@Test public void testGetRefreshTokenWhenCredentialFlowIsNotCodeGrantFlowThenEmptyOptionalReturns() { when(credentialView.codeGrantFlow()).thenReturn(false); 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(2)).codeGrantFlow(); verify(credentialView, times(1)).getSubscriptionId(); verify(cbRefreshTokenClientProvider, times(0)).getCBRefreshTokenClient(anyString()); }
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();  }