diff options
author | David Pursehouse <dpursehouse@collab.net> | 2019-02-22 00:43:54 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2019-02-22 00:43:54 +0000 |
commit | 5426c4ff1f1a52d650660ab88aa45c46ea0d00fe (patch) | |
tree | 4e1602812058029ca40a70ba94624e9376fa0414 | |
parent | 49edfc2d50318f290336dd4237e8338c63ddeb12 (diff) | |
parent | 0685471336d54218e1e9c7872a7b62280cb54500 (diff) |
Merge changes from topic "issue-10488" into stable-2.15
* changes:
AccountIT: Extend assertKeyEquals to check that full key is included
Fix GPG public key export
-rw-r--r-- | gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/accounts/AccountIT.java | 4 | ||||
-rw-r--r-- | gerrit-gpg/src/main/java/com/google/gerrit/gpg/server/GpgKeys.java | 15 |
2 files changed, 11 insertions, 8 deletions
diff --git a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/accounts/AccountIT.java b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/accounts/AccountIT.java index aa702df111..47ed515e38 100644 --- a/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/accounts/AccountIT.java +++ b/gerrit-acceptance-tests/src/test/java/com/google/gerrit/acceptance/api/accounts/AccountIT.java @@ -1967,7 +1967,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(); } diff --git a/gerrit-gpg/src/main/java/com/google/gerrit/gpg/server/GpgKeys.java b/gerrit-gpg/src/main/java/com/google/gerrit/gpg/server/GpgKeys.java index ecff7e6a3c..6dd3c7ec3a 100644 --- a/gerrit-gpg/src/main/java/com/google/gerrit/gpg/server/GpgKeys.java +++ b/gerrit-gpg/src/main/java/com/google/gerrit/gpg/server/GpgKeys.java @@ -222,13 +222,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); } } |