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

Function TestMiddlewareRequireAttributeNotPresent

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

Source from the content-addressed store, hash-verified

359}
360
361func TestMiddlewareRequireAttributeNotPresent(t *testing.T) {
362 test := NewMiddlewareTest(t)
363 handler := test.Middleware.RequireAccount(
364 RequireAttribute("valueThatDoesntExist", "doesntMatter")(
365 http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
366 panic("not reached")
367 })))
368
369 req, _ := http.NewRequest("GET", "/frob", nil)
370 req.Header.Set("Cookie", ""+
371 "ttt="+test.expectedSessionCookie+"; "+
372 "Path=/; Max-Age=7200")
373 resp := httptest.NewRecorder()
374 handler.ServeHTTP(resp, req)
375
376 assert.Check(t, is.Equal(http.StatusForbidden, resp.Code))
377}
378
379func TestMiddlewareRequireAttributeMissingAccount(t *testing.T) {
380 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