mirror of
https://github.com/pgpainless/pgpainless.git
synced 2025-09-14 20:59:39 +02:00
Add method KeyRingInfo.isFullyEncrypted() Fixes #107 Co-authored-by: Ivan Pizhenko <IvanPizhenko@users.noreply.github.com>
This commit is contained in:
parent
0b3511486c
commit
eb47e5caa3
4 changed files with 118 additions and 14 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2020 Paul Schaub.
|
||||
* Copyright 2020 Paul Schaub. Copyright 2021 Flowcrypt a.s.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -89,16 +89,34 @@ public class KeyRingInfoTest {
|
|||
|
||||
assertTrue(info.isFullyDecrypted());
|
||||
|
||||
secretKeys = PGPainless.modifyKeyRing(secretKeys)
|
||||
.changePassphraseFromOldPassphrase(null)
|
||||
.withSecureDefaultSettings()
|
||||
.toNewPassphrase(Passphrase.fromPassword("sw0rdf1sh"))
|
||||
.done();
|
||||
secretKeys = encryptSecretKeys(secretKeys);
|
||||
info = PGPainless.inspectKeyRing(secretKeys);
|
||||
|
||||
assertFalse(info.isFullyDecrypted());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsFullyEncrypted() throws IOException, PGPException {
|
||||
PGPSecretKeyRing secretKeys = TestKeys.getEmilSecretKeyRing();
|
||||
KeyRingInfo info = PGPainless.inspectKeyRing(secretKeys);
|
||||
|
||||
assertFalse(info.isFullyEncrypted());
|
||||
|
||||
secretKeys = encryptSecretKeys(secretKeys);
|
||||
info = PGPainless.inspectKeyRing(secretKeys);
|
||||
|
||||
assertTrue(info.isFullyEncrypted());
|
||||
}
|
||||
|
||||
private static PGPSecretKeyRing encryptSecretKeys(PGPSecretKeyRing secretKeys) throws PGPException {
|
||||
return PGPainless.modifyKeyRing(secretKeys)
|
||||
.changePassphraseFromOldPassphrase(null)
|
||||
.withSecureDefaultSettings()
|
||||
.toNewPassphrase(Passphrase.fromPassword("sw0rdf1sh"))
|
||||
.done();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetSecretKey() throws IOException, PGPException {
|
||||
PGPSecretKeyRing secretKeys = TestKeys.getCryptieSecretKeyRing();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue