[JAVA-15018] Removed redundant apache httpclient dependency + added commons-codec (#13828)
This commit is contained in:
@@ -21,7 +21,7 @@ public class HttpClient {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public int sendRquestWithAuthHeader(String url) throws IOException {
|
||||
public int sendRequestWithAuthHeader(String url) throws IOException {
|
||||
HttpURLConnection connection = null;
|
||||
try {
|
||||
connection = createConnection(url);
|
||||
@@ -34,7 +34,7 @@ public class HttpClient {
|
||||
}
|
||||
}
|
||||
|
||||
public int sendRquestWithAuthenticator(String url) throws IOException {
|
||||
public int sendRequestWithAuthenticator(String url) throws IOException {
|
||||
setAuthenticator();
|
||||
|
||||
HttpURLConnection connection = null;
|
||||
|
||||
@@ -7,28 +7,28 @@ import org.junit.Test;
|
||||
public class HttpClientLiveTest {
|
||||
|
||||
@Test
|
||||
public void sendRquestWithAuthHeader() throws Exception {
|
||||
public void sendRequestWithAuthHeader() throws Exception {
|
||||
HttpClient httpClient = new HttpClient("user1", "pass1");
|
||||
|
||||
int status = httpClient.sendRquestWithAuthHeader("https://httpbin.org/basic-auth/user1/pass1");
|
||||
int status = httpClient.sendRequestWithAuthHeader("https://httpbin.org/basic-auth/user1/pass1");
|
||||
|
||||
assertTrue(isSuccess(status));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sendRquestWithAuthHeader_whenIncorrectCredentials_thenNotSuccessful() throws Exception {
|
||||
public void sendRequestWithAuthHeader_whenIncorrectCredentials_thenNotSuccessful() throws Exception {
|
||||
HttpClient httpClient = new HttpClient("John", "Smith");
|
||||
|
||||
int status = httpClient.sendRquestWithAuthHeader("https://httpbin.org/basic-auth/user1/pass1");
|
||||
int status = httpClient.sendRequestWithAuthHeader("https://httpbin.org/basic-auth/user1/pass1");
|
||||
|
||||
assertTrue(isUnauthorized(status));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sendRquestWithAuthenticator() throws Exception {
|
||||
public void sendRequestWithAuthenticator() throws Exception {
|
||||
HttpClient httpClient = new HttpClient("user2", "pass2");
|
||||
|
||||
int status = httpClient.sendRquestWithAuthenticator("https://httpbin.org/basic-auth/user2/pass2");
|
||||
int status = httpClient.sendRequestWithAuthenticator("https://httpbin.org/basic-auth/user2/pass2");
|
||||
|
||||
assertTrue(isSuccess(status));
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public class HttpClientLiveTest {
|
||||
public void sendRquestWithAuthenticator_whenIncorrectCredentials_thenNotSuccessful() throws Exception {
|
||||
HttpClient httpClient = new HttpClient("John", "Smith");
|
||||
|
||||
int status = httpClient.sendRquestWithAuthenticator("https://httpbin.org/basic-auth/user2/pass2");
|
||||
int status = httpClient.sendRequestWithAuthenticator("https://httpbin.org/basic-auth/user2/pass2");
|
||||
|
||||
assertTrue(isUnauthorized(status));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user