public void Logout_OKResponseLogoutSucceed() { JiraClientStatusKeeper statusKeeper = LogInLogOutWithStatus(HttpStatusCode.OK); Assert.IsFalse(statusKeeper.IsLoggedIn); Assert.IsTrue(statusKeeper.LogoutSucceeded); Assert.IsFalse(statusKeeper.LogoutFailed); }
public void Login_EmptySetCookieHeaderLoginFail() { Dictionary <string, string> headers = new Dictionary <string, string> { { "Set-Cookie", string.Empty } }; JiraClientStatusKeeper statusKeeper = LoginWithHeaders(headers); Assert.IsTrue(statusKeeper.LogonFailed); }
public void Logout_ForbiddenResponseLogoutFails() { JiraClientStatusKeeper statusKeeper = LogInLogOutWithStatus(HttpStatusCode.Forbidden); Assert.True(statusKeeper.IsLoggedIn); Assert.IsFalse(statusKeeper.LogoutSucceeded); Assert.IsTrue(statusKeeper.LogoutFailed); Assert.IsTrue(statusKeeper.EncounteredError); }
public void Login_EmptyAuthCookieLoginFail() { Dictionary <string, string> headers = new Dictionary <string, string> { { "Set-Cookie", CookieName + "=;Path=/;" } }; JiraClientStatusKeeper statusKeeper = LoginWithHeaders(headers); Assert.IsTrue(statusKeeper.LogonFailed); }
public void Login_InvalidSetCookieHeaderLoginFail() { Dictionary <string, string> headers = new Dictionary <string, string> { { CookieName, "This Is not a valid header" } }; JiraClientStatusKeeper statusKeeper = LoginWithHeaders(headers); Assert.IsTrue(statusKeeper.LogonFailed); }
public void Logout_LogoutWhenNotLoggedInDoesNothing() { JiraClient client = new JiraClient(FakeUsername, FakePassword, FakeServerUrl); JiraClientStatusKeeper statusKeeper = new JiraClientStatusKeeper(client); client.LogOut(); Assert.IsFalse(statusKeeper.IsLoggedIn); Assert.IsFalse(statusKeeper.LogoutFailed); Assert.IsFalse(statusKeeper.LogoutSucceeded); }
public void Login_ValidCookieHeaderLoginSuccess() { Dictionary <string, string> headers = new Dictionary <string, string> { { "Set-Cookie", CookieName + "=secret_value;Path=/;" } }; JiraClientStatusKeeper statusKeeper = LoginWithHeaders(headers); Assert.IsFalse(statusKeeper.LogonFailed); Assert.IsTrue(statusKeeper.IsLoggedIn); Assert.IsTrue(statusKeeper.LogonSucceeded); }
private static JiraClientStatusKeeper LoginWithHeaders(Dictionary <string, string> headers) { IHttpResponse response = new MockHttpResponse <TogglEntry[]>() { FakeHeaders = headers }; MockHttpDataSource source = new MockHttpDataSource(); JiraClient client = new JiraClient(FakeUsername, FakePassword, FakeServerUrl, source); JiraClientStatusKeeper statusKeeper = new JiraClientStatusKeeper(client); source.SetResponse(SessionUrl, "POST", response); client.LogIn(); return(statusKeeper); }
private static MockHttpDataSource GetLoggedInClient(out JiraClient client, out JiraClientStatusKeeper statusKeeper) { Dictionary <string, string> headers = new Dictionary <string, string> { { "Set-Cookie", ValidFakeCookie } }; MockHttpDataSource source = new MockHttpDataSource(); client = new JiraClient(FakeUsername, FakePassword, FakeServerUrl, source); statusKeeper = new JiraClientStatusKeeper(client); source.SetResponse(SessionUrl, "POST", new MockHttpResponse <TogglEntry[]>() { FakeHeaders = headers }); client.LogIn(); Assert.IsTrue(statusKeeper.IsLoggedIn); return(source); }
private static JiraClientStatusKeeper LogInLogOutWithStatus(HttpStatusCode statusCode) { Dictionary <string, string> headers = new Dictionary <string, string> { { "Set-Cookie", ValidFakeCookie } }; MockHttpDataSource source = new MockHttpDataSource(); JiraClient client = new JiraClient(FakeUsername, FakePassword, FakeServerUrl, source); JiraClientStatusKeeper statusKeeper = new JiraClientStatusKeeper(client); source.SetResponse(SessionUrl, "POST", new MockHttpResponse <TogglEntry[]>() { FakeHeaders = headers }); source.SetResponse(SessionUrl, "DELETE", new MockHttpResponse <TogglEntry[]>() { FakeStatusCode = statusCode }); client.LogIn(); client.LogOut(); return(statusKeeper); }
public void Login_NoAuthCookieCallsLoginFail() { JiraClientStatusKeeper statusKeeper = LoginWithHeaders(new Dictionary <string, string>()); Assert.IsTrue(statusKeeper.LogonFailed); }