Exemple #1
0
        public void Logout_OKResponseLogoutSucceed()
        {
            JiraClientStatusKeeper statusKeeper = LogInLogOutWithStatus(HttpStatusCode.OK);

            Assert.IsFalse(statusKeeper.IsLoggedIn);
            Assert.IsTrue(statusKeeper.LogoutSucceeded);
            Assert.IsFalse(statusKeeper.LogoutFailed);
        }
Exemple #2
0
        public void Login_EmptySetCookieHeaderLoginFail()
        {
            Dictionary <string, string> headers = new Dictionary <string, string> {
                { "Set-Cookie", string.Empty }
            };
            JiraClientStatusKeeper statusKeeper = LoginWithHeaders(headers);

            Assert.IsTrue(statusKeeper.LogonFailed);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        public void Login_EmptyAuthCookieLoginFail()
        {
            Dictionary <string, string> headers = new Dictionary <string, string>
            {
                { "Set-Cookie", CookieName + "=;Path=/;" }
            };
            JiraClientStatusKeeper statusKeeper = LoginWithHeaders(headers);

            Assert.IsTrue(statusKeeper.LogonFailed);
        }
Exemple #5
0
        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);
        }
Exemple #6
0
        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);
        }
Exemple #7
0
        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);
        }
Exemple #8
0
        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);
        }
Exemple #9
0
        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);
        }
Exemple #10
0
        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);
        }
Exemple #11
0
        public void Login_NoAuthCookieCallsLoginFail()
        {
            JiraClientStatusKeeper statusKeeper = LoginWithHeaders(new Dictionary <string, string>());

            Assert.IsTrue(statusKeeper.LogonFailed);
        }