MCPcopy Index your code
hub / github.com/dnote/dnote / TestGetSessionKeyFromAuth

Function TestGetSessionKeyFromAuth

pkg/server/middleware/helpers_test.go:74–102  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

72}
73
74func TestGetSessionKeyFromAuth(t *testing.T) {
75 testCases := []struct {
76 authHeaderStr string
77 expected string
78 }{
79 {
80 authHeaderStr: "Bearer foo",
81 expected: "foo",
82 },
83 }
84
85 for _, tc := range testCases {
86 // set up
87 r, err := http.NewRequest("GET", "/", nil)
88 if err != nil {
89 t.Fatal(errors.Wrap(err, "constructing request"))
90 }
91
92 r.Header.Set("Authorization", tc.authHeaderStr)
93
94 // execute
95 got, err := getSessionKeyFromAuth(r)
96 if err != nil {
97 t.Fatal(errors.Wrap(err, "executing"))
98 }
99
100 assert.Equal(t, got, tc.expected, "result mismatch")
101 }
102}
103
104func mustMakeRequest(t *testing.T) *http.Request {
105 r, err := http.NewRequest("GET", "/", nil)

Callers

nothing calls this directly

Calls 2

EqualFunction · 0.92
getSessionKeyFromAuthFunction · 0.70

Tested by

no test coverage detected