Search in sources :

Example 86 with Context

use of org.zaproxy.zap.model.Context in project zaproxy by zaproxy.

the class ManualAuthenticationMethodType method getSetMethodForContextApiAction.

@Override
public ApiDynamicActionImplementor getSetMethodForContextApiAction() {
    return new ApiDynamicActionImplementor(API_METHOD_NAME, null, null) {

        @Override
        public void handleAction(JSONObject params) throws ApiException {
            Context context = ApiUtils.getContextByParamId(params, AuthenticationAPI.PARAM_CONTEXT_ID);
            ManualAuthenticationMethod method = createAuthenticationMethod(context.getId());
            context.setAuthenticationMethod(method);
        }
    };
}
Also used : ApiDynamicActionImplementor(org.zaproxy.zap.extension.api.ApiDynamicActionImplementor) Context(org.zaproxy.zap.model.Context) JSONObject(net.sf.json.JSONObject)

Example 87 with Context

use of org.zaproxy.zap.model.Context in project zaproxy by zaproxy.

the class HttpAuthSessionManagementMethodType method getSetMethodForContextApiAction.

@Override
public ApiDynamicActionImplementor getSetMethodForContextApiAction() {
    return new ApiDynamicActionImplementor(API_METHOD_NAME, null, null) {

        @Override
        public void handleAction(JSONObject params) throws ApiException {
            Context context = ApiUtils.getContextByParamId(params, SessionManagementAPI.PARAM_CONTEXT_ID);
            context.setSessionManagementMethod(createSessionManagementMethod(context.getId()));
        }
    };
}
Also used : ApiDynamicActionImplementor(org.zaproxy.zap.extension.api.ApiDynamicActionImplementor) Context(org.zaproxy.zap.model.Context) JSONObject(net.sf.json.JSONObject)

Example 88 with Context

use of org.zaproxy.zap.model.Context in project zaproxy by zaproxy.

the class HostProcessUnitTest method isCustomPageShouldReturnTrueWhenCustomPageMatches.

@Test
void isCustomPageShouldReturnTrueWhenCustomPageMatches() {
    // Given
    Context context = mock(Context.class);
    hostProcess.setContext(context);
    HttpMessage msg = new HttpMessage();
    CustomPage.Type cpType = CustomPage.Type.OTHER;
    given(context.isCustomPage(msg, cpType)).willReturn(true);
    // When / Then
    assertTrue(hostProcess.isCustomPage(msg, cpType));
    verify(context).isCustomPage(msg, cpType);
}
Also used : Context(org.zaproxy.zap.model.Context) CustomPage(org.zaproxy.zap.extension.custompages.CustomPage) HttpMessage(org.parosproxy.paros.network.HttpMessage) Test(org.junit.jupiter.api.Test)

Example 89 with Context

use of org.zaproxy.zap.model.Context in project zaproxy by zaproxy.

the class HostProcessUnitTest method isCustomPageShouldReturnFalseWhenContextIsNull.

@Test
void isCustomPageShouldReturnFalseWhenContextIsNull() {
    // Given
    Context context = mock(Context.class);
    hostProcess.setContext(null);
    HttpMessage msg = new HttpMessage();
    CustomPage.Type cpType = CustomPage.Type.OTHER;
    // When / Then
    assertFalse(hostProcess.isCustomPage(msg, cpType));
    verifyNoInteractions(context);
}
Also used : Context(org.zaproxy.zap.model.Context) CustomPage(org.zaproxy.zap.extension.custompages.CustomPage) HttpMessage(org.parosproxy.paros.network.HttpMessage) Test(org.junit.jupiter.api.Test)

Aggregations

Context (org.zaproxy.zap.model.Context)89 ApiException (org.zaproxy.zap.extension.api.ApiException)22 Test (org.junit.jupiter.api.Test)21 ZapXmlConfiguration (org.zaproxy.zap.utils.ZapXmlConfiguration)17 WithConfigsTest (org.zaproxy.zap.WithConfigsTest)16 User (org.zaproxy.zap.users.User)15 JSONObject (net.sf.json.JSONObject)14 Configuration (org.apache.commons.configuration.Configuration)14 Session (org.parosproxy.paros.model.Session)14 ApiDynamicActionImplementor (org.zaproxy.zap.extension.api.ApiDynamicActionImplementor)13 RecordContext (org.parosproxy.paros.db.RecordContext)12 DatabaseException (org.parosproxy.paros.db.DatabaseException)10 ConfigurationException (org.apache.commons.configuration.ConfigurationException)9 HttpMessage (org.parosproxy.paros.network.HttpMessage)9 ExtensionUserManagement (org.zaproxy.zap.extension.users.ExtensionUserManagement)9 ArrayList (java.util.ArrayList)8 JMenuItem (javax.swing.JMenuItem)7 ExtensionPopupMenuItem (org.parosproxy.paros.extension.ExtensionPopupMenuItem)7 SiteNode (org.parosproxy.paros.model.SiteNode)7 IOException (java.io.IOException)6