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

Function TestIDPMakeErrorResponse

idp_error_response_test.go:90–113  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

88}
89
90func TestIDPMakeErrorResponse(t *testing.T) {
91 test := idpErrNewTest(t)
92 req := idpErrValidRequest(t, test)
93
94 assert.NilError(t, req.MakeErrorResponse(StatusResponder, StatusNoPassive, "cannot authenticate passively"))
95 assert.Check(t, req.Assertion == nil)
96 assert.Check(t, req.AssertionEl == nil)
97 idpErrCheckErrorResponse(t, test, req.ResponseEl, req.Request.ID, StatusResponder, StatusNoPassive, "cannot authenticate passively")
98
99 // The Response unmarshals into the package's Response type.
100 var response Response
101 assert.NilError(t, unmarshalEtreeHack(req.ResponseEl.Copy(), &response))
102 assert.Check(t, is.Equal(StatusResponder, response.Status.StatusCode.Value))
103 assert.Check(t, response.Assertion == nil)
104
105 // It is posted to the ACS with the RelayState, like a success Response.
106 w := httptest.NewRecorder()
107 assert.NilError(t, req.WriteResponse(w))
108 _, action, fields := idpErrResponseFromForm(t, w.Body.Bytes())
109 assert.Check(t, is.Equal(test.SP.AcsURL.String(), action))
110 assert.Check(t, is.DeepEqual([]string{"relay"}, fields["RelayState"]))
111
112 idpErrCheckSPRejects(t, test, w.Body.Bytes(), []string{req.Request.ID}, StatusResponder)
113}
114
115func TestIDPMakeErrorResponseWithoutSecondLevelOrMessage(t *testing.T) {
116 test := idpErrNewTest(t)

Callers

nothing calls this directly

Calls 10

idpErrNewTestFunction · 0.85
idpErrValidRequestFunction · 0.85
idpErrCheckErrorResponseFunction · 0.85
unmarshalEtreeHackFunction · 0.85
idpErrResponseFromFormFunction · 0.85
idpErrCheckSPRejectsFunction · 0.85
MakeErrorResponseMethod · 0.80
BytesMethod · 0.80
StringMethod · 0.80
WriteResponseMethod · 0.65

Tested by

no test coverage detected