mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-13 20:29:39 +02:00
SecretKeyRingEditor: UserIDs only reside on primary keys
This commit is contained in:
parent
57c11a63e5
commit
77800f26e8
5 changed files with 101 additions and 266 deletions
|
@ -136,7 +136,7 @@ public class SigningTest {
|
|||
.modernKeyRing("alice", "password123");
|
||||
SecretKeyRingProtector protector = SecretKeyRingProtector.unlockAllKeysWith(Passphrase.fromPassword("password123"), secretKeys);
|
||||
secretKeys = PGPainless.modifyKeyRing(secretKeys)
|
||||
.revokeUserIdOnAllSubkeys("alice", protector)
|
||||
.revokeUserId("alice", protector)
|
||||
.done();
|
||||
|
||||
final PGPSecretKeyRing fSecretKeys = secretKeys;
|
||||
|
|
|
@ -64,7 +64,7 @@ public class UserIdRevocationTest {
|
|||
|
||||
// make a copy with revoked subkey
|
||||
PGPSecretKeyRing revoked = PGPainless.modifyKeyRing(secretKeys)
|
||||
.revokeUserIdOnAllSubkeys("secondary@key.id", new UnprotectedKeysProtector())
|
||||
.revokeUserId("secondary@key.id", new UnprotectedKeysProtector())
|
||||
.done();
|
||||
|
||||
KeyRingInfo info = PGPainless.inspectKeyRing(revoked);
|
||||
|
@ -78,7 +78,7 @@ public class UserIdRevocationTest {
|
|||
assertTrue(info.isUserIdValid("secondary@key.id")); // key on original secret key ring is still valid
|
||||
|
||||
revoked = PGPainless.modifyKeyRing(secretKeys)
|
||||
.revokeUserId("secondary@key.id", secretKeys.getSecretKey().getKeyID(), new UnprotectedKeysProtector())
|
||||
.revokeUserId("secondary@key.id", new UnprotectedKeysProtector())
|
||||
.done();
|
||||
info = PGPainless.inspectKeyRing(revoked);
|
||||
userIds = info.getUserIds();
|
||||
|
@ -103,7 +103,7 @@ public class UserIdRevocationTest {
|
|||
.build();
|
||||
|
||||
secretKeys = PGPainless.modifyKeyRing(secretKeys)
|
||||
.revokeUserIdOnAllSubkeys("secondary@key.id", new UnprotectedKeysProtector(),
|
||||
.revokeUserId("secondary@key.id", new UnprotectedKeysProtector(),
|
||||
RevocationAttributes.createCertificateRevocation()
|
||||
.withReason(RevocationAttributes.Reason.USER_ID_NO_LONGER_VALID)
|
||||
.withDescription("I lost my mail password"))
|
||||
|
@ -123,10 +123,8 @@ public class UserIdRevocationTest {
|
|||
SecretKeyRingProtector protector = PasswordBasedSecretKeyRingProtector
|
||||
.forKey(secretKeys.getSecretKey(), TestKeys.CRYPTIE_PASSPHRASE);
|
||||
|
||||
assertThrows(IllegalArgumentException.class, () -> PGPainless.modifyKeyRing(secretKeys)
|
||||
.revokeUserId("cryptie@encrypted.key", 1L, protector));
|
||||
assertThrows(IllegalArgumentException.class, () -> PGPainless.modifyKeyRing(secretKeys)
|
||||
.revokeUserId("cryptie@encrypted.key", TestKeys.EMIL_FINGERPRINT, protector));
|
||||
assertThrows(NoSuchElementException.class, () -> PGPainless.modifyKeyRing(secretKeys)
|
||||
.revokeSubKey(1L, protector));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -136,9 +134,7 @@ public class UserIdRevocationTest {
|
|||
.forKey(secretKeys.getSecretKey(), TestKeys.CRYPTIE_PASSPHRASE);
|
||||
|
||||
assertThrows(NoSuchElementException.class, () -> PGPainless.modifyKeyRing(secretKeys)
|
||||
.revokeUserId("invalid@user.id", TestKeys.CRYPTIE_FINGERPRINT, protector));
|
||||
assertThrows(NoSuchElementException.class, () -> PGPainless.modifyKeyRing(secretKeys)
|
||||
.revokeUserId("invalid@user.id", TestKeys.CRYPTIE_KEY_ID, protector));
|
||||
.revokeUserId("invalid@user.id", protector));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -148,7 +144,7 @@ public class UserIdRevocationTest {
|
|||
.forKey(secretKeys.getSecretKey(), TestKeys.CRYPTIE_PASSPHRASE);
|
||||
|
||||
assertThrows(IllegalArgumentException.class, () -> PGPainless.modifyKeyRing(secretKeys)
|
||||
.revokeUserId("cryptie@encrypted.key", secretKeys.getSecretKey().getKeyID(), protector,
|
||||
.revokeUserId("cryptie@encrypted.key", protector,
|
||||
RevocationAttributes.createKeyRevocation().withReason(RevocationAttributes.Reason.KEY_RETIRED)
|
||||
.withDescription("This is not a valid certification revocation reason.")));
|
||||
}
|
||||
|
|
|
@ -69,14 +69,6 @@ public class AddUserIdTest {
|
|||
assertFalse(userIds.hasNext());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void addUserId_NoSuchElementExceptionForMissingKey() throws IOException, PGPException {
|
||||
PGPSecretKeyRing secretKeys = TestKeys.getCryptieSecretKeyRing();
|
||||
assertThrows(NoSuchElementException.class, () -> PGPainless.modifyKeyRing(secretKeys)
|
||||
.addUserId(0L, TestKeys.CRYPTIE_UID, new UnprotectedKeysProtector()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteUserId_noSuchElementExceptionForMissingUserId() throws IOException, PGPException {
|
||||
PGPSecretKeyRing secretKeys = TestKeys.getCryptieSecretKeyRing();
|
||||
|
@ -84,13 +76,6 @@ public class AddUserIdTest {
|
|||
.deleteUserId("invalid@user.id", new UnprotectedKeysProtector()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteUserId_noSuchElementExceptionForMissingKey() throws IOException, PGPException {
|
||||
PGPSecretKeyRing secretKeys = TestKeys.getCryptieSecretKeyRing();
|
||||
assertThrows(NoSuchElementException.class, () -> PGPainless.modifyKeyRing(secretKeys)
|
||||
.deleteUserId(0L, TestKeys.CRYPTIE_UID, new UnprotectedKeysProtector()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteExistingAndAddNewUserIdToExistingKeyRing() throws PGPException, IOException {
|
||||
final String ARMORED_PRIVATE_KEY =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue