use of org.cloudfoundry.credhub.service.PermissionCheckingService in project credhub by cloudfoundry-incubator.
the class CredentialsHandlerTest method beforeEach.
@Before
public void beforeEach() {
Encryptor encryptor = mock(Encryptor.class);
permissionedCredentialService = mock(PermissionedCredentialService.class);
permissionCheckingService = mock(PermissionCheckingService.class);
subject = new CredentialsHandler(permissionedCredentialService);
userContext = mock(UserContext.class);
when(userContext.getActor()).thenReturn(USER);
version1 = new SshCredentialVersion(CREDENTIAL_NAME);
version1.setVersionCreatedAt(VERSION1_CREATED_AT);
version1.setEncryptor(encryptor);
version2 = new SshCredentialVersion(CREDENTIAL_NAME);
version2.setVersionCreatedAt(VERSION2_CREATED_AT);
version2.setEncryptor(encryptor);
}
use of org.cloudfoundry.credhub.service.PermissionCheckingService in project credhub by cloudfoundry-incubator.
the class CertificateGeneratorTest method beforeEach.
@Before
public void beforeEach() throws Exception {
TestHelper.getBouncyCastleProvider();
keyGenerator = mock(LibcryptoRsaKeyPairGenerator.class);
signedCertificateGenerator = mock(SignedCertificateGenerator.class);
certificateAuthorityService = mock(CertificateAuthorityService.class);
permissionCheckingService = mock(PermissionCheckingService.class);
userContext = mock(UserContext.class);
subject = new CertificateGenerator(keyGenerator, signedCertificateGenerator, certificateAuthorityService);
when(permissionCheckingService.hasPermission(anyString(), anyString(), any())).thenReturn(true);
fakeKeyPairGenerator = new FakeKeyPairGenerator();
rootCaDn = new X500Name("O=foo,ST=bar,C=root");
signeeDn = new X500Name("O=foo,ST=bar,C=mars");
rootCaKeyPair = fakeKeyPairGenerator.generate();
X509CertificateHolder caX509CertHolder = makeCert(rootCaKeyPair, rootCaKeyPair.getPrivate(), rootCaDn, rootCaDn, true);
rootCaX509Certificate = new JcaX509CertificateConverter().setProvider(BouncyCastleProvider.PROVIDER_NAME).getCertificate(caX509CertHolder);
rootCa = new CertificateCredentialValue(null, CertificateFormatter.pemOf(rootCaX509Certificate), CertificateFormatter.pemOf(rootCaKeyPair.getPrivate()), null);
generationParameters = new CertificateGenerationRequestParameters();
generationParameters.setOrganization("foo");
generationParameters.setState("bar");
generationParameters.setCaName("my-ca-name");
generationParameters.setCountry("mars");
generationParameters.setDuration(365);
inputParameters = new CertificateGenerationParameters(generationParameters);
}
use of org.cloudfoundry.credhub.service.PermissionCheckingService 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.service.PermissionCheckingService in project credhub by cloudfoundry-incubator.
the class CertificatesHandlerTest method beforeEach.
@Before
public void beforeEach() {
Encryptor encryptor = mock(Encryptor.class);
permissionedCertificateService = mock(PermissionedCertificateService.class);
permissionCheckingService = mock(PermissionCheckingService.class);
certificateService = mock(CertificateService.class);
universalCredentialGenerator = mock(UniversalCredentialGenerator.class);
generationRequestGenerator = mock(GenerationRequestGenerator.class);
subject = new CertificatesHandler(permissionedCertificateService, certificateService, universalCredentialGenerator, generationRequestGenerator);
userContext = mock(UserContext.class);
when(userContext.getActor()).thenReturn(USER);
}
Aggregations