Ejemplo n.º 1
0
        public void GetExcludedRegexes(
            [Frozen] Mock <IHttpClient> httpClientMock,
            [Greedy] ContextComponent sut,
            string name,
            IEnumerable <string> excludedRegexes)
        {
            // ARRANGE
            var json = new JObject(
                new JProperty("excludeRegexs", excludedRegexes.ToJsonStringList()));

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

            // ACT
            var result = sut.GetExcludedRegexes(name);

            // ASSERT
            result.ShouldBeEquivalentTo(excludedRegexes);
            httpClientMock.Verify();
        }
Ejemplo n.º 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);
 }
Ejemplo n.º 3
0
        public void NewContext(
            [Frozen] Mock <IHttpClient> httpClientMock,
            [Greedy] ContextComponent sut,
            string name,
            int contextId)
        {
            // ARRANGE
            var json = new JObject(
                new JProperty("contextId", contextId));

            httpClientMock.SetupApiCall(sut, CallType.Action, "newContext",
                                        new Parameters
            {
                { "contextName", name }
            })
            .Returns(json.ToString())
            .Verifiable();

            // ACT
            var result = sut.NewContext(name);

            // ASSERT
            result.Should().Be(contextId);
            httpClientMock.Verify();
        }
Ejemplo n.º 4
0
        public void ComponentName(
            [Greedy] ContextComponent sut)
        {
            // ACT
            var result = sut.ComponentName;

            // ASSERT
            result.Should().Be("context");
        }
Ejemplo n.º 5
0
        public void ImportContext(
            [Frozen] Mock <IHttpClient> httpClientMock,
            [Greedy] ContextComponent sut,
            string filePath)
        {
            // ARRANGE
            httpClientMock.SetupApiCall(sut, CallType.Action, "importContext",
                                        new Parameters
            {
                { "contextFile", filePath }
            })
            .ReturnsOkResult()
            .Verifiable();

            // ACT
            sut.ImportContext(filePath);

            // ASSERT
            httpClientMock.Verify();
        }
Ejemplo n.º 6
0
        public void GetContextList(
            [Frozen] Mock <IHttpClient> httpClientMock,
            [Greedy] ContextComponent sut,
            string name,
            IEnumerable <string> contextList)
        {
            // ARRANGE
            var json = new JObject(
                new JProperty("contextList", contextList.ToJsonStringList()));

            httpClientMock.SetupApiCall(sut, CallType.View, "contextList")
            .Returns(json.ToString())
            .Verifiable();

            // ACT
            var result = sut.GetContextList();

            // ASSERT
            result.ShouldBeEquivalentTo(contextList);
            httpClientMock.Verify();
        }
Ejemplo n.º 7
0
        public void SetContextInScope(
            [Frozen] Mock <IHttpClient> httpClientMock,
            [Greedy] ContextComponent sut,
            string name,
            bool inScope)
        {
            // ARRANGE
            httpClientMock.SetupApiCall(sut, CallType.Action, "setContextInScope",
                                        new Parameters
            {
                { "contextName", name },
                { "booleanInScope", inScope }
            })
            .ReturnsOkResult()
            .Verifiable();

            // ACT
            sut.SetContextInScope(name, inScope);

            // ASSERT
            httpClientMock.Verify();
        }
Ejemplo n.º 8
0
        public void IncludeInContext(
            [Frozen] Mock <IHttpClient> httpClientMock,
            [Greedy] ContextComponent sut,
            string name,
            string regex)
        {
            // ARRANGE
            httpClientMock.SetupApiCall(sut, CallType.Action, "includeInContext",
                                        new Parameters
            {
                { "contextName", name },
                { "regex", regex }
            })
            .ReturnsOkResult()
            .Verifiable();

            // ACT
            sut.IncludeInContext(name, regex);

            // ASSERT
            httpClientMock.Verify();
        }
Ejemplo n.º 9
0
        public void GetContext(
            [Frozen] Mock <IHttpClient> httpClientMock,
            [Greedy] ContextComponent sut,
            string name,
            Schema.Context context)
        {
            // ARRANGE
            var json = JObject.FromObject(context);

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

            // ACT
            var result = sut.GetContext(name);

            // ASSERT
            result.ShouldBeEquivalentTo(context);
            httpClientMock.Verify();
        }