MCPcopy
hub / github.com/fabiolb/fabio / TestNewBasicAuth

Function TestNewBasicAuth

auth/basic_test.go:73–106  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

71}
72
73func TestNewBasicAuth(t *testing.T) {
74
75 t.Run("should create a basic auth scheme from the supplied config", func(t *testing.T) {
76 filename, err := createBasicAuthFile("foo:bar", t)
77
78 if err != nil {
79 t.Error(err)
80 }
81
82 _, err = newBasicAuth(config.BasicAuth{
83 File: filename,
84 })
85
86 if err != nil {
87 t.Error(err)
88 }
89 })
90
91 t.Run("should log a warning when credentials are malformed", func(t *testing.T) {
92 filename, err := createBasicAuthFile("foosdlijdgohdgdbar", t)
93
94 if err != nil {
95 t.Error(err)
96 }
97
98 _, err = newBasicAuth(config.BasicAuth{
99 File: filename,
100 })
101
102 if err != nil {
103 t.Error(err)
104 }
105 })
106}
107
108func TestBasic_Authorised(t *testing.T) {
109 basicAuth, err := createBasicAuth("foo", "bar", t)

Callers

nothing calls this directly

Calls 3

createBasicAuthFileFunction · 0.85
newBasicAuthFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected