use of com.venafi.vcert.sdk.endpoint.Authentication in project vcert-java by Venafi.
the class TppTokenConnectorAT method authenticateInvalid.
@Test
@Tag("InvalidAuthentication")
@DisplayName("Authenticate with invalid credentials")
void authenticateInvalid() throws VCertException {
Authentication authentication = Authentication.builder().user("sample").password("password").scope("certificate:manage,revoke,discover").build();
connectorResource.connector().credentials(authentication);
TokenInfo info = connectorResource.connector().getAccessToken();
assertThat(info).isNotNull();
assertThat(info.authorized()).isFalse();
assertThat(info.errorMessage()).isNotNull();
// After setting invalid credentials to TPP, setting variable <info> to null
// will allow for new token to be authorized
// connectorResource.info(null);
}
use of com.venafi.vcert.sdk.endpoint.Authentication in project vcert-java by Venafi.
the class TppTokenConnectorAT method revokeTokenInvalid.
@Test
@Tag("InvalidAuthentication")
void revokeTokenInvalid() throws VCertException {
Authentication invalidCredentials = Authentication.builder().accessToken("abcde==").refreshToken("1234-1234-12345-123").build();
connectorResource.connector().credentials(invalidCredentials);
assertThrows(VCertException.class, () -> connectorResource.connector().revokeAccessToken());
// After setting invalid credentials to TPP, setting variable <info> to null
// will allow for new token to be authorized
// connectorResource.info(null);
}
use of com.venafi.vcert.sdk.endpoint.Authentication in project vcert-java by Venafi.
the class CloudConnectorTest method testExceptionValidatingPolicyCountriesWithNot2Characters.
@Test
@DisplayName("Cloud - Testing Exception in Validation of Policy Countries with not 2 char values")
public void testExceptionValidatingPolicyCountriesWithNot2Characters() throws VCertException {
classUnderTest.authenticate(new Authentication(null, null, "12345678-1234-1234-1234-123456789012"));
PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
// setting the Countries to a list of values which contains a string with more than
// 2 chars to validate that the related VCertException is thrown
policySpecification.policy().subject().countries(new String[] { "US", "Mexico" });
Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(CloudTestUtils.getRandomZone(), policySpecification));
assertEquals(CloudTestUtils.getVCertExceptionMessage(CloudPolicySpecificationValidator.ATTRIBUTE_HAS_NOT_A_TWO_CHAR_STRING_VALUE_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_POLICY_SUBJECT_COUNTRIES), exception.getMessage());
}
use of com.venafi.vcert.sdk.endpoint.Authentication in project vcert-java by Venafi.
the class CloudConnectorTest method testExceptionValidatingDefaultKeySize.
@Test
@DisplayName("Cloud - Testing Exception in Validation of Default KeySize with a not supported value")
public void testExceptionValidatingDefaultKeySize() 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 supported to
// validate that the related VCertException is thrown
policySpecification.defaults().keyPair().rsaKeySize(3072);
Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(CloudTestUtils.getRandomZone(), policySpecification));
assertEquals(CloudTestUtils.getVCertExceptionMessage(CloudPolicySpecificationValidator.DEFAULT_ATTRIBUTE_DOESNT_MATCH_WITH_ACCEPTED_VALUES_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_DEFAULTS_KEYPAIR_RSA_KEY_SIZE), exception.getMessage());
}
use of com.venafi.vcert.sdk.endpoint.Authentication in project vcert-java by Venafi.
the class CloudConnectorTest method testExceptionValidatingSANUriAllowed.
@Test
@DisplayName("Cloud - Testing Exception in Validation of Policy SAN UriAllowed")
public void testExceptionValidatingSANUriAllowed() throws VCertException {
classUnderTest.authenticate(new Authentication(null, null, "12345678-1234-1234-1234-123456789012"));
PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
// setting the uriAllowed to true to validate that the related VCertException is thrown
policySpecification.policy().subjectAltNames().uriAllowed(true);
Exception exception = assertThrows(VCertException.class, () -> classUnderTest.setPolicy(CloudTestUtils.getRandomZone(), policySpecification));
assertEquals(CloudTestUtils.getVCertExceptionMessage(CloudPolicySpecificationValidator.SUBJECT_ALT_NAME_ATTRIBUTE_DOESNT_SUPPORTED_EXCEPTION_MESSAGE, PolicySpecificationConst.ATT_POLICY_SUBJECT_ALT_NAMES_URI_ALLOWED), exception.getMessage());
}
Aggregations