use of org.cloudfoundry.credhub.data.CertificateAuthorityService 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.data.CertificateAuthorityService 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