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

Function idpErrCheckErrorResponse

idp_error_response_test.go:51–76  ·  view source on GitHub ↗

idpErrCheckErrorResponse checks that el is a signed Response from the IdP with the given status codes and no assertion.

(t *testing.T, test *IdentityProviderTest, el *etree.Element, inResponseTo, topLevel, secondLevel, message string)

Source from the content-addressed store, hash-verified

49// idpErrCheckErrorResponse checks that el is a signed Response from the IdP
50// with the given status codes and no assertion.
51func idpErrCheckErrorResponse(t *testing.T, test *IdentityProviderTest, el *etree.Element, inResponseTo, topLevel, secondLevel, message string) {
52 t.Helper()
53 assert.Check(t, is.Equal("Response", el.Tag))
54 assert.Check(t, is.Equal(inResponseTo, el.SelectAttrValue("InResponseTo", "<none>")))
55 assert.Check(t, is.Equal(test.SP.AcsURL.String(), el.SelectAttrValue("Destination", "")))
56 assert.Check(t, is.Equal(test.IDP.MetadataURL.String(), el.FindElement("./Issuer").Text()))
57 assert.Check(t, el.FindElement("./Signature") != nil, "response is not signed")
58 assert.Check(t, el.FindElement("./Assertion") == nil)
59 assert.Check(t, el.FindElement("./EncryptedAssertion") == nil)
60
61 code := el.FindElement("./Status/StatusCode")
62 assert.Assert(t, code != nil)
63 assert.Check(t, is.Equal(topLevel, code.SelectAttrValue("Value", "")))
64 nested := code.FindElement("./StatusCode")
65 if secondLevel == "" {
66 assert.Check(t, nested == nil)
67 } else if assert.Check(t, nested != nil) {
68 assert.Check(t, is.Equal(secondLevel, nested.SelectAttrValue("Value", "")))
69 }
70 msg := el.FindElement("./Status/StatusMessage")
71 if message == "" {
72 assert.Check(t, msg == nil)
73 } else if assert.Check(t, msg != nil) {
74 assert.Check(t, is.Equal(message, msg.Text()))
75 }
76}
77
78// idpErrCheckSPRejects checks that the SP parsing the form in body for
79// requestIDs reports ErrBadStatus with topLevel.

Calls 1

StringMethod · 0.80

Tested by

no test coverage detected