ChangeJson: Ignore PUSH_CERTIFICATES if GPG API is disabled

GpgApiAdapter throws an exception if the GPG API is disabled. The
client respects whether the server advertises signed push is enabled
when deciding whether to send the PUSH_CERTIFICATES option, but we
can't assume all clients will be so well behaved.

Recently in I04ddc340 we started passing this option when generating
events, causing breakage when processing a patch set with a push
certificate but the GPG API is disabled.

Change-Id: I53981d521f67906def7e8d3018f87816d5e43ab9
This commit is contained in:
Dave Borowitz
2016-08-12 17:24:44 -04:00
committed by Jonathan Nieder
parent 2dd29b7452
commit d373a09673
5 changed files with 19 additions and 1 deletions

View File

@@ -56,6 +56,11 @@ public class GpgApiAdapterImpl implements GpgApiAdapter {
this.pushCertCheckerFactory = pushCertCheckerFactory;
}
@Override
public boolean isEnabled() {
return true;
}
@Override
public Map<String, GpgKeyInfo> listGpgKeys(AccountResource account)
throws RestApiException, GpgException {

View File

@@ -61,6 +61,11 @@ public class GpgApiModule extends RestApiModule {
private static class NoGpgApi implements GpgApiAdapter {
private static final String MSG = "GPG key APIs disabled";
@Override
public boolean isEnabled() {
return false;
}
@Override
public Map<String, GpgKeyInfo> listGpgKeys(AccountResource account) {
throw new NotImplementedException(MSG);