1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-12-23 03:17:58 +01:00

Fix unreliable unit test

Fixes #389
This commit is contained in:
Paul Schaub 2023-07-07 11:07:14 +02:00
parent cac500874a
commit 30481cd510
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
3 changed files with 17 additions and 1 deletions

View file

@ -83,6 +83,12 @@ public class SecretKeyRingEditor implements SecretKeyRingEditorInterface {
this.referenceTime = referenceTime; this.referenceTime = referenceTime;
} }
@Nonnull
@Override
public Date getReferenceTime() {
return referenceTime;
}
@Override @Override
public SecretKeyRingEditorInterface addUserId( public SecretKeyRingEditorInterface addUserId(
@Nonnull CharSequence userId, @Nonnull CharSequence userId,

View file

@ -29,6 +29,14 @@ import org.pgpainless.util.selection.userid.SelectUserId;
public interface SecretKeyRingEditorInterface { public interface SecretKeyRingEditorInterface {
/**
* Return the editors reference time.
*
* @return reference time
*/
@Nonnull
Date getReferenceTime();
/** /**
* Add a user-id to the key ring. * Add a user-id to the key ring.
* *

View file

@ -76,7 +76,9 @@ public class RefuseToAddWeakSubkeyTest {
PGPainless.getPolicy().setPublicKeyAlgorithmPolicy(new Policy.PublicKeyAlgorithmPolicy(minimalBitStrengths)); PGPainless.getPolicy().setPublicKeyAlgorithmPolicy(new Policy.PublicKeyAlgorithmPolicy(minimalBitStrengths));
SecretKeyRingEditorInterface editor = PGPainless.modifyKeyRing(secretKeys); SecretKeyRingEditorInterface editor = PGPainless.modifyKeyRing(secretKeys);
KeySpec spec = KeySpec.getBuilder(KeyType.RSA(RsaLength._1024), KeyFlag.ENCRYPT_COMMS).build(); KeySpec spec = KeySpec.getBuilder(KeyType.RSA(RsaLength._1024), KeyFlag.ENCRYPT_COMMS)
.setKeyCreationDate(editor.getReferenceTime()) // The key gets created after we instantiate the editor.
.build();
secretKeys = editor.addSubKey(spec, Passphrase.emptyPassphrase(), SecretKeyRingProtector.unprotectedKeys()) secretKeys = editor.addSubKey(spec, Passphrase.emptyPassphrase(), SecretKeyRingProtector.unprotectedKeys())
.done(); .done();