Search in sources :

Example 1 with PermissionDataService

use of org.cloudfoundry.credhub.data.PermissionDataService in project credhub by cloudfoundry-incubator.

the class PermissionCheckingServiceTest method beforeEach.

@Before
public void beforeEach() {
    userContext = mock(UserContext.class);
    when(userContext.getActor()).thenReturn("test-actor");
    permissionDataService = mock(PermissionDataService.class);
    UserContextHolder userContextHolder = new UserContextHolder();
    userContextHolder.setUserContext(userContext);
    subject = new PermissionCheckingService(permissionDataService, userContextHolder);
}
Also used : UserContext(org.cloudfoundry.credhub.auth.UserContext) UserContextHolder(org.cloudfoundry.credhub.auth.UserContextHolder) PermissionDataService(org.cloudfoundry.credhub.data.PermissionDataService) Before(org.junit.Before)

Example 2 with PermissionDataService

use of org.cloudfoundry.credhub.data.PermissionDataService in project credhub by cloudfoundry-incubator.

the class PermissionServiceTest method beforeEach.

@Before
public void beforeEach() {
    userContext = mock(UserContext.class);
    when(userContext.getActor()).thenReturn(USER_NAME);
    expectedCredential = new Credential(CREDENTIAL_NAME);
    expectedCredentialVersion = new PasswordCredentialVersion(CREDENTIAL_NAME);
    permissionDataService = mock(PermissionDataService.class);
    permissionCheckingService = mock(PermissionCheckingService.class);
    when(permissionCheckingService.hasPermission(anyString(), anyString(), any(PermissionOperation.class))).thenReturn(true);
    auditRecordParameters = newArrayList();
    UserContextHolder userContextHolder = new UserContextHolder();
    userContextHolder.setUserContext(userContext);
    subject = new PermissionService(permissionDataService, permissionCheckingService, userContextHolder);
}
Also used : Credential(org.cloudfoundry.credhub.entity.Credential) PermissionOperation(org.cloudfoundry.credhub.request.PermissionOperation) UserContext(org.cloudfoundry.credhub.auth.UserContext) UserContextHolder(org.cloudfoundry.credhub.auth.UserContextHolder) PermissionDataService(org.cloudfoundry.credhub.data.PermissionDataService) PasswordCredentialVersion(org.cloudfoundry.credhub.domain.PasswordCredentialVersion) Before(org.junit.Before)

Aggregations

UserContext (org.cloudfoundry.credhub.auth.UserContext)2 UserContextHolder (org.cloudfoundry.credhub.auth.UserContextHolder)2 PermissionDataService (org.cloudfoundry.credhub.data.PermissionDataService)2 Before (org.junit.Before)2 PasswordCredentialVersion (org.cloudfoundry.credhub.domain.PasswordCredentialVersion)1 Credential (org.cloudfoundry.credhub.entity.Credential)1 PermissionOperation (org.cloudfoundry.credhub.request.PermissionOperation)1