use of com.google.gerrit.gpg.testutil.TestKey in project gerrit by GerritCodeReview.
the class PublicKeyStoreTest method removeNonexisting.
@Test
public void removeNonexisting() throws Exception {
TestKey key1 = validKeyWithoutExpiration();
store.add(key1.getPublicKeyRing());
assertEquals(RefUpdate.Result.NEW, store.save(newCommitBuilder()));
TestKey key2 = validKeyWithExpiration();
store.remove(key2.getPublicKey().getFingerprint());
assertEquals(RefUpdate.Result.NO_CHANGE, store.save(newCommitBuilder()));
assertKeys(key1.getKeyId(), key1);
}
use of com.google.gerrit.gpg.testutil.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.testutil.TestKey in project gerrit by GerritCodeReview.
the class PublicKeyCheckerTest method trustCycle.
@Test
public void trustCycle() throws Exception {
// F---G---F, in a cycle.
TestKey kf = add(keyF());
TestKey kg = add(keyG());
save();
PublicKeyChecker checker = newChecker(10, keyA());
assertProblems(checker, kf, "No path to a trusted key", notTrusted(kg));
assertProblems(checker, kg, "No path to a trusted key", notTrusted(kf));
}
use of com.google.gerrit.gpg.testutil.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);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
PublicKeyChecker checker = new PublicKeyChecker().setStore(store).setEffectiveTime(df.parse("2010-01-01 12:00:00"));
assertProblems(checker, k, problem);
}
use of com.google.gerrit.gpg.testutil.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));
}
Aggregations