private void setAuthInterceptor(String uriHost, String uriPath, String uriProtocol, int uriPort) { if (iamApiKey != null) { URI baseURI = getBaseUri(uriHost, uriPath, uriProtocol, uriPort); IamCookieInterceptor ici = new IamCookieInterceptor(iamApiKey, baseURI.toString()); requestInterceptors.add(ici); responseInterceptors.add(ici); } else if (this.username != null && this.password != null) { URI baseURI = getBaseUri(uriHost, uriPath, uriProtocol, uriPort); CookieInterceptor ci = new CookieInterceptor(this.username, this.password, baseURI .toString()); requestInterceptors.add(ci); responseInterceptors.add(ci); } }
String token = getBearerToken(context); if (token == null) { return false;
IamCookieInterceptor cookieInterceptor = new IamCookieInterceptor(this.iamApiKey, this.url.toString()); cookieInterceptor.getIamServerUrl(), iamServerClientId, iamServerClientSecret));
public CouchConfig(URI rootUri, List<HttpConnectionRequestInterceptor> requestInterceptors, List<HttpConnectionResponseInterceptor> responseInterceptors, String username, String password) { this.rootUri = rootUri; this.requestInterceptors = requestInterceptors; this.responseInterceptors = responseInterceptors; this.username = username; this.password = password; if (TestOptions.COUCH_IAM_API_KEY != null) { int slash = this.rootUri.toString().lastIndexOf("/"); String root = this.rootUri.toString().substring(0, slash); IamCookieInterceptor ici = new IamCookieInterceptor(TestOptions.COUCH_IAM_API_KEY, root); this.requestInterceptors.add(ici); this.responseInterceptors.add(ici); } }
@BeforeEach public void setupSessionInterceptor(boolean okUsable, String sessionPath) { this.mockWebServer = mockWebServerExt.get(); this.mockIamServer = mockIamServerExt.get(); String baseUrl = mockWebServer.url("").toString(); if (sessionPath.equals("/_session")) { CookieInterceptor ci = new CookieInterceptor("user", "pass", baseUrl); rqInterceptor = ci; rpInterceptor = ci; } else if (sessionPath.equals("/_iam_session")) { // Set the endpoint value before each test iamSystemPropertyMock.setMockIamTokenEndpointUrl(mockIamServer.url("/identity/token") .toString()); IamCookieInterceptor ici = new IamCookieInterceptor("apikey", baseUrl); rqInterceptor = ici; rpInterceptor = ici; } else { fail("Invalid sessionPath " + sessionPath); } }