4545import eu .webeid .security .validator .certvalidators .SubjectCertificateValidatorBatch ;
4646import eu .webeid .security .validator .ocsp .OcspClient ;
4747import eu .webeid .security .validator .ocsp .OcspServiceProvider ;
48- import org .bouncycastle .asn1 .x509 .Extension ;
4948import org .junit .jupiter .api .AfterEach ;
5049import org .junit .jupiter .api .BeforeEach ;
5150import org .junit .jupiter .api .Disabled ;
@@ -409,8 +408,9 @@ void whenV11SigningCertificateNotIssuedBySameAuthority_thenValidationFails() thr
409408
410409 X509Certificate mockSigningCert = mock (X509Certificate .class );
411410 when (mockSigningCert .getSubjectX500Principal ()).thenReturn (realSubjectCert .getSubjectX500Principal ());
412- when (mockSigningCert .getExtensionValue (Extension .authorityKeyIdentifier .getId ()))
413- .thenReturn (new byte []{0x01 , 0x02 });
411+ when (mockSigningCert .getIssuerX500Principal ()).thenReturn (
412+ new javax .security .auth .x500 .X500Principal ("CN=Other Test CA, O=Other Org, C=EE" )
413+ );
414414
415415 try (MockedStatic <CertificateLoader > mocked = mockStatic (CertificateLoader .class )) {
416416 mocked .when (() -> CertificateLoader .decodeCertificateFromBase64 (parsedToken .getUnverifiedCertificate ()))
@@ -420,21 +420,21 @@ void whenV11SigningCertificateNotIssuedBySameAuthority_thenValidationFails() thr
420420
421421 assertThatThrownBy (() -> spyValidator .validate (parsedToken , VALID_CHALLENGE_NONCE ))
422422 .isInstanceOf (AuthTokenParseException .class )
423- .hasMessage ("Signing certificate not issued by same authority as authentication certificate " );
423+ .hasMessage ("Signing and authentication certificates are not issued by the same authority" );
424424 }
425425 }
426426
427-
428427 @ Test
429- void whenV11SigningCertificateHasNoNonRepudiationUsage_thenValidationFails () throws Exception {
428+ void whenV11SigningCertificateNotSuitableForSigning_thenValidationFails () throws Exception {
430429 AuthTokenV11Validator spyValidator = spyAuthTokenV11Validator ();
431430 WebEidAuthToken parsedToken = OBJECT_READER .readValue (V11_AUTH_TOKEN , WebEidAuthToken .class );
432431 X509Certificate realSubjectCert = CertificateLoader .decodeCertificateFromBase64 (parsedToken .getUnverifiedCertificate ());
433432 doReturn (realSubjectCert ).when (spyValidator ).validateV1 (any (), any ());
434433
435434 X509Certificate signingCert = mock (X509Certificate .class );
436435 when (signingCert .getSubjectX500Principal ()).thenReturn (realSubjectCert .getSubjectX500Principal ());
437- when (signingCert .getKeyUsage ()).thenReturn (new boolean []{true , false });
436+ when (signingCert .getIssuerX500Principal ()).thenReturn (realSubjectCert .getIssuerX500Principal ());
437+ when (signingCert .getKeyUsage ()).thenReturn (new boolean []{false , false });
438438
439439 try (MockedStatic <CertificateLoader > mocked = mockStatic (CertificateLoader .class )) {
440440 mocked .when (() -> CertificateLoader .decodeCertificateFromBase64 (parsedToken .getUnverifiedCertificate ()))
@@ -444,7 +444,7 @@ void whenV11SigningCertificateHasNoNonRepudiationUsage_thenValidationFails() thr
444444
445445 assertThatThrownBy (() -> spyValidator .validate (parsedToken , VALID_CHALLENGE_NONCE ))
446446 .isInstanceOf (AuthTokenParseException .class )
447- .hasMessage ("Signing certificate does not have nonRepudiation key usage " );
447+ .hasMessage ("Signing certificate not suitable for signing " );
448448 }
449449 }
450450
0 commit comments