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

Function encryptedAssertionAlgorithm

identity_provider_assertion_encrypter_test.go:69–90  ·  view source on GitHub ↗

encryptedAssertionAlgorithm makes and encrypts an assertion for a validated request from the test SP, after edit has adjusted the request, and returns the block cipher the EncryptedData names. It also checks that the SP's key decrypts it.

(t *testing.T, edit func(*IdentityProviderTest, *IdpAuthnRequest))

Source from the content-addressed store, hash-verified

67// and returns the block cipher the EncryptedData names. It also checks
68// that the SP's key decrypts it.
69func encryptedAssertionAlgorithm(t *testing.T, edit func(*IdentityProviderTest, *IdpAuthnRequest)) string {
70 t.Helper()
71 test := NewIdentityProviderTest(t, applyKey)
72 authReq, err := test.SP.MakeAuthenticationRequest(test.IDP.SSOURL.String(), HTTPPostBinding, HTTPPostBinding)
73 assert.NilError(t, err)
74 req, err := NewIdpAuthnRequest(&test.IDP, postForm(t, authReq.Post("")))
75 assert.NilError(t, err)
76 assert.NilError(t, req.Validate())
77 if edit != nil {
78 edit(test, req)
79 }
80 assert.NilError(t, DefaultAssertionMaker{}.MakeAssertion(req, &Session{ID: "s", UserName: "alice"}))
81 assert.NilError(t, req.MakeAssertionEl())
82
83 encryptedData := req.AssertionEl.FindElement("./EncryptedData")
84 assert.Assert(t, encryptedData != nil, "the assertion is encrypted")
85 method := encryptedData.FindElement("./EncryptionMethod")
86 assert.Assert(t, method != nil)
87 _, err = xmlenc.Decrypt(test.SPKey, encryptedData)
88 assert.NilError(t, err, "the SP's key decrypts the assertion")
89 return method.SelectAttrValue("Algorithm", "")
90}
91
92// By default the assertion is encrypted with the strongest block cipher the
93// SP's metadata lists: this package's SP lists AES-256-GCM.

Calls 10

ValidateMethod · 0.95
MakeAssertionElMethod · 0.95
DecryptFunction · 0.92
NewIdentityProviderTestFunction · 0.85
NewIdpAuthnRequestFunction · 0.85
postFormFunction · 0.85
StringMethod · 0.80
MakeAssertionMethod · 0.65
PostMethod · 0.45

Tested by

no test coverage detected