|
1 | 1 | package uk.gov.di.authentication.shared.services; |
2 | 2 |
|
| 3 | +import com.amazonaws.services.kms.model.GetPublicKeyRequest; |
| 4 | +import com.amazonaws.services.kms.model.GetPublicKeyResult; |
3 | 5 | import com.amazonaws.services.kms.model.SignRequest; |
4 | 6 | import com.amazonaws.services.kms.model.SignResult; |
5 | 7 | import com.fasterxml.jackson.core.JsonProcessingException; |
6 | 8 | import com.fasterxml.jackson.databind.ObjectMapper; |
7 | 9 | import com.nimbusds.jose.JOSEException; |
8 | 10 | import com.nimbusds.jose.JWSAlgorithm; |
| 11 | +import com.nimbusds.jose.JWSHeader; |
9 | 12 | import com.nimbusds.jose.crypto.ECDSASigner; |
10 | 13 | import com.nimbusds.jose.crypto.impl.ECDSA; |
11 | 14 | import com.nimbusds.jose.jwk.Curve; |
|
65 | 68 | import static org.hamcrest.Matchers.equalTo; |
66 | 69 | import static org.hamcrest.Matchers.hasItem; |
67 | 70 | import static org.hamcrest.Matchers.not; |
| 71 | +import static org.hamcrest.core.Is.is; |
68 | 72 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
69 | 73 | import static org.junit.jupiter.api.Assertions.assertNull; |
70 | 74 | import static org.junit.jupiter.api.Assertions.assertTrue; |
@@ -114,6 +118,9 @@ void setUp() { |
114 | 118 | when(configurationService.getAccessTokenExpiry()).thenReturn(300L); |
115 | 119 | when(configurationService.getIDTokenExpiry()).thenReturn(120L); |
116 | 120 | when(configurationService.getSessionExpiry()).thenReturn(300L); |
| 121 | + when(kmsConnectionService.getPublicKey(any(GetPublicKeyRequest.class))) |
| 122 | + .thenReturn(new GetPublicKeyResult().withKeyId("789789789789789")); |
| 123 | + |
117 | 124 | nonce = new Nonce(); |
118 | 125 | } |
119 | 126 |
|
@@ -529,6 +536,13 @@ private void assertSuccessfullTokenResponse(OIDCTokenResponse tokenResponse) |
529 | 536 | accessTokenKey, |
530 | 537 | new ObjectMapper().writeValueAsString(accessTokenStore), |
531 | 538 | 300L); |
| 539 | + |
| 540 | + var header = (JWSHeader) tokenResponse.getOIDCTokens().getIDToken().getHeader(); |
| 541 | + |
| 542 | + assertThat( |
| 543 | + header.getKeyID(), |
| 544 | + is("1d504aece298a14d74ee0a02b6740b4372a1fab4206778e486ba72770ff4beb8")); |
| 545 | + |
532 | 546 | assertThat( |
533 | 547 | tokenResponse.getOIDCTokens().getIDToken().getJWTClaimsSet().getClaims().size(), |
534 | 548 | equalTo(9)); |
|
0 commit comments