LoginHandler { void handleLogin(Executor executor, CookieStore cookieStore) throws JSONException, IOException, CredentialInvalidException { handleLogin(executor, cookieStore, false); } LoginHandler(SubstitutionScheduleData scheduleData, Credential auth,
                 @Nullable CookieProvider cookieProvider);   }
@Test(expected = CredentialInvalidException.class) public void testPostAuthFailCheckText() throws JSONException, IOException, CredentialInvalidException { stubPostAuth(); Executor exec = newExecutor(); LoginHandler handler = new LoginHandler(dataPostCheckText, wrong, null); handler.handleLogin(exec, null); }
@Test(expected = CredentialInvalidException.class) public void testPostAuthFailCheckUrl() throws JSONException, IOException, CredentialInvalidException { stubPostAuth(); Executor exec = newExecutor(); LoginHandler handler = new LoginHandler(dataPostCheckUrl, wrong, null); handler.handleLogin(exec, null); }
@Test public void testPostAuthFormData() throws JSONException, IOException, CredentialInvalidException { stubPostAuthFormData(); Executor exec = newExecutor(); LoginHandler handler = new LoginHandler(dataPostFormData, correct, null); handler.handleLogin(exec, null); String content = exec.execute(Request.Get(baseurl + "/index.html")).returnContent().asString(); assertEquals("content", content); }
@Test public void testBasicAuth() throws JSONException, IOException, CredentialInvalidException { stubBasicAuth(); Executor exec = newExecutor(); LoginHandler handler = new LoginHandler(dataBasic, correct, null); handler.handleLogin(exec, null); int status = exec.execute(Request.Get(baseurl + "/index.html")).returnResponse().getStatusLine() .getStatusCode(); assertEquals(200, status); }
@Test public void testBasicAuthFail() throws JSONException, IOException, CredentialInvalidException { stubBasicAuth(); Executor exec = newExecutor(); LoginHandler handler = new LoginHandler(dataBasic, wrong, null); handler.handleLogin(exec, null); int status = exec.execute(Request.Get(baseurl + "/index.html")).returnResponse().getStatusLine() .getStatusCode(); assertEquals(401, status); }
@Test(expected = CredentialInvalidException.class) public void testBasicAuthFailUrl() throws JSONException, IOException, CredentialInvalidException { stubBasicAuth(); Executor exec = newExecutor(); LoginHandler handler = new LoginHandler(dataBasicUrl, wrong, null); handler.handleLogin(exec, null); }
@Test public void testFixedAuth() throws JSONException, IOException, CredentialInvalidException { LoginHandler handler = new LoginHandler(dataFixed, correct, null); handler.handleLogin(newExecutor(), null); }
@Test(expected = CredentialInvalidException.class) public void testFixedAuthFail() throws JSONException, IOException, CredentialInvalidException { LoginHandler handler = new LoginHandler(dataFixed, wrong, null); handler.handleLogin(newExecutor(), null); }
@Test public void testPostAuth() throws JSONException, IOException, CredentialInvalidException { stubPostAuth(); Executor exec = newExecutor(); LoginHandler handler = new LoginHandler(dataPost, correct, null); handler.handleLogin(exec, null); String content = exec.execute(Request.Get(baseurl + "/index.html")).returnContent().asString(); assertEquals("content", content); }
@Test public void testPostAuthFail() throws JSONException, IOException, CredentialInvalidException { stubPostAuth(); Executor exec = newExecutor(); LoginHandler handler = new LoginHandler(dataPost, wrong, null); handler.handleLogin(exec, null); String content = exec.execute(Request.Get(baseurl + "/index.html")).returnContent().asString(); assertEquals("please login", content); }