@Test public void testGetPrerequisitesReturnsTheExpectedValue() { String expectedCommand = "someAppCreationCommandValue"; String expectedRoleDef = "roleDefJson"; when(appCreationCommand.generate(anyString())).thenReturn(expectedCommand); when(azurePlatformParameters.getRoleDefJson()).thenReturn(expectedRoleDef); CredentialPrerequisitesResponse result = underTest.getPrerequisites(TEST_CLOUD_CONTEXT, "2", DEPLOYMENT_ADDRESS, CredentialType.ENVIRONMENT); assertEquals(PLATFORM, result.getCloudPlatform()); assertEquals(expectedCommand, new String(Base64.decodeBase64(result.getAzure().getAppCreationCommand()))); assertEquals(expectedRoleDef, result.getAzure().getRoleDefitionJson()); }
@Override public CredentialPrerequisitesResponse getPrerequisites(CloudContext cloudContext, String externalId, String deploymentAddress, CredentialType type) { String creationCommand = appCreationCommand.generate(deploymentAddress); String encodedCommand = Base64.encodeBase64String(creationCommand.getBytes()); String roleDefJson; switch (type) { case ENVIRONMENT: roleDefJson = azurePlatformParameters.getRoleDefJson(); break; case AUDIT: roleDefJson = azurePlatformParameters.getAuditRoleDefJson(); break; default: roleDefJson = null; break; } AzureCredentialPrerequisites azurePrerequisites = new AzureCredentialPrerequisites(encodedCommand, roleDefJson); return new CredentialPrerequisitesResponse(cloudContext.getPlatform().value(), azurePrerequisites); }
AzureCredentialConnector implements CredentialConnector { @Override public CredentialPrerequisitesResponse getPrerequisites(CloudContext cloudContext, String externalId, String deploymentAddress, CredentialType type) { String creationCommand = appCreationCommand.generate(deploymentAddress); String encodedCommand = Base64.encodeBase64String(creationCommand.getBytes()); String roleDefJson; switch (type) { case ENVIRONMENT: roleDefJson = azurePlatformParameters.getRoleDefJson(); break; case AUDIT: roleDefJson = azurePlatformParameters.getAuditRoleDefJson(); break; default: roleDefJson = null; break; } AzureCredentialPrerequisites azurePrerequisites = new AzureCredentialPrerequisites(encodedCommand, roleDefJson); return new CredentialPrerequisitesResponse(cloudContext.getPlatform().value(), azurePrerequisites); } }
AzureCredentialConnector implements CredentialConnector { @Override public CredentialPrerequisitesResponse getPrerequisites(CloudContext cloudContext, String externalId, String deploymentAddress, CredentialType type) { String creationCommand = appCreationCommand.generate(deploymentAddress); String encodedCommand = Base64.encodeBase64String(creationCommand.getBytes()); String roleDefJson; switch (type) { case ENVIRONMENT: roleDefJson = azurePlatformParameters.getRoleDefJson(); break; case AUDIT: roleDefJson = azurePlatformParameters.getAuditRoleDefJson(); break; default: roleDefJson = null; break; } AzureCredentialPrerequisites azurePrerequisites = new AzureCredentialPrerequisites(encodedCommand, roleDefJson); return new CredentialPrerequisitesResponse(cloudContext.getPlatform().value(), azurePrerequisites); }  }
AzureCredentialConnector implements CredentialConnector { @Override public CredentialPrerequisitesResponse getPrerequisites(CloudContext cloudContext, String externalId, String deploymentAddress, CredentialType type) { String creationCommand = appCreationCommand.generate(deploymentAddress); String encodedCommand = Base64.encodeBase64String(creationCommand.getBytes()); String roleDefJson; switch (type) { case ENVIRONMENT: roleDefJson = azurePlatformParameters.getRoleDefJson(); break; case AUDIT: roleDefJson = azurePlatformParameters.getAuditRoleDefJson(); break; default: roleDefJson = null; break; } AzureCredentialPrerequisites azurePrerequisites = new AzureCredentialPrerequisites(encodedCommand, roleDefJson); return new CredentialPrerequisitesResponse(cloudContext.getPlatform().value(), azurePrerequisites); }  @Override CloudCredentialStatus verify(AuthenticatedContext authenticatedContext, CredentialVerificationContext credentialVerificationContext); @Override CloudCredentialStatus create(AuthenticatedContext authenticatedContext); @Override Map<String, String> interactiveLogin(CloudContext cloudContext, ExtendedCloudCredential extendedCloudCredential,
            CredentialNotifier credentialNotifier); @Override CloudCredentialStatus delete(AuthenticatedContext authenticatedContext); @Override CredentialPrerequisitesResponse getPrerequisites(CloudContext cloudContext, String externalId, String deploymentAddress, CredentialType type); @Override Map<String, String> initCodeGrantFlow(CloudContext cloudContext, CloudCredential cloudCredential); }
AzureCredentialConnector implements CredentialConnector { @Override public CredentialPrerequisitesResponse getPrerequisites(CloudContext cloudContext, String externalId, String deploymentAddress, CredentialType type) { String creationCommand = appCreationCommand.generate(deploymentAddress); String encodedCommand = Base64.encodeBase64String(creationCommand.getBytes()); String roleDefJson; switch (type) { case ENVIRONMENT: roleDefJson = azurePlatformParameters.getRoleDefJson(); break; case AUDIT: roleDefJson = azurePlatformParameters.getAuditRoleDefJson(); break; default: roleDefJson = null; break; } AzureCredentialPrerequisites azurePrerequisites = new AzureCredentialPrerequisites(encodedCommand, roleDefJson); return new CredentialPrerequisitesResponse(cloudContext.getPlatform().value(), azurePrerequisites); }  @Override CloudCredentialStatus verify(AuthenticatedContext authenticatedContext, CredentialVerificationContext credentialVerificationContext); @Override CloudCredentialStatus create(AuthenticatedContext authenticatedContext); @Override Map<String, String> interactiveLogin(CloudContext cloudContext, ExtendedCloudCredential extendedCloudCredential,
            CredentialNotifier credentialNotifier); @Override CloudCredentialStatus delete(AuthenticatedContext authenticatedContext); @Override CredentialPrerequisitesResponse getPrerequisites(CloudContext cloudContext, String externalId, String deploymentAddress, CredentialType type); @Override Map<String, String> initCodeGrantFlow(CloudContext cloudContext, CloudCredential cloudCredential);  }