Skip to content

Commit

Permalink
Added removeKey test for KeyStoreService and made changes to KeyStore…
Browse files Browse the repository at this point in the history
…AuthTest noPasswords test
  • Loading branch information
Thendo20 committed Jun 27, 2024
1 parent 65b7e08 commit 83cac9a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class KeyStoreAuthTest extends BaseMockitoTest {
@Test
void noPasswords() {
KeyStoreAuth keyStoreAuth = new KeyStoreAuth(null, null);
assertThrows(KeyStoreAuthException.class, () -> keyStoreAuth.getReadKeyPassword());
assertThrows(KeyStoreAuthException.class, () -> keyStoreAuth.getReadKeyPassword());
assertThrows(KeyStoreAuthException.class, keyStoreAuth::getReadKeyPassword);
assertThrows(KeyStoreAuthException.class, keyStoreAuth::getReadStorePassword);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,15 @@ void getSecretKey() {
SecretKey secretKey = keyStoreService.getSecretKey(keyStoreAccess, keyID);
Assertions.assertNotNull(secretKey);
}
@Test
void removeKey() {
KeyCreationConfig config = KeyCreationConfig.builder().signKeyNumber(1).encKeyNumber(0).build();
KeyStore keyStore = keyStoreService.createKeyStore(keyStoreAuth, config);
KeyStoreAccess keyStoreAccess = new KeyStoreAccess(keyStore, keyStoreAuth);

KeyID keyID = KeystoreUtil.keyIdByPrefix(keyStore, DOCUMENT_KEY_ID_PREFIX);
keyStoreService.removeKey(keyStoreAccess, keyID.getValue());
SecretKey secretKey = keyStoreService.getSecretKey(keyStoreAccess, keyID);
Assertions.assertNull(secretKey);
}
}

0 comments on commit 83cac9a

Please sign in to comment.