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

Function TestMiddlewareRequireAttributeMissingAccount

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

Source from the content-addressed store, hash-verified

377}
378
379func TestMiddlewareRequireAttributeMissingAccount(t *testing.T) {
380 test := NewMiddlewareTest(t)
381 handler := RequireAttribute("eduPersonAffiliation", "DomainAdmins")(
382 http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
383 panic("not reached")
384 }))
385
386 req, _ := http.NewRequest("GET", "/frob", nil)
387 req.Header.Set("Cookie", ""+
388 "ttt="+test.expectedSessionCookie+"; "+
389 "Path=/; Max-Age=7200")
390 resp := httptest.NewRecorder()
391 handler.ServeHTTP(resp, req)
392
393 assert.Check(t, is.Equal(http.StatusForbidden, resp.Code))
394}
395
396func TestMiddlewareCanParseResponse(t *testing.T) {
397 test := NewMiddlewareTest(t)

Callers

nothing calls this directly

Calls 3

NewMiddlewareTestFunction · 0.85
RequireAttributeFunction · 0.85
ServeHTTPMethod · 0.80

Tested by

no test coverage detected