MCPcopy
hub / github.com/gin-gonic/gin / TestBasicAuth

Function TestBasicAuth

auth_test.go:16–36  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestBasicAuth(t *testing.T) {
17 pairs := processAccounts(Accounts{
18 "admin": "password",
19 "foo": "bar",
20 "bar": "foo",
21 })
22
23 assert.Len(t, pairs, 3)
24 assert.Contains(t, pairs, authPair{
25 user: "bar",
26 value: "Basic YmFyOmZvbw==",
27 })
28 assert.Contains(t, pairs, authPair{
29 user: "foo",
30 value: "Basic Zm9vOmJhcg==",
31 })
32 assert.Contains(t, pairs, authPair{
33 user: "admin",
34 value: "Basic YWRtaW46cGFzc3dvcmQ=",
35 })
36}
37
38func TestBasicAuthFails(t *testing.T) {
39 assert.Panics(t, func() { processAccounts(nil) })

Callers

nothing calls this directly

Calls 1

processAccountsFunction · 0.85

Tested by

no test coverage detected