mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-08-16 13:47:28 +02:00
Update CertificateValidationServiceTest.java
This commit is contained in:
parent
cf2f366e8e
commit
a1e029679a
@ -155,19 +155,19 @@ class CertificateValidationServiceTest {
|
|||||||
void testValidateTrustStore_found_returnsTrue() throws Exception {
|
void testValidateTrustStore_found_returnsTrue() throws Exception {
|
||||||
KeyStore ks = mock(KeyStore.class);
|
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);
|
X509Certificate same = mock(X509Certificate.class);
|
||||||
|
|
||||||
when(ks.aliases())
|
when(ks.aliases())
|
||||||
.thenReturn(java.util.Collections.enumeration(java.util.List.of("alias1")));
|
.thenReturn(java.util.Collections.enumeration(java.util.List.of("alias1")));
|
||||||
when(ks.getCertificate("alias1")).thenReturn(same);
|
when(ks.getCertificate("alias1")).thenReturn(same);
|
||||||
|
|
||||||
// trustStore per Reflection setzen
|
// Set trustStore via reflection
|
||||||
var f = CertificateValidationService.class.getDeclaredField("trustStore");
|
var f = CertificateValidationService.class.getDeclaredField("trustStore");
|
||||||
f.setAccessible(true);
|
f.setAccessible(true);
|
||||||
f.set(validationService, ks);
|
f.set(validationService, ks);
|
||||||
|
|
||||||
// same-Instanz -> equals() true ohne Stubbing
|
// same instance -> equals() true without stubbing
|
||||||
assertTrue(validationService.validateTrustStore(same));
|
assertTrue(validationService.validateTrustStore(same));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user