Search in sources :

Example 1 with PermissionsRequest

use of org.cloudfoundry.credhub.request.PermissionsRequest in project credhub by cloudfoundry-incubator.

the class PermissionsControllerTest method POST_returnsASuccessfulEmptyResponse.

@Test
public void POST_returnsASuccessfulEmptyResponse() throws Exception {
    grantPermissions(mockMvc, "test-credential-name", UAA_OAUTH2_PASSWORD_GRANT_TOKEN, "test-actor", "read", "write");
    ArgumentCaptor<PermissionsRequest> captor = ArgumentCaptor.forClass(PermissionsRequest.class);
    verify(permissionsHandler, times(1)).setPermissions(captor.capture(), any(List.class));
    PermissionsRequest permissionsRequest = captor.getValue();
    List<PermissionEntry> accessControlEntries = permissionsRequest.getPermissions();
    assertThat(accessControlEntries, hasItem(allOf(hasProperty("actor", equalTo("test-actor")), hasProperty("allowedOperations", hasItems(PermissionOperation.READ, PermissionOperation.WRITE)))));
}
Also used : PermissionsRequest(org.cloudfoundry.credhub.request.PermissionsRequest) PermissionEntry(org.cloudfoundry.credhub.request.PermissionEntry) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Test(org.junit.Test)

Aggregations

Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 List (java.util.List)1 PermissionEntry (org.cloudfoundry.credhub.request.PermissionEntry)1 PermissionsRequest (org.cloudfoundry.credhub.request.PermissionsRequest)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1