use of org.cloudfoundry.credhub.auth.UserContextHolder in project credhub by cloudfoundry-incubator.
the class CertificateAuthorityServiceTest method beforeEach.
@Before
public void beforeEach() {
certificate = new CertificateCredentialValue(null, CertificateStringConstants.SELF_SIGNED_CA_CERT, "my-key", null);
certificateCredential = mock(CertificateCredentialVersion.class);
permissionCheckingService = mock(PermissionCheckingService.class);
userContext = mock(UserContext.class);
when(userContext.getActor()).thenReturn(USER_NAME);
when(certificateCredential.getName()).thenReturn(CREDENTIAL_NAME);
when(permissionCheckingService.hasPermission(USER_NAME, CREDENTIAL_NAME, PermissionOperation.READ)).thenReturn(true);
certificateVersionDataService = mock(CertificateVersionDataService.class);
UserContextHolder userContextHolder = new UserContextHolder();
userContextHolder.setUserContext(userContext);
certificateAuthorityService = new CertificateAuthorityService(certificateVersionDataService, permissionCheckingService, userContextHolder);
}
use of org.cloudfoundry.credhub.auth.UserContextHolder in project credhub by cloudfoundry-incubator.
the class SetHandlerTest method setUp.
@Before
public void setUp() throws Exception {
TestHelper.getBouncyCastleProvider();
credentialService = mock(PermissionedCredentialService.class);
certificateAuthorityService = mock(CertificateAuthorityService.class);
permissionService = mock(PermissionService.class);
userContext = new UserContext();
UserContextHolder userContextHolder = new UserContextHolder();
userContextHolder.setUserContext(userContext);
subject = new SetHandler(credentialService, permissionService, certificateAuthorityService, userContextHolder);
generationParameters = new StringGenerationParameters();
accessControlEntries = new ArrayList<>();
credentialVersion = mock(PasswordCredentialVersion.class);
when(credentialService.save(anyObject(), anyObject(), anyObject(), anyList())).thenReturn(credentialVersion);
}
Aggregations