MCPcopy Create free account
hub / github.com/crewjam/saml / TestMiddlewareRequireAttribute

Function TestMiddlewareRequireAttribute

samlsp/middleware_test.go:325–341  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

323}
324
325func TestMiddlewareRequireAttribute(t *testing.T) {
326 test := NewMiddlewareTest(t)
327 handler := test.Middleware.RequireAccount(
328 RequireAttribute("eduPersonAffiliation", "Staff")(
329 http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
330 w.WriteHeader(http.StatusTeapot)
331 })))
332
333 req, _ := http.NewRequest("GET", "/frob", nil)
334 req.Header.Set("Cookie", ""+
335 "ttt="+test.expectedSessionCookie+"; "+
336 "Path=/; Max-Age=7200")
337 resp := httptest.NewRecorder()
338 handler.ServeHTTP(resp, req)
339
340 assert.Check(t, is.Equal(http.StatusTeapot, resp.Code))
341}
342
343func TestMiddlewareRequireAttributeWrongValue(t *testing.T) {
344 test := NewMiddlewareTest(t)

Callers

nothing calls this directly

Calls 4

NewMiddlewareTestFunction · 0.85
RequireAttributeFunction · 0.85
RequireAccountMethod · 0.80
ServeHTTPMethod · 0.80

Tested by

no test coverage detected