use of com.venafi.vcert.sdk.endpoint.Authentication in project vcert-java by Venafi.
the class CloudConnectorTest method testExceptionValidatingDefaultKeySizeDoesntMatchWithPolicyKeySizes.
@Test
@DisplayName("Cloud - Testing Exception in Validation of Default KeySize with a value not matching with the Policy KeySizes")
public void testExceptionValidatingDefaultKeySizeDoesntMatchWithPolicyKeySizes() throws VCertException {
classUnderTest.authenticate(new Authentication(null, null, "12345678-1234-1234-1234-123456789012"));
PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
// setting the default keysize to a value which is not matching with
// the Policy KeySizes to validate that the related VCertException is thrown
policySpecification.defaults().keyPair().rsaKeySize(4096);
Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(CloudTestUtils.getRandomZone(), policySpecification));
assertEquals(CloudTestUtils.getVCertExceptionMessage(CloudPolicySpecificationValidator.DEFAULT_ATTRIBUTE_DOESNT_MATCH_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_DEFAULTS_KEYPAIR_RSA_KEY_SIZE, PolicySpecificationConst.ATT_POLICY_KEYPAIR_RSA_KEY_SIZES), exception.getMessage());
}
use of com.venafi.vcert.sdk.endpoint.Authentication in project vcert-java by Venafi.
the class CloudConnectorTest method testExceptionValidatingPolicyLocalitiesWhenWildcards.
@Test
@DisplayName("Cloud - Testing Exception in Validation of Policy Localities with wildcard value")
public void testExceptionValidatingPolicyLocalitiesWhenWildcards() throws VCertException {
classUnderTest.authenticate(new Authentication(null, null, "12345678-1234-1234-1234-123456789012"));
PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
// setting the Localities to a list of values which contains ".*" to validate that the related VCertException is thrown
policySpecification.policy().subject().localities(new String[] { PolicySpecificationConst.ALLOW_ALL, "Merida" });
Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(CloudTestUtils.getRandomZone(), policySpecification));
assertEquals(CloudTestUtils.getVCertExceptionMessage(CloudPolicySpecificationValidator.ATTRIBUTE_HAS_MORE_THAN_ONE_VALUE_CONTAINING_ALLOW_ALL_STRING_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_POLICY_SUBJECT_LOCALITIES), exception.getMessage());
}
use of com.venafi.vcert.sdk.endpoint.Authentication in project vcert-java by Venafi.
the class VCertClientTest method authenticate.
@Test
@DisplayName("Authenticated with venafi endpoint with server error")
void authenticate() throws VCertException {
final Authentication auth = mock(Authentication.class);
classUnderTest.authenticate(auth);
verify(connector).authenticate(auth);
}
use of com.venafi.vcert.sdk.endpoint.Authentication in project vcert-java by Venafi.
the class VCertClientTest method authenticateWithException.
@Test
@DisplayName("Authenticated with venafi endpoint")
void authenticateWithException() throws VCertException {
final Authentication auth = mock(Authentication.class);
doThrow(new FeignException.InternalServerError("Error", request, "".getBytes())).when(connector).authenticate(auth);
assertThrows(VCertException.class, () -> classUnderTest.authenticate(auth));
}
use of com.venafi.vcert.sdk.endpoint.Authentication in project vcert-java by Venafi.
the class TppTokenConnectorIT method setup.
@BeforeEach
void setup() throws VCertException {
serverMock.start();
classUnderTest = new TppTokenConnector(Tpp.connect("http://localhost:" + serverMock.port() + "/"));
// String.format()
Authentication auth = Authentication.builder().user("user").password("pass").build();
classUnderTest.credentials(auth);
info = classUnderTest.getAccessToken();
}
Aggregations