use of com.google.gerrit.gpg.testutil.TestKey in project gerrit by GerritCodeReview.
the class AccountIT method listGpgKeys.
@Test
public void listGpgKeys() throws Exception {
List<TestKey> keys = allValidKeys();
List<String> toAdd = new ArrayList<>(keys.size());
for (TestKey key : keys) {
addExternalIdEmail(admin, PushCertificateIdent.parse(key.getFirstUserId()).getEmailAddress());
toAdd.add(key.getPublicKeyArmored());
}
gApi.accounts().self().putGpgKeys(toAdd, ImmutableList.<String>of());
assertKeys(keys);
accountIndexedCounter.assertReindexOf(admin);
}
use of com.google.gerrit.gpg.testutil.TestKey in project gerrit by GerritCodeReview.
the class GerritPublicKeyCheckerTest method checkTrustChainWithExpiredKey.
@Test
public void checkTrustChainWithExpiredKey() throws Exception {
// A---Bx
//
// The server ultimately trusts B.
TestKey keyA = add(keyA(), user);
TestKey keyB = add(keyB(), addUser("userB"));
PublicKeyChecker checker = checkerFactory.create(user, store);
assertProblems(checker.check(keyA.getPublicKey()), Status.OK, "No path to a trusted key", "Certification by " + keyToString(keyB.getPublicKey()) + " is valid, but key is not trusted", "Key D24FE467 used for certification is not in store");
}
use of com.google.gerrit.gpg.testutil.TestKey in project gerrit by GerritCodeReview.
the class GerritPublicKeyCheckerTest method noExternalIds.
@Test
public void noExternalIds() throws Exception {
ExternalIdsUpdate externalIdsUpdate = externalIdsUpdateFactory.create();
externalIdsUpdate.deleteAll(user.getAccountId());
reloadUser();
TestKey key = validKeyWithSecondUserId();
PublicKeyChecker checker = checkerFactory.create(user, store).disableTrust();
assertProblems(checker.check(key.getPublicKey()), Status.BAD, "No identities found for user; check http://test/#/settings/web-identities");
checker = checkerFactory.create().setStore(store).disableTrust();
assertProblems(checker.check(key.getPublicKey()), Status.BAD, "Key is not associated with any users");
externalIdsUpdate.insert(ExternalId.create(toExtIdKey(key.getPublicKey()), user.getAccountId()));
reloadUser();
assertProblems(checker.check(key.getPublicKey()), Status.BAD, "No identities found for user");
}
use of com.google.gerrit.gpg.testutil.TestKey in project gerrit by GerritCodeReview.
the class GerritPublicKeyCheckerTest method checkWithValidKeyButWrongExpectedUserInChecker.
@Test
public void checkWithValidKeyButWrongExpectedUserInChecker() throws Exception {
// A---Bx
// \
// \---C---D
// \
// \---Ex
//
// The server ultimately trusts B and D.
// D and E trust C to be a valid introducer of depth 2.
IdentifiedUser userB = addUser("userB");
TestKey keyA = add(keyA(), user);
TestKey keyB = add(keyB(), userB);
add(keyC(), addUser("userC"));
add(keyD(), addUser("userD"));
add(keyE(), addUser("userE"));
// Checker for A, checking B.
PublicKeyChecker checkerA = checkerFactory.create(user, store);
assertProblems(checkerA.check(keyB.getPublicKey()), Status.BAD, "Key is expired", "Key must contain a valid certification for one of the following" + " identities:\n" + " gerrit:user\n" + " mailto:testa@example.com\n" + " testa@example.com\n" + " username:user");
// Checker for B, checking A.
PublicKeyChecker checkerB = checkerFactory.create(userB, store);
assertProblems(checkerB.check(keyA.getPublicKey()), Status.BAD, "Key must contain a valid certification for one of the following" + " identities:\n" + " gerrit:userB\n" + " mailto:testb@example.com\n" + " testb@example.com\n" + " username:userB");
}
use of com.google.gerrit.gpg.testutil.TestKey in project gerrit by GerritCodeReview.
the class GerritPublicKeyCheckerTest method checkTrustChainUsingCheckerWithoutExpectedKey.
@Test
public void checkTrustChainUsingCheckerWithoutExpectedKey() throws Exception {
// A---Bx
// \
// \---C---D
// \
// \---Ex
//
// The server ultimately trusts B and D.
// D and E trust C to be a valid introducer of depth 2.
TestKey keyA = add(keyA(), user);
TestKey keyB = add(keyB(), addUser("userB"));
TestKey keyC = add(keyC(), addUser("userC"));
TestKey keyD = add(keyD(), addUser("userD"));
TestKey keyE = add(keyE(), addUser("userE"));
// This checker can check any key, so the only problems come from issues
// with the keys themselves, not having invalid user IDs.
PublicKeyChecker checker = checkerFactory.create().setStore(store);
assertNoProblems(checker.check(keyA.getPublicKey()));
assertProblems(checker.check(keyB.getPublicKey()), Status.BAD, "Key is expired");
assertNoProblems(checker.check(keyC.getPublicKey()));
assertNoProblems(checker.check(keyD.getPublicKey()));
assertProblems(checker.check(keyE.getPublicKey()), Status.BAD, "Key is expired", "No path to a trusted key");
}
Aggregations