mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-09-08 17:59:43 +02:00
CertifyValidateUserIdTest: unbound User-IDs do throw exceptions
This commit is contained in:
parent
61206dde53
commit
e1d048225b
1 changed files with 25 additions and 24 deletions
|
@ -14,7 +14,6 @@ import sop.exception.SOPGPException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
@ -47,16 +46,17 @@ public class CertifyValidateUserIdTest {
|
||||||
|
|
||||||
// Alice has her own user-id self-certified
|
// Alice has her own user-id self-certified
|
||||||
assertTrue(sop.validateUserId()
|
assertTrue(sop.validateUserId()
|
||||||
.authorities(aliceCert)
|
.authorities(aliceCert)
|
||||||
.userId("Alice <alice@pgpainless.org>")
|
.userId("Alice <alice@pgpainless.org>")
|
||||||
.subjects(aliceCert),
|
.subjects(aliceCert),
|
||||||
"Alice accepts her own self-certified user-id");
|
"Alice accepts her own self-certified user-id");
|
||||||
|
|
||||||
// Alice has not yet certified Bobs user-id
|
// Alice has not yet certified Bobs user-id
|
||||||
assertFalse(sop.validateUserId()
|
assertThrows(SOPGPException.CertUserIdNoMatch.class, () ->
|
||||||
.authorities(aliceCert)
|
sop.validateUserId()
|
||||||
.userId("Bob <bob@pgpainless.org>")
|
.authorities(aliceCert)
|
||||||
.subjects(bobCert),
|
.userId("Bob <bob@pgpainless.org>")
|
||||||
|
.subjects(bobCert),
|
||||||
"Alice has not yet certified Bobs user-id");
|
"Alice has not yet certified Bobs user-id");
|
||||||
|
|
||||||
byte[] bobCertifiedByAlice = sop.certifyUserId()
|
byte[] bobCertifiedByAlice = sop.certifyUserId()
|
||||||
|
@ -67,10 +67,10 @@ public class CertifyValidateUserIdTest {
|
||||||
.getBytes();
|
.getBytes();
|
||||||
|
|
||||||
assertTrue(sop.validateUserId()
|
assertTrue(sop.validateUserId()
|
||||||
.userId("Bob <bob@pgpainless.org>")
|
.userId("Bob <bob@pgpainless.org>")
|
||||||
.authorities(aliceCert)
|
.authorities(aliceCert)
|
||||||
.subjects(bobCertifiedByAlice),
|
.subjects(bobCertifiedByAlice),
|
||||||
"Alice accepts Bobs user-id after she certified it");
|
"Alice accepts Bobs user-id after she certified it");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
|
@ -132,11 +132,11 @@ public class CertifyValidateUserIdTest {
|
||||||
.getBytes();
|
.getBytes();
|
||||||
|
|
||||||
assertThrows(SOPGPException.CertUserIdNoMatch.class, () ->
|
assertThrows(SOPGPException.CertUserIdNoMatch.class, () ->
|
||||||
sop.certifyUserId()
|
sop.certifyUserId()
|
||||||
.userId("Bobby")
|
.userId("Bobby")
|
||||||
.keys(aliceKey)
|
.keys(aliceKey)
|
||||||
.certs(bobCert)
|
.certs(bobCert)
|
||||||
.getBytes(),
|
.getBytes(),
|
||||||
"Alice cannot create a pet-name for Bob without the --no-require-self-sig flag");
|
"Alice cannot create a pet-name for Bob without the --no-require-self-sig flag");
|
||||||
|
|
||||||
byte[] bobWithPetName = sop.certifyUserId()
|
byte[] bobWithPetName = sop.certifyUserId()
|
||||||
|
@ -147,15 +147,16 @@ public class CertifyValidateUserIdTest {
|
||||||
.getBytes();
|
.getBytes();
|
||||||
|
|
||||||
assertTrue(sop.validateUserId()
|
assertTrue(sop.validateUserId()
|
||||||
.userId("Bobby")
|
.userId("Bobby")
|
||||||
.authorities(aliceCert)
|
.authorities(aliceCert)
|
||||||
.subjects(bobWithPetName),
|
.subjects(bobWithPetName),
|
||||||
"Alice accepts the pet-name she gave to Bob");
|
"Alice accepts the pet-name she gave to Bob");
|
||||||
|
|
||||||
assertFalse(sop.validateUserId()
|
assertThrows(SOPGPException.CertUserIdNoMatch.class, () ->
|
||||||
.userId("Bobby")
|
sop.validateUserId()
|
||||||
.authorities(bobWithPetName)
|
.userId("Bobby")
|
||||||
.subjects(bobWithPetName),
|
.authorities(bobWithPetName)
|
||||||
|
.subjects(bobWithPetName),
|
||||||
"Bob does not accept the pet-name Alice gave him");
|
"Bob does not accept the pet-name Alice gave him");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue