mirror of
https://codeberg.org/PGPainless/wkd-java.git
synced 2024-11-22 07:12:05 +01:00
Add test for unbound user-ids
This commit is contained in:
parent
8968f69e31
commit
38ef283313
1 changed files with 32 additions and 0 deletions
|
@ -22,6 +22,7 @@ import org.bouncycastle.openpgp.PGPException;
|
||||||
import org.bouncycastle.openpgp.PGPPublicKey;
|
import org.bouncycastle.openpgp.PGPPublicKey;
|
||||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||||
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
import org.bouncycastle.openpgp.PGPSecretKeyRing;
|
||||||
|
import org.bouncycastle.openpgp.PGPSignature;
|
||||||
import org.pgpainless.PGPainless;
|
import org.pgpainless.PGPainless;
|
||||||
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
import org.pgpainless.key.protection.SecretKeyRingProtector;
|
||||||
|
|
||||||
|
@ -47,6 +48,7 @@ public class TestSuiteGenerator {
|
||||||
tests.add(baseCaseMultipleCertificates(structure));
|
tests.add(baseCaseMultipleCertificates(structure));
|
||||||
tests.add(wrongUserId(structure));
|
tests.add(wrongUserId(structure));
|
||||||
tests.add(noUserId(structure));
|
tests.add(noUserId(structure));
|
||||||
|
tests.add(unboundUserId(structure));
|
||||||
tests.addAll(baseCaseMultiUserIds(structure));
|
tests.addAll(baseCaseMultiUserIds(structure));
|
||||||
tests.add(secretKeyMaterial(structure));
|
tests.add(secretKeyMaterial(structure));
|
||||||
tests.add(randomBytes(structure));
|
tests.add(randomBytes(structure));
|
||||||
|
@ -158,6 +160,36 @@ public class TestSuiteGenerator {
|
||||||
return TestCase.fail("Wrong User-ID", description, lookupMail, directoryStructure);
|
return TestCase.fail("Wrong User-ID", description, lookupMail, directoryStructure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TestCase unboundUserId(WkdDirectoryStructure directoryStructure) throws Exception {
|
||||||
|
String lookupMail = "unbound-userid@" + domain;
|
||||||
|
String userId = "WKD-Test Unbound User-ID <" + lookupMail + ">";
|
||||||
|
String description = "Certificate has a single User-ID '" + userId + "' without binding signature.";
|
||||||
|
PGPPublicKeyRing publicKeys = certificate(userId);
|
||||||
|
|
||||||
|
Iterator<PGPPublicKey> keyIterator = publicKeys.iterator();
|
||||||
|
PGPPublicKey primaryKey = keyIterator.next();
|
||||||
|
Iterator<PGPSignature> bindingSigs = primaryKey.getSignaturesForID(userId);
|
||||||
|
while (bindingSigs.hasNext()) {
|
||||||
|
primaryKey = PGPPublicKey.removeCertification(primaryKey, userId, bindingSigs.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<PGPPublicKey> keys = new ArrayList<>();
|
||||||
|
keys.add(primaryKey);
|
||||||
|
while (keyIterator.hasNext()) {
|
||||||
|
keys.add(keyIterator.next());
|
||||||
|
}
|
||||||
|
|
||||||
|
PGPPublicKeyRing certificateWithoutUserIdBinding = new PGPPublicKeyRing(keys);
|
||||||
|
writeDataFor(lookupMail, directoryStructure, new DataSink() {
|
||||||
|
@Override
|
||||||
|
public void write(OutputStream outputStream) throws IOException {
|
||||||
|
certificateWithoutUserIdBinding.encode(outputStream);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return TestCase.fail("Unbound UserId", description, lookupMail, directoryStructure);
|
||||||
|
}
|
||||||
|
|
||||||
private TestCase noUserId(WkdDirectoryStructure directoryStructure) throws Exception {
|
private TestCase noUserId(WkdDirectoryStructure directoryStructure) throws Exception {
|
||||||
String lookupMail = "absent-userid@" + domain;
|
String lookupMail = "absent-userid@" + domain;
|
||||||
String description = "Certificate has no user-id, but is deposited for mail address '" + lookupMail + "'.";
|
String description = "Certificate has no user-id, but is deposited for mail address '" + lookupMail + "'.";
|
||||||
|
|
Loading…
Reference in a new issue