Skip to content

Commit ea9bdb0

Browse files
authored
Merge pull request #726 from microsoftgraph/bugfix/unit-test-audience
- fixes a bug where the test authentication provider would try to authenticate requests for the wrong audience
2 parents e743592 + 2fed754 commit ea9bdb0

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/test/java/com/microsoft/graph/functional/TestBase.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import com.microsoft.graph.http.CoreHttpProvider;
1414
import com.microsoft.graph.http.IHttpRequest;
1515
import com.microsoft.graph.httpcore.HttpClients;
16-
import com.microsoft.graph.authentication.IAuthenticationProvider;
16+
import com.microsoft.graph.authentication.BaseAuthenticationProvider;
1717
import com.microsoft.graph.requests.GraphServiceClient;
1818

1919
import okhttp3.OkHttpClient;
@@ -58,20 +58,24 @@ private void GetClient(boolean authenticate)
5858
}
5959
}
6060
}
61-
public IAuthenticationProvider getUnauthenticationProvider() {
62-
return new IAuthenticationProvider() {
61+
public BaseAuthenticationProvider getUnauthenticationProvider() {
62+
return new BaseAuthenticationProvider() {
6363
@Override
6464
public CompletableFuture<String> getAuthorizationTokenAsync(final URL requestUrl) {
6565
return CompletableFuture.completedFuture((String)null);
6666
}
6767
};
6868
}
69-
public IAuthenticationProvider getAuthenticationProvider() {
69+
public BaseAuthenticationProvider getAuthenticationProvider() {
7070
final String accessToken = GetAccessToken().replace("\"", "");
71-
return new IAuthenticationProvider() {
71+
return new BaseAuthenticationProvider() {
7272
@Override
7373
public CompletableFuture<String> getAuthorizationTokenAsync(final URL requestUrl) {
74-
return CompletableFuture.completedFuture(accessToken);
74+
if(this.shouldAuthenticateRequestWithUrl(requestUrl)) {
75+
return CompletableFuture.completedFuture(accessToken);
76+
} else {
77+
return CompletableFuture.completedFuture(null);
78+
}
7579
}
7680
};
7781
}

0 commit comments

Comments
 (0)