MCPcopy
hub / github.com/perkeep/perkeep / TestMultiMode

Function TestMultiMode

pkg/auth/auth_test.go:62–98  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

60}
61
62func TestMultiMode(t *testing.T) {
63 req, err := http.NewRequest("GET", "/", nil)
64 if err != nil {
65 t.Fatal(err)
66 }
67 (&UserPass{Username: "foo", Password: "bar"}).AddAuthHeader(req)
68
69 modes = []AuthMode{
70 &UserPass{
71 Username: "foo",
72 Password: "baz",
73 },
74 }
75
76 if Allowed(req, OpAll) {
77 t.Fatalf("req should not be allowed")
78 }
79
80 AddMode(&UserPass{
81 Username: "foo",
82 Password: "bar",
83 })
84
85 if !Allowed(req, OpAll) {
86 t.Fatalf("req should now be allowed")
87 }
88
89 SetMode(&UserPass{
90 Username: "foo",
91 Password: "baz",
92 })
93
94 if Allowed(req, OpAll) {
95 t.Fatalf("req should not be allowed anymore")
96 }
97
98}
99
100func TestEmptyPasswords(t *testing.T) {
101 tests := []struct {

Callers

nothing calls this directly

Calls 7

AllowedFunction · 0.85
AddModeFunction · 0.85
SetModeFunction · 0.85
NewRequestMethod · 0.80
FatalMethod · 0.80
AddAuthHeaderMethod · 0.65
FatalfMethod · 0.65

Tested by

no test coverage detected