Merge branch 'stable-2.14' into stable-2.15
* stable-2.14: PostGpgKeys: Gracefully handle malformed GPG keys input Change-Id: I72f639ada2db19dd7c33f98954088d4c0836c36c
This commit is contained in:
commit
2049f12280
@ -1596,6 +1596,14 @@ public class AccountIT extends AbstractDaemonTest {
|
|||||||
ImmutableList.of(key2.getKeyIdString()));
|
ImmutableList.of(key2.getKeyIdString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addMalformedGpgKey() throws Exception {
|
||||||
|
String key = "-----BEGIN PGP PUBLIC KEY BLOCK-----\n\ntest\n-----END PGP PUBLIC KEY BLOCK-----";
|
||||||
|
exception.expect(BadRequestException.class);
|
||||||
|
exception.expectMessage("Failed to parse GPG keys");
|
||||||
|
addGpgKey(key);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@UseSsh
|
@UseSsh
|
||||||
public void sshKeys() throws Exception {
|
public void sshKeys() throws Exception {
|
||||||
|
@ -66,6 +66,7 @@ import org.bouncycastle.bcpg.ArmoredInputStream;
|
|||||||
import org.bouncycastle.openpgp.PGPException;
|
import org.bouncycastle.openpgp.PGPException;
|
||||||
import org.bouncycastle.openpgp.PGPPublicKey;
|
import org.bouncycastle.openpgp.PGPPublicKey;
|
||||||
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
import org.bouncycastle.openpgp.PGPPublicKeyRing;
|
||||||
|
import org.bouncycastle.openpgp.PGPRuntimeOperationException;
|
||||||
import org.bouncycastle.openpgp.bc.BcPGPObjectFactory;
|
import org.bouncycastle.openpgp.bc.BcPGPObjectFactory;
|
||||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||||
import org.eclipse.jgit.lib.CommitBuilder;
|
import org.eclipse.jgit.lib.CommitBuilder;
|
||||||
@ -183,6 +184,8 @@ public class PostGpgKeys implements RestModifyView<AccountResource, Input> {
|
|||||||
"Cannot both add and delete key: " + keyToString(keyRing.getPublicKey()));
|
"Cannot both add and delete key: " + keyToString(keyRing.getPublicKey()));
|
||||||
}
|
}
|
||||||
keyRings.add(keyRing);
|
keyRings.add(keyRing);
|
||||||
|
} catch (PGPRuntimeOperationException e) {
|
||||||
|
throw new BadRequestException("Failed to parse GPG keys", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return keyRings;
|
return keyRings;
|
||||||
|
Loading…
Reference in New Issue
Block a user