use of org.cloudfoundry.credhub.auth.UserContextHolder 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);
}
use of org.cloudfoundry.credhub.auth.UserContextHolder in project credhub by cloudfoundry-incubator.
the class UserContextInterceptorTest method setup.
@Before
public void setup() {
userContextFactory = mock(UserContextFactory.class);
userContext = mock(UserContext.class);
userContextHolder = new UserContextHolder();
subject = new UserContextInterceptor(userContextFactory, userContextHolder);
when(userContextFactory.createUserContext(any())).thenReturn(userContext);
request = mock(HttpServletRequest.class);
}
use of org.cloudfoundry.credhub.auth.UserContextHolder in project credhub by cloudfoundry-incubator.
the class CertificateServiceTest method setup.
@Before
public void setup() {
initMocks(this);
auditRecordParameters = new ArrayList<>();
userContext = mock(UserContext.class);
userContextHolder = new UserContextHolder();
userContextHolder.setUserContext(userContext);
subject = new CertificateService(certificateVersionDataService, permissionCheckingService, userContextHolder);
credentialVersion.createName(credentialName);
when(userContext.getActor()).thenReturn(actor);
when(certificateVersionDataService.findByCredentialUUID(credentialUuid)).thenReturn(credentialVersion);
}
use of org.cloudfoundry.credhub.auth.UserContextHolder 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);
}
use of org.cloudfoundry.credhub.auth.UserContextHolder in project credhub by cloudfoundry-incubator.
the class PermissionedCredentialServiceTest method setUp.
@Before
public void setUp() throws Exception {
initMocks(this);
userContext = mock(UserContext.class);
UserContextHolder userContextHolder = new UserContextHolder();
userContextHolder.setUserContext(userContext);
subject = new PermissionedCredentialService(credentialVersionDataService, credentialFactory, permissionCheckingService, certificateAuthorityService, userContextHolder, credentialDataService);
auditRecordParameters = new ArrayList<>();
generationParameters = mock(StringGenerationParameters.class);
credentialValue = mock(CredentialValue.class);
credential = new Credential(CREDENTIAL_NAME);
accessControlEntries = new ArrayList<>();
when(userContext.getActor()).thenReturn(USER);
existingCredentialVersion = new PasswordCredentialVersion(CREDENTIAL_NAME);
existingCredentialVersion.setEncryptor(encryptor);
when(permissionCheckingService.hasPermission(USER, CREDENTIAL_NAME, READ)).thenReturn(true);
when(permissionCheckingService.hasPermission(USER, CREDENTIAL_NAME, WRITE)).thenReturn(true);
when(credentialDataService.findByUUID(CREDENTIAL_UUID)).thenReturn(credential);
when(credentialVersionDataService.findByUuid(VERSION_UUID_STRING)).thenReturn(existingCredentialVersion);
when(request.getName()).thenReturn(CREDENTIAL_NAME);
when(request.getGenerationParameters()).thenReturn(generationParameters);
when(request.getAdditionalPermissions()).thenReturn(accessControlEntries);
}
Aggregations