Search in sources :

Example 36 with TestKey

use of com.google.gerrit.gpg.testutil.TestKey in project gerrit by GerritCodeReview.

the class PublicKeyStoreTest method get.

@Test
public void get() throws Exception {
    TestKey key1 = validKeyWithoutExpiration();
    tr.branch(REFS_GPG_KEYS).commit().add(keyObjectId(key1.getKeyId()).name(), key1.getPublicKeyArmored()).create();
    TestKey key2 = validKeyWithExpiration();
    tr.branch(REFS_GPG_KEYS).commit().add(keyObjectId(key2.getKeyId()).name(), key2.getPublicKeyArmored()).create();
    assertKeys(key1.getKeyId(), key1);
    assertKeys(key2.getKeyId(), key2);
}
Also used : TestKey(com.google.gerrit.gpg.testutil.TestKey) Test(org.junit.Test)

Example 37 with TestKey

use of com.google.gerrit.gpg.testutil.TestKey in project gerrit by GerritCodeReview.

the class PushCertificateCheckerTest method setUp.

@Before
public void setUp() throws Exception {
    TestKey key1 = validKeyWithoutExpiration();
    TestKey key3 = expiredKey();
    repo = new InMemoryRepository(new DfsRepositoryDescription("repo"));
    store = new PublicKeyStore(repo);
    store.add(key1.getPublicKeyRing());
    store.add(key3.getPublicKeyRing());
    PersonIdent ident = new PersonIdent("A U Thor", "author@example.com");
    CommitBuilder cb = new CommitBuilder();
    cb.setAuthor(ident);
    cb.setCommitter(ident);
    assertEquals(RefUpdate.Result.NEW, store.save(cb));
    signedPushConfig = new SignedPushConfig();
    signedPushConfig.setCertNonceSeed("sekret");
    signedPushConfig.setCertNonceSlopLimit(60 * 24);
    checker = newChecker(true);
}
Also used : TestKey(com.google.gerrit.gpg.testutil.TestKey) InMemoryRepository(org.eclipse.jgit.internal.storage.dfs.InMemoryRepository) SignedPushConfig(org.eclipse.jgit.transport.SignedPushConfig) PersonIdent(org.eclipse.jgit.lib.PersonIdent) CommitBuilder(org.eclipse.jgit.lib.CommitBuilder) DfsRepositoryDescription(org.eclipse.jgit.internal.storage.dfs.DfsRepositoryDescription) Before(org.junit.Before)

Example 38 with TestKey

use of com.google.gerrit.gpg.testutil.TestKey in project gerrit by GerritCodeReview.

the class PublicKeyCheckerTest method revokedKeyDueToNoLongerBeingUsedDoesNotRevokeKeyRetroactively.

@Test
public void revokedKeyDueToNoLongerBeingUsedDoesNotRevokeKeyRetroactively() throws Exception {
    TestKey k = add(revokedNoLongerUsedKey());
    add(validKeyWithoutExpiration());
    save();
    assertProblems(k, "Key is revoked (retired and no longer valid): test7 not used");
    PublicKeyChecker checker = new PublicKeyChecker().setStore(store).setEffectiveTime(parseDate("2010-01-01 12:00:00 -0400"));
    assertNoProblems(checker, k);
}
Also used : TestKey(com.google.gerrit.gpg.testutil.TestKey) Test(org.junit.Test)

Example 39 with TestKey

use of com.google.gerrit.gpg.testutil.TestKey in project gerrit by GerritCodeReview.

the class PublicKeyStoreTest method addThenRemove.

@Test
public void addThenRemove() throws Exception {
    TestKey key1 = validKeyWithoutExpiration();
    store.add(key1.getPublicKeyRing());
    store.remove(key1.getPublicKey().getFingerprint());
    assertEquals(RefUpdate.Result.NO_CHANGE, store.save(newCommitBuilder()));
    assertKeys(key1.getKeyId());
}
Also used : TestKey(com.google.gerrit.gpg.testutil.TestKey) Test(org.junit.Test)

Example 40 with TestKey

use of com.google.gerrit.gpg.testutil.TestKey in project gerrit by GerritCodeReview.

the class PushCertificateCheckerTest method missingKey.

@Test
public void missingKey() throws Exception {
    TestKey key2 = validKeyWithExpiration();
    PushCertificate cert = newSignedCert(validNonce(), key2);
    assertProblems(cert, "No public keys found for key ID " + keyIdToString(key2.getKeyId()));
}
Also used : TestKey(com.google.gerrit.gpg.testutil.TestKey) PushCertificate(org.eclipse.jgit.transport.PushCertificate) Test(org.junit.Test)

Aggregations

TestKey (com.google.gerrit.gpg.testutil.TestKey)40 Test (org.junit.Test)37 PublicKeyStore.keyToString (com.google.gerrit.gpg.PublicKeyStore.keyToString)10 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)7 PGPPublicKeyRing (org.bouncycastle.openpgp.PGPPublicKeyRing)5 PGPPublicKey (org.bouncycastle.openpgp.PGPPublicKey)4 GpgKeyInfo (com.google.gerrit.extensions.common.GpgKeyInfo)3 PushCertificate (org.eclipse.jgit.transport.PushCertificate)3 PublicKeyStore.keyIdToString (com.google.gerrit.gpg.PublicKeyStore.keyIdToString)2 SimpleDateFormat (java.text.SimpleDateFormat)2 RevWalk (org.eclipse.jgit.revwalk.RevWalk)2 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 FluentIterable (com.google.common.collect.FluentIterable)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Iterables (com.google.common.collect.Iterables)1 BaseEncoding (com.google.common.io.BaseEncoding)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 Truth.assert_ (com.google.common.truth.Truth.assert_)1 AtomicLongMap (com.google.common.util.concurrent.AtomicLongMap)1