Example #1
0
        public void GetSessions(
            [Frozen] Mock <IHttpClient> httpClientMock,
            [Greedy] HttpSessionsComponent sut,
            string site,
            string name,
            IEnumerable <HttpSession> sessions)
        {
            // ARRANGE
            var json = new JObject(
                new JProperty("sessions", JArray.FromObject(sessions)));

            httpClientMock.SetupApiCall(sut, CallType.View, "sessions",
                                        new Parameters
            {
                { "site", site },
                { "session", name }
            })
            .Returns(json.ToString())
            .Verifiable();

            // ACT
            var result = sut.GetSessions(site, name);

            // ASSERT
            result.ShouldBeEquivalentTo(sessions);
            httpClientMock.Verify();
        }
Example #2
0
 public ZapClient(string host, int port, Protocols protocol = Protocols.http)
 {
     Protocol          = protocol;
     Host              = host;
     Port              = port;
     Acsrf             = new AcsrfComponent(this);
     AjaxSpider        = new AjaxSpiderComponent(this);
     Ascan             = new AscanComponent(this);
     Authentication    = new AuthenticationComponent(this);
     Authorization     = new AuthorizationComponent(this);
     Autoupdate        = new AutoupdateComponent(this);
     Break             = new BreakComponent(this);
     Context           = new ContextComponent(this);
     Core              = new CoreComponent(this);
     ForcedUser        = new ForcedUserComponent(this);
     HttpSessions      = new HttpSessionsComponent(this);
     Params            = new ParamsComponent(this);
     Pscan             = new PscanComponent(this);
     Reveal            = new RevealComponent(this);
     Script            = new ScriptComponent(this);
     Search            = new SearchComponent(this);
     Selenium          = new SeleniumComponent(this);
     SessionManagement = new SessionManagementComponent(this);
     Spider            = new SpiderComponent(this);
     Users             = new UsersComponent(this);
 }
Example #3
0
        public void GetActiveSession(
            [Frozen] Mock <IHttpClient> httpClientMock,
            [Greedy] HttpSessionsComponent sut,
            string site,
            string activeSession)
        {
            // ARRANGE
            var json = new JObject(
                new JProperty("active_session", activeSession));

            httpClientMock.SetupApiCall(sut, CallType.View, "activeSession",
                                        new Parameters
            {
                { "site", site }
            })
            .Returns(json.ToString())
            .Verifiable();

            // ACT
            var result = sut.GetActiveSession(site);

            // ASSERT
            result.Should().Be(activeSession);
            httpClientMock.Verify();
        }
Example #4
0
        public void SetSessionTokenValue(
            [Frozen] Mock <IHttpClient> httpClientMock,
            [Greedy] HttpSessionsComponent sut,
            string site,
            string sessionName,
            string sessionTokenName,
            string value)
        {
            // ARRANGE
            httpClientMock.SetupApiCall(sut, CallType.Action, "setSessionTokenValue",
                                        new Parameters
            {
                { "site", site },
                { "session", sessionName },
                { "sessionToken", sessionTokenName },
                { "tokenValue", value }
            })
            .ReturnsOkResult()
            .Verifiable();

            // ACT
            sut.SetSessionTokenValue(site, sessionName, sessionTokenName, value);

            // ASSERT
            httpClientMock.Verify();
        }
Example #5
0
        public void ComponentName(
            [Greedy] HttpSessionsComponent sut)
        {
            // ACT
            var result = sut.ComponentName;

            // ASSERT
            result.Should().Be("httpSessions");
        }
Example #6
0
        public void UnsetActiveSession(
            [Frozen] Mock <IHttpClient> httpClientMock,
            [Greedy] HttpSessionsComponent sut,
            string site)
        {
            // ARRANGE
            httpClientMock.SetupApiCall(sut, CallType.Action, "unsetActiveSession",
                                        new Parameters
            {
                { "site", site }
            })
            .ReturnsOkResult()
            .Verifiable();

            // ACT
            sut.UnsetActiveSession(site);

            // ASSERT
            httpClientMock.Verify();
        }
Example #7
0
        public void RenameSession(
            [Frozen] Mock <IHttpClient> httpClientMock,
            [Greedy] HttpSessionsComponent sut,
            string site,
            string oldName,
            string newName)
        {
            // ARRANGE
            httpClientMock.SetupApiCall(sut, CallType.Action, "renameSession",
                                        new Parameters
            {
                { "site", site },
                { "oldSessionName", oldName },
                { "newSessionName", newName }
            })
            .ReturnsOkResult()
            .Verifiable();

            // ACT
            sut.RenameSession(site, oldName, newName);

            // ASSERT
            httpClientMock.Verify();
        }