public void SetBasicAuthorizationDetectionMethod( [Frozen] Mock <IHttpClient> httpClientMock, [Greedy] AuthorizationComponent sut, int contextId, BasicAuthorizationDetectionMethod basicAuthorizationDetectionMethod) { // ARRANGE httpClientMock.SetupApiCall(sut, CallType.Action, "setBasicAuthorizationDetectionMethod", new Parameters { { "contextId", contextId }, { "headerRegex", basicAuthorizationDetectionMethod.HeaderRegex }, { "bodyRegex", basicAuthorizationDetectionMethod.BodyRegex }, { "statusCode", basicAuthorizationDetectionMethod.StatusCode }, { "logicalOperator", basicAuthorizationDetectionMethod.LogicalOperator } }) .ReturnsOkResult() .Verifiable(); // ACT sut.SetBasicAuthorizationDetectionMethod(contextId, basicAuthorizationDetectionMethod); // ASSERT httpClientMock.Verify(); }
public void GetAuthorizationDetectionMethod( [Frozen] Mock <IHttpClient> httpClientMock, [Greedy] AuthorizationComponent sut, int contextId, BasicAuthorizationDetectionMethod basicAuthorizationDetectionMethod) { // ARRANGE var json = JObject.FromObject(basicAuthorizationDetectionMethod); json.Add("methodType", "basic"); httpClientMock.SetupApiCall(sut, CallType.View, "getAuthorizationDetectionMethod", new Parameters { { "contextId", contextId } }) .Returns(json.ToString()) .Verifiable(); // ACT var result = sut.GetAuthorizationDetectionMethod(contextId); // ASSERT result.ShouldBeEquivalentTo(basicAuthorizationDetectionMethod); httpClientMock.Verify(); }
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); }
public void ComponentName( [Greedy] AuthorizationComponent sut) { // ACT var result = sut.ComponentName; // ASSERT result.Should().Be("authorization"); }
public void GetAuthorizationDetectionMethod_UnsupportedMethodType( [Frozen] Mock <IHttpClient> httpClientMock, [Greedy] AuthorizationComponent sut, int contextId) { // ARRANGE var json = new JObject( new JProperty("methodType", "alternative")); httpClientMock.SetupApiCall(sut, CallType.View, "getAuthorizationDetectionMethod", new Parameters { { "contextId", contextId } }) .Returns(json.ToString()) .Verifiable(); // ACT Action act = () => sut.GetAuthorizationDetectionMethod(contextId); // ASSERT act.ShouldThrow <ZapException>().WithMessage(Resources.UnsupportedAuthorizationDetectionMethod); httpClientMock.Verify(); }