Update CertificateValidationServiceTest.java

This commit is contained in:
Ludy87 2025-08-10 12:35:41 +02:00
parent cf2f366e8e
commit a1e029679a
No known key found for this signature in database
GPG Key ID: 92696155E0220F94

View File

@ -155,19 +155,19 @@ class CertificateValidationServiceTest {
void testValidateTrustStore_found_returnsTrue() throws Exception {
KeyStore ks = mock(KeyStore.class);
// Ein Zertifikat-Mock, der sowohl im Keystore liegt als auch geprüft wird:
// A certificate mock that is both in the keystore and being checked:
X509Certificate same = mock(X509Certificate.class);
when(ks.aliases())
.thenReturn(java.util.Collections.enumeration(java.util.List.of("alias1")));
when(ks.getCertificate("alias1")).thenReturn(same);
// trustStore per Reflection setzen
// Set trustStore via reflection
var f = CertificateValidationService.class.getDeclaredField("trustStore");
f.setAccessible(true);
f.set(validationService, ks);
// same-Instanz -> equals() true ohne Stubbing
// same instance -> equals() true without stubbing
assertTrue(validationService.validateTrustStore(same));
}