@Test public void testForFailedStatusBecauseMissingServiceAccId() throws InvalidGcpContextException { final AuthenticatedContext authContext = createAuthContext(); when(contextBuilder.contextInit(authContext.getCloudContext(), authContext, null, null, false)).thenReturn(context); doThrow(new NullPointerException()).when(gcpCredentialVerifier).checkGcpContextValidity(context); CloudCredentialStatus status = underTest.verify(authContext, CREDENTIAL_VERIFICATION_CONTEXT); Assert.assertNotNull("The returned CloudCredentialStatus instance is null!", status); Assert.assertEquals("Invalid credential status has specified!", CredentialStatus.FAILED, status.getStatus()); }
@Override public CloudCredentialStatus verify(@Nonnull AuthenticatedContext authenticatedContext, CredentialVerificationContext credentialVerificationContext) { LOGGER.debug("Verify credential: {}", authenticatedContext.getCloudCredential()); GcpStackUtil.prepareCredential(authenticatedContext.getCloudCredential()); GcpContext gcpContext = gcpContextBuilder.contextInit(authenticatedContext.getCloudContext(), authenticatedContext, null, null, false); try { gcpCredentialVerifier.checkGcpContextValidity(gcpContext); gcpCredentialVerifier.preCheckOfGooglePermission(gcpContext); } catch (TokenResponseException te) { return createFailedCloudCredentialStatusWithExc(te, authenticatedContext, getErrDescriptionFromTokenResponse(te)); } catch (Exception e) { return createFailedCloudCredentialStatusWithExc(e, authenticatedContext, Optional.empty()); } return new CloudCredentialStatus(authenticatedContext.getCloudCredential(), CredentialStatus.VERIFIED); }
GcpCredentialConnector implements CredentialConnector { @Override public CloudCredentialStatus verify(@Nonnull AuthenticatedContext authenticatedContext, CredentialVerificationContext credentialVerificationContext) { LOGGER.debug("Verify credential: {}", authenticatedContext.getCloudCredential()); GcpStackUtil.prepareCredential(authenticatedContext.getCloudCredential()); GcpContext gcpContext = gcpContextBuilder.contextInit(authenticatedContext.getCloudContext(), authenticatedContext, null, null, false); try { gcpCredentialVerifier.checkGcpContextValidity(gcpContext); gcpCredentialVerifier.preCheckOfGooglePermission(gcpContext); } catch (TokenResponseException te) { return createFailedCloudCredentialStatusWithExc(te, authenticatedContext, getErrDescriptionFromTokenResponse(te)); } catch (Exception e) { return createFailedCloudCredentialStatusWithExc(e, authenticatedContext, Optional.empty()); } return new CloudCredentialStatus(authenticatedContext.getCloudCredential(), CredentialStatus.VERIFIED); } }
GcpCredentialConnector implements CredentialConnector { @Override public CloudCredentialStatus verify(@Nonnull AuthenticatedContext authenticatedContext, CredentialVerificationContext credentialVerificationContext) { LOGGER.debug("Verify credential: {}", authenticatedContext.getCloudCredential()); GcpStackUtil.prepareCredential(authenticatedContext.getCloudCredential()); GcpContext gcpContext = gcpContextBuilder.contextInit(authenticatedContext.getCloudContext(), authenticatedContext, null, null, false); try { gcpCredentialVerifier.checkGcpContextValidity(gcpContext); gcpCredentialVerifier.preCheckOfGooglePermission(gcpContext); } catch (TokenResponseException te) { return createFailedCloudCredentialStatusWithExc(te, authenticatedContext, getErrDescriptionFromTokenResponse(te)); } catch (Exception e) { return createFailedCloudCredentialStatusWithExc(e, authenticatedContext, Optional.empty()); } return new CloudCredentialStatus(authenticatedContext.getCloudCredential(), CredentialStatus.VERIFIED); }  }
GcpCredentialConnector implements CredentialConnector { @Override public CloudCredentialStatus verify(@Nonnull AuthenticatedContext authenticatedContext, CredentialVerificationContext credentialVerificationContext) { LOGGER.debug("Verify credential: {}", authenticatedContext.getCloudCredential()); GcpStackUtil.prepareCredential(authenticatedContext.getCloudCredential()); GcpContext gcpContext = gcpContextBuilder.contextInit(authenticatedContext.getCloudContext(), authenticatedContext, null, null, false); try { gcpCredentialVerifier.checkGcpContextValidity(gcpContext); gcpCredentialVerifier.preCheckOfGooglePermission(gcpContext); } catch (TokenResponseException te) { return createFailedCloudCredentialStatusWithExc(te, authenticatedContext, getErrDescriptionFromTokenResponse(te)); } catch (Exception e) { return createFailedCloudCredentialStatusWithExc(e, authenticatedContext, Optional.empty()); } return new CloudCredentialStatus(authenticatedContext.getCloudCredential(), CredentialStatus.VERIFIED); }  @Override CloudCredentialStatus verify(@Nonnull AuthenticatedContext authenticatedContext, CredentialVerificationContext credentialVerificationContext); @Override CloudCredentialStatus create(@Nonnull AuthenticatedContext authenticatedContext); @Override CloudCredentialStatus delete(@Nonnull AuthenticatedContext authenticatedContext); @Override CredentialPrerequisitesResponse getPrerequisites(CloudContext cloudContext, String externalId, String deploymentAddress, CredentialType type); }
GcpCredentialConnector implements CredentialConnector { @Override public CloudCredentialStatus verify(@Nonnull AuthenticatedContext authenticatedContext, CredentialVerificationContext credentialVerificationContext) { LOGGER.debug("Verify credential: {}", authenticatedContext.getCloudCredential()); GcpStackUtil.prepareCredential(authenticatedContext.getCloudCredential()); GcpContext gcpContext = gcpContextBuilder.contextInit(authenticatedContext.getCloudContext(), authenticatedContext, null, null, false); try { gcpCredentialVerifier.checkGcpContextValidity(gcpContext); gcpCredentialVerifier.preCheckOfGooglePermission(gcpContext); } catch (TokenResponseException te) { return createFailedCloudCredentialStatusWithExc(te, authenticatedContext, getErrDescriptionFromTokenResponse(te)); } catch (Exception e) { return createFailedCloudCredentialStatusWithExc(e, authenticatedContext, Optional.empty()); } return new CloudCredentialStatus(authenticatedContext.getCloudCredential(), CredentialStatus.VERIFIED); }  @Override CloudCredentialStatus verify(@Nonnull AuthenticatedContext authenticatedContext, CredentialVerificationContext credentialVerificationContext); @Override CloudCredentialStatus create(@Nonnull AuthenticatedContext authenticatedContext); @Override CloudCredentialStatus delete(@Nonnull AuthenticatedContext authenticatedContext); @Override CredentialPrerequisitesResponse getPrerequisites(CloudContext cloudContext, String externalId, String deploymentAddress, CredentialType type);  }