use of com.venafi.vcert.sdk.endpoint.Authentication in project vcert-java by Venafi.
the class CloudConnectorTest method testExceptionValidatingPolicyOrgsWhenWildcards.
@Test
@DisplayName("Cloud - Testing Exception in Validation of Policy Orgs with wildcard value")
public void testExceptionValidatingPolicyOrgsWhenWildcards() throws VCertException {
classUnderTest.authenticate(new Authentication(null, null, "12345678-1234-1234-1234-123456789012"));
PolicySpecification policySpecification = CloudTestUtils.getPolicySpecification();
// setting the orgs to a list of values which contains ".*" to validate that the related VCertException is thrown
policySpecification.policy().subject().orgs(new String[] { PolicySpecificationConst.ALLOW_ALL, "org1" });
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_ORGS), exception.getMessage());
}
use of com.venafi.vcert.sdk.endpoint.Authentication in project vcert-java by Venafi.
the class TppConnectorATForSSH method authenticate.
@BeforeEach
void authenticate(TestInfo testInfo) throws VCertException {
if (testInfo.getTags() != null && !testInfo.getTags().contains("AuthenticationUnneeded")) {
Security.addProvider(new BouncyCastleProvider());
Authentication authentication = new Authentication().user(TestUtils.TPP_USER).password(TestUtils.TPP_PASSWORD).scope("ssh:manage");
classUnderTest.authenticate(authentication);
}
}
use of com.venafi.vcert.sdk.endpoint.Authentication in project vcert-java by Venafi.
the class VCertTknClientTest 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).getAccessToken(auth);
assertThrows(VCertException.class, () -> classUnderTest.getAccessToken(auth));
}
use of com.venafi.vcert.sdk.endpoint.Authentication in project vcert-java by Venafi.
the class VCertTknClientTest method authenticate.
@Test
@DisplayName("Authenticated with venafi endpoint with server error")
void authenticate() throws VCertException {
final Authentication auth = mock(Authentication.class);
classUnderTest.getAccessToken(auth);
verify(connector).getAccessToken(auth);
}
use of com.venafi.vcert.sdk.endpoint.Authentication in project vcert-java by Venafi.
the class TppTokenConnectorATForSSH method authenticate.
@BeforeEach
void authenticate(TestInfo testInfo) throws VCertException {
if (testInfo.getTags() != null && !testInfo.getTags().contains("AuthenticationUnneeded")) {
Security.addProvider(new BouncyCastleProvider());
// Executes only once to ensure the same token is used across the tests
if (TppTokenConnectorATForSSH.info == null) {
Authentication authentication = Authentication.builder().user(TestUtils.TPP_USER).password(TestUtils.TPP_PASSWORD).scope("ssh:manage").build();
TokenInfo info = classUnderTest.getAccessToken(authentication);
assertThat(info).isNotNull();
assertThat(info.authorized()).isTrue();
assertThat(info.errorMessage()).isNull();
assertThat(info.accessToken()).isNotNull();
assertThat(info.refreshToken()).isNotNull();
TppTokenConnectorATForSSH.info = info;
}
}
}
Aggregations