Add /config/check.access endpoint

The check.access endpoint is for administrative users. It can be
supplied with a (project, account) or (project, account, ref) tuple to
check that ACLs are behaving as expected.

Change-Id: Icf74b0fc4036312eef9f222aaff8e1769a051eec
This commit is contained in:
Han-Wen Nienhuys
2017-04-25 17:41:58 +02:00
parent 5646393ac7
commit e04df7e589
8 changed files with 433 additions and 1 deletions

View File

@@ -0,0 +1,27 @@
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.extensions.api.config;
public class AccessCheckInfo {
public static class Result {
public String message;
// HTTP status code.
public int status;
}
public Result result;
// for future extension, we may add inputs / results for bulk checks.
}

View File

@@ -0,0 +1,33 @@
// Copyright (C) 2017 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.extensions.api.config;
import com.google.gerrit.common.Nullable;
public class AccessCheckInput {
public String account;
public String project;
@Nullable public String ref;
public AccessCheckInput(String account, String project, @Nullable String ref) {
this.account = account;
this.project = project;
this.ref = ref;
}
public AccessCheckInput() {
}
}

View File

@@ -36,6 +36,8 @@ public interface Server {
ConsistencyCheckInfo checkConsistency(ConsistencyCheckInput in) throws RestApiException;
AccessCheckInfo checkAccess(AccessCheckInput in) throws RestApiException;
/**
* A default implementation which allows source compatibility when adding new methods to the
* interface.
@@ -75,5 +77,10 @@ public interface Server {
public ConsistencyCheckInfo checkConsistency(ConsistencyCheckInput in) {
throw new NotImplementedException();
}
@Override
public AccessCheckInfo checkAccess(AccessCheckInput in) throws RestApiException {
throw new NotImplementedException();
}
}
}