@Test public void testGetRefreshTokenWhenThereIsNoRefreshTokenInCredentialViewThenNoRefreshTokenReturns() { when(credentialView.getRefreshToken()).thenReturn(null); when(credentialView.getAppReplyUrl()).thenReturn("replyUrl"); when(credentialView.getAuthorizationCode()).thenReturn("someAuthCode"); Optional<String> result = new AzureClientCredentials(credentialView, LOG_LEVEL, cbRefreshTokenClientProvider, authenticationContextProvider, tracingInterceptor) .getRefreshToken(); assertFalse(result.isPresent()); verify(credentialView, times(1)).getTenantId(); verify(credentialView, times(1)).getAccessKey(); verify(credentialView, times(1)).getSecretKey(); verify(credentialView, times(1)).getAppReplyUrl(); verify(credentialView, times(1)).getRefreshToken(); verify(credentialView, times(2)).codeGrantFlow(); verify(credentialView, times(1)).getSubscriptionId(); verify(credentialView, times(1)).getAuthorizationCode(); verify(cbRefreshTokenClientProvider, times(1)).getCBRefreshTokenClient(anyString()); verify(cbRefreshTokenClient, times(0)).refreshToken(anyString(), anyString(), anyString(), anyString(), anyString(), anyBoolean()); verify(cbRefreshTokenClientProvider, times(1)).getCBRefreshTokenClient(eq(AzureEnvironment.AZURE.activeDirectoryEndpoint())); }
public Optional<String> getRefreshToken() { String refreshToken = null; Optional<Boolean> codeGrantFlow = Optional.ofNullable(credentialView.codeGrantFlow()); if (codeGrantFlow.orElse(Boolean.FALSE)) { CbDelegatedTokenCredentials delegatedCredentials = (CbDelegatedTokenCredentials) azureClientCredentials; Optional<AuthenticationResult> authenticationResult = delegatedCredentials.getTokens() .values() .stream() .findFirst(); if (authenticationResult.isPresent()) { refreshToken = authenticationResult.get().getRefreshToken(); } } return Optional.ofNullable(refreshToken); }
AzureClientCredentials { public Optional<String> getRefreshToken() { String refreshToken = null; Optional<Boolean> codeGrantFlow = Optional.ofNullable(credentialView.codeGrantFlow()); if (codeGrantFlow.orElse(Boolean.FALSE)) { CbDelegatedTokenCredentials delegatedCredentials = (CbDelegatedTokenCredentials) azureClientCredentials; Optional<AuthenticationResult> authenticationResult = delegatedCredentials.getTokens() .values() .stream() .findFirst(); if (authenticationResult.isPresent()) { refreshToken = authenticationResult.get().getRefreshToken(); } } return Optional.ofNullable(refreshToken); } }
AzureClientCredentials { public Optional<String> getRefreshToken() { String refreshToken = null; Optional<Boolean> codeGrantFlow = Optional.ofNullable(credentialView.codeGrantFlow()); if (codeGrantFlow.orElse(Boolean.FALSE)) { CbDelegatedTokenCredentials delegatedCredentials = (CbDelegatedTokenCredentials) azureClientCredentials; Optional<AuthenticationResult> authenticationResult = delegatedCredentials.getTokens() .values() .stream() .findFirst(); if (authenticationResult.isPresent()) { refreshToken = authenticationResult.get().getRefreshToken(); } } return Optional.ofNullable(refreshToken); } AzureClientCredentials(AzureCredentialView credentialView, LogLevel logLevel, CBRefreshTokenClientProvider cbRefreshTokenClientProvider,
            AuthenticationContextProvider authenticationContextProvider, AzureOkHttp3TracingInterceptor tracingInterceptor); }
AzureClientCredentials { public Optional<String> getRefreshToken() { String refreshToken = null; Optional<Boolean> codeGrantFlow = Optional.ofNullable(credentialView.codeGrantFlow()); if (codeGrantFlow.orElse(Boolean.FALSE)) { CbDelegatedTokenCredentials delegatedCredentials = (CbDelegatedTokenCredentials) azureClientCredentials; Optional<AuthenticationResult> authenticationResult = delegatedCredentials.getTokens() .values() .stream() .findFirst(); if (authenticationResult.isPresent()) { refreshToken = authenticationResult.get().getRefreshToken(); } } return Optional.ofNullable(refreshToken); } AzureClientCredentials(AzureCredentialView credentialView, LogLevel logLevel, CBRefreshTokenClientProvider cbRefreshTokenClientProvider,
            AuthenticationContextProvider authenticationContextProvider, AzureOkHttp3TracingInterceptor tracingInterceptor); Azure getAzure(); Optional<String> getRefreshToken(); }
AzureClientCredentials { public Optional<String> getRefreshToken() { String refreshToken = null; Optional<Boolean> codeGrantFlow = Optional.ofNullable(credentialView.codeGrantFlow()); if (codeGrantFlow.orElse(Boolean.FALSE)) { CbDelegatedTokenCredentials delegatedCredentials = (CbDelegatedTokenCredentials) azureClientCredentials; Optional<AuthenticationResult> authenticationResult = delegatedCredentials.getTokens() .values() .stream() .findFirst(); if (authenticationResult.isPresent()) { refreshToken = authenticationResult.get().getRefreshToken(); } } return Optional.ofNullable(refreshToken); } AzureClientCredentials(AzureCredentialView credentialView, LogLevel logLevel, CBRefreshTokenClientProvider cbRefreshTokenClientProvider,
            AuthenticationContextProvider authenticationContextProvider, AzureOkHttp3TracingInterceptor tracingInterceptor); Azure getAzure(); Optional<String> getRefreshToken();  }