use of com.google.gerrit.gpg.testing.TestKey in project gerrit by GerritCodeReview.
the class PublicKeyCheckerTest method trustInsufficientDepthInSignature.
@Test
public void trustInsufficientDepthInSignature() throws Exception {
// H---I---J, but J is only trusted to length 1.
TestKey kh = add(keyH());
TestKey ki = add(keyI());
add(keyJ());
save();
PublicKeyChecker checker = newChecker(10, keyJ());
// J trusts I to a depth of 1, so I itself is valid, but I's certification
// of K is not valid.
assertNoProblems(checker, ki);
assertProblems(checker, kh, "No path to a trusted key", notTrusted(ki));
}
use of com.google.gerrit.gpg.testing.TestKey in project gerrit by GerritCodeReview.
the class PublicKeyCheckerTest method revokedKeyDueToCompromiseRevokesKeyRetroactively.
@Test
public void revokedKeyDueToCompromiseRevokesKeyRetroactively() throws Exception {
TestKey k = add(revokedCompromisedKey());
add(validKeyWithoutExpiration());
save();
String problem = "Key is revoked (key material has been compromised): test6 compromised";
assertProblems(k, problem);
Instant instant = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").withZone(ZoneId.systemDefault()).parse("2010-01-01 12:00:00", Instant::from);
PublicKeyChecker checker = new PublicKeyChecker().setStore(store).setEffectiveTime(instant);
assertProblems(checker, k, problem);
}
use of com.google.gerrit.gpg.testing.TestKey in project gerrit by GerritCodeReview.
the class PushCertificateCheckerTest method invalidKey.
@Test
public void invalidKey() throws Exception {
TestKey key3 = expiredKey();
PushCertificate cert = newSignedCert(validNonce(), key3);
assertProblems(cert, "Invalid public key " + keyToString(key3.getPublicKey()) + ":\n Key is expired");
}
use of com.google.gerrit.gpg.testing.TestKey in project gerrit by GerritCodeReview.
the class PushCertificateCheckerTest method signatureByExpiredKeyBeforeExpiration.
@Test
public void signatureByExpiredKeyBeforeExpiration() throws Exception {
TestKey key3 = expiredKey();
Date now = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").parse("2005-07-10 12:00:00 -0400");
PushCertificate cert = newSignedCert(validNonce(), key3, now);
assertNoProblems(cert);
}
use of com.google.gerrit.gpg.testing.TestKey in project gerrit by GerritCodeReview.
the class AccountIT method addGpgKey.
@Test
public void addGpgKey() throws Exception {
TestKey key = validKeyWithoutExpiration();
String id = key.getKeyIdString();
addExternalIdEmail(admin, "test1@example.com");
sender.clear();
assertKeyMapContains(key, addGpgKey(key.getPublicKeyArmored()));
assertKeys(key);
assertThat(sender.getMessages()).hasSize(1);
assertThat(sender.getMessages().get(0).body()).contains("new GPG keys have been added");
requestScopeOperations.setApiUser(user.id());
ResourceNotFoundException thrown = assertThrows(ResourceNotFoundException.class, () -> gApi.accounts().self().gpgKey(id).get());
assertThat(thrown).hasMessageThat().contains(id);
}
Aggregations