@Test public void testWrongPort() throws IOException { httpClient .get(uri, authResponseHandler) .addAuth( HttpClientDefaultAuthProvider.forUserAndHost( localHttpService.getHost(), 22, LOGIN_USER, LOGIN_PASSWORD)) .perform(); Assert.assertThat(testHandler.getToken(), is(nullValue())); }
@After public void teardown() { Assert.assertNotNull(localHttpService); Assert.assertNotNull(testHandler); Assert.assertNotNull(httpClient); Assert.assertNotNull(uri); localHttpService.stop(); localHttpService = null; testHandler = null; httpClient.close(); httpClient = null; uri = null; }
@Test public void testWrongScheme() throws IOException { httpClient .get(uri, authResponseHandler) .addAuth( new HttpClientDefaultAuthProvider( "DIGEST", localHttpService.getHost(), localHttpService.getPort(), "test", LOGIN_USER, LOGIN_PASSWORD)) .perform(); Assert.assertThat(testHandler.getToken(), is(nullValue())); }
@Test public void testGetItRight() throws IOException { final String response = httpClient .get( uri, new ContentResponseHandler<String>( new ResponseCodeCheckingConverter(HttpServletResponse.SC_OK))) .addAuth( new HttpClientDefaultAuthProvider( "BASIC", localHttpService.getHost(), localHttpService.getPort(), "test", LOGIN_USER, LOGIN_PASSWORD)) .perform(); Assert.assertThat(response, is(testString)); Assert.assertThat(testHandler.getToken(), is(trackingToken)); }
@Test public void testNoAuth() throws IOException { httpClient.get(uri, authResponseHandler).perform(); Assert.assertThat(testHandler.getToken(), is(nullValue())); }
@Test public void testWrongPassword() throws IOException { httpClient.get(uri, authResponseHandler).addBasicAuth("somedude", LOGIN_PASSWORD).perform(); Assert.assertThat(testHandler.getToken(), is(nullValue())); }