diff options
author | David Pursehouse <dpursehouse@collab.net> | 2019-02-22 10:10:10 +0900 |
---|---|---|
committer | David Pursehouse <dpursehouse@collab.net> | 2019-02-22 10:10:10 +0900 |
commit | 37e00e62eac3949bed60762804c66ff25e9fc1e5 (patch) | |
tree | e3ef1aac0f982760a3ecaaefc9cced1d66a72b68 | |
parent | 8431054febea9990d38b25df12ae8b2d2c315941 (diff) | |
parent | 5426c4ff1f1a52d650660ab88aa45c46ea0d00fe (diff) |
Merge branch 'stable-2.15' into stable-2.16
* stable-2.15:
AccountIT: Extend assertKeyEquals to check that full key is included
Fix GPG public key export
Change-Id: I68c469722593a53b475144825673cb0e8e9708e7
-rw-r--r-- | java/com/google/gerrit/gpg/server/GpgKeys.java | 15 | ||||
-rw-r--r-- | javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java | 4 |
2 files changed, 11 insertions, 8 deletions
diff --git a/java/com/google/gerrit/gpg/server/GpgKeys.java b/java/com/google/gerrit/gpg/server/GpgKeys.java index 3f090a1091..e555f07554 100644 --- a/java/com/google/gerrit/gpg/server/GpgKeys.java +++ b/java/com/google/gerrit/gpg/server/GpgKeys.java @@ -219,13 +219,14 @@ public class GpgKeys implements ChildCollection<AccountResource, GpgKey> { Iterator<String> userIds = key.getUserIDs(); info.userIds = ImmutableList.copyOf(userIds); - try (ByteArrayOutputStream out = new ByteArrayOutputStream(4096); - ArmoredOutputStream aout = new ArmoredOutputStream(out)) { - // This is not exactly the key stored in the store, but is equivalent. In - // particular, it will have a Bouncy Castle version string. The armored - // stream reader in PublicKeyStore doesn't give us an easy way to extract - // the original ASCII armor. - key.encode(aout); + try (ByteArrayOutputStream out = new ByteArrayOutputStream(4096)) { + try (ArmoredOutputStream aout = new ArmoredOutputStream(out)) { + // This is not exactly the key stored in the store, but is equivalent. In + // particular, it will have a Bouncy Castle version string. The armored + // stream reader in PublicKeyStore doesn't give us an easy way to extract + // the original ASCII armor. + key.encode(aout); + } info.key = new String(out.toByteArray(), UTF_8); } } diff --git a/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java b/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java index 644fb06aa9..83c180956c 100644 --- a/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java +++ b/javatests/com/google/gerrit/acceptance/api/accounts/AccountIT.java @@ -2870,7 +2870,9 @@ public class AccountIT extends AbstractDaemonTest { .isEqualTo(Fingerprint.toString(expected.getPublicKey().getFingerprint())); List<String> userIds = ImmutableList.copyOf(expected.getPublicKey().getUserIDs()); assertThat(actual.userIds).named(id).containsExactlyElementsIn(userIds); - assertThat(actual.key).named(id).startsWith("-----BEGIN PGP PUBLIC KEY BLOCK-----\n"); + String key = actual.key; + assertThat(key).named(id).startsWith("-----BEGIN PGP PUBLIC KEY BLOCK-----\n"); + assertThat(key).named(id).endsWith("-----END PGP PUBLIC KEY BLOCK-----\n"); assertThat(actual.status).isEqualTo(GpgKeyInfo.Status.TRUSTED); assertThat(actual.problems).isEmpty(); } |