Skip to content

Commit

Permalink
remove varargs for testPermissions and other minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajay Kannan committed Mar 22, 2016
1 parent 3a97ae1 commit 52bf6c1
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class Policy extends IamPolicy<String> {
/**
* The project-level roles in an IAM policy. This enum is not an exhaustive list of all roles
* you can use in an IAM policy. You can also use service-specific roles (e.g.
* <i>roles/pubsub.editor</i>). See the <i>Supported Cloud Platform Services</i> page for links
* "roles/pubsub.editor"). See the <i>Supported Cloud Platform Services</i> page for links
* to service-specific roles.
*
* @see <a href="https://cloud.google.com/iam/#supported_cloud_platform_services">Supported Cloud
Expand All @@ -74,7 +74,7 @@ public enum ProjectRole {
*/
OWNER("roles/owner");

String value;
private final String value;

private ProjectRole(String value) {
this.value = value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,29 +251,6 @@ List<Boolean> testPermissions(List<String> permissions) {
return resourceManager.testPermissions(projectId(), permissions);
}

/**
* Returns the permissions that a caller has on this project. You typically don't call this method
* if you're using Google Cloud Platform directly to manage permissions. This method is intended
* for integration with your proprietary software, such as a customized graphical user interface.
* For example, the Cloud Platform Console tests IAM permissions internally to determine which UI
* should be available to the logged-in user. Each service that supports IAM lists the possible
* permissions; see the <i>Supported Cloud Platform services</i> page below for links to these
* lists.
*
* @return a list of booleans representing whether the caller has the permissions specified (in
* the order of the given permissions)
* @throws ResourceManagerException upon failure
* @see <a href=
* "https://cloud.google.com/resource-manager/reference/rest/v1beta1/projects/testIamPermissions">
* Resource Manager testIamPermissions</a>
* @see <a href=
* "https://cloud.google.com/iam/#supported_cloud_platform_services">Supported Cloud Platform
* Services</a>
*/
List<Boolean> testPermissions(String firstPermission, String... otherPermissions) {
return resourceManager.testPermissions(projectId(), firstPermission, otherPermissions);
}

@Override
public Builder toBuilder() {
return new Builder(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,26 +341,4 @@ public static ProjectListOption fields(ProjectField... fields) {
* Services</a>
*/
List<Boolean> testPermissions(String projectId, List<String> permissions);

/**
* Returns the permissions that a caller has on the specified project. You typically don't call
* this method if you're using Google Cloud Platform directly to manage permissions. This method
* is intended for integration with your proprietary software, such as a customized graphical user
* interface. For example, the Cloud Platform Console tests IAM permissions internally to
* determine which UI should be available to the logged-in user. Each service that supports IAM
* lists the possible permissions; see the <i>Supported Cloud Platform services</i> page below for
* links to these lists.
*
* @return A list of booleans representing whether the caller has the permissions specified (in
* the order of the given permissions)
* @throws ResourceManagerException upon failure
* @see <a href=
* "https://cloud.google.com/resource-manager/reference/rest/v1beta1/projects/testIamPermissions">
* Resource Manager testIamPermissions</a>
* @see <a href=
* "https://cloud.google.com/iam/#supported_cloud_platform_services">Supported Cloud Platform
* Services</a>
*/
List<Boolean> testPermissions(
String projectId, String firstPermission, String... otherPermissions);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.gcloud.BaseService;
import com.google.gcloud.Page;
Expand Down Expand Up @@ -230,12 +229,6 @@ public List<Boolean> call() {
}
}

@Override
public List<Boolean> testPermissions(
String projectId, String firstPermission, String... otherPermissions) {
return testPermissions(projectId, Lists.asList(firstPermission, otherPermissions));
}

private Map<ResourceManagerRpc.Option, ?> optionMap(Option... options) {
Map<ResourceManagerRpc.Option, Object> temp = Maps.newEnumMap(ResourceManagerRpc.Option.class);
for (Option option : options) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,11 @@ public void testTestPermissions() {
String getPermission = "resourcemanager.projects.get";
String deletePermission = "resourcemanager.projects.delete";
expect(resourceManager.options()).andReturn(mockOptions).times(1);
expect(resourceManager.testPermissions(PROJECT_ID, getPermission, deletePermission))
.andReturn(response);
expect(resourceManager.testPermissions(
PROJECT_ID, ImmutableList.of(getPermission, deletePermission)))
.andReturn(response);
replay(resourceManager);
initializeProject();
assertEquals(response, project.testPermissions(getPermission, deletePermission));
assertEquals(
response, project.testPermissions(ImmutableList.of(getPermission, deletePermission)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,6 @@ public void testTestPermissions() {
RESOURCE_MANAGER.create(PARTIAL_PROJECT);
assertEquals(ImmutableList.of(true),
RESOURCE_MANAGER.testPermissions(PARTIAL_PROJECT.projectId(), permissions));
assertEquals(
ImmutableList.of(true, true),
RESOURCE_MANAGER.testPermissions(
PARTIAL_PROJECT.projectId(),
"resourcemanager.projects.delete",
"resourcemanager.projects.get"));
}

@Test
Expand Down

0 comments on commit 52bf6c1

Please sign in to comment.