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))
| 67 | // and returns the block cipher the EncryptedData names. It also checks |
| 68 | // that the SP's key decrypts it. |
| 69 | func 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. |
no test coverage detected