Search in sources :

Example 6 with Model

use of org.parosproxy.paros.model.Model in project zaproxy by zaproxy.

the class SessionStructure method find.

/**
 * Finds the node in the Site tree for the given request data
 *
 * @param sessionId the session id
 * @param uri the URI
 * @param method the method
 * @param postData the POST data
 * @return the site node or null if not found
 * @throws DatabaseException
 * @throws URIException
 * @depreciated Use {@link #find(Model, URI, String, String)}
 */
@Deprecated
public static StructuralNode find(long sessionId, URI uri, String method, String postData) throws DatabaseException, URIException {
    Model model = Model.getSingleton();
    if (!Constant.isLowMemoryOptionSet()) {
        SiteNode node = model.getSession().getSiteTree().findNode(uri, method, postData);
        if (node == null) {
            return null;
        }
        return new StructuralSiteNode(node);
    }
    String nodeName = getNodeName(model, uri, method, postData);
    RecordStructure rs = model.getDb().getTableStructure().find(sessionId, nodeName, method);
    if (rs == null) {
        return null;
    }
    return new StructuralTableNode(rs);
}
Also used : RecordStructure(org.parosproxy.paros.db.RecordStructure) Model(org.parosproxy.paros.model.Model) SiteNode(org.parosproxy.paros.model.SiteNode)

Example 7 with Model

use of org.parosproxy.paros.model.Model in project zaproxy by zaproxy.

the class WithConfigsTest method setUpZap.

/**
 * Sets up ZAP, by initialising the home/installation dirs and core classes (for example, {@link
 * Constant}, {@link Control}, {@link Model}).
 *
 * @throws Exception if an error occurred while setting up the dirs or core classes.
 */
@BeforeEach
void setUpZap() throws Exception {
    Constant.setZapInstall(zapInstallDir);
    Constant.setZapHome(zapHomeDir);
    model = mock(Model.class, withSettings().defaultAnswer(CALLS_REAL_METHODS));
    Model.setSingletonForTesting(model);
    extensionLoader = mock(ExtensionLoader.class, withSettings().lenient());
    // Init all the things
    Constant.getInstance();
    setUpConstantMessages();
    Control.initSingletonForTesting(Model.getSingleton(), extensionLoader);
    Model.getSingleton().getOptionsParam().load(new ZapXmlConfiguration());
}
Also used : Model(org.parosproxy.paros.model.Model) ZapXmlConfiguration(org.zaproxy.zap.utils.ZapXmlConfiguration) ExtensionLoader(org.parosproxy.paros.extension.ExtensionLoader) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Model (org.parosproxy.paros.model.Model)7 BeforeEach (org.junit.jupiter.api.BeforeEach)3 DatabaseException (org.parosproxy.paros.db.DatabaseException)3 Session (org.parosproxy.paros.model.Session)3 URI (org.apache.commons.httpclient.URI)2 URIException (org.apache.commons.httpclient.URIException)2 SiteNode (org.parosproxy.paros.model.SiteNode)2 StructuralNode (org.zaproxy.zap.model.StructuralNode)2 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 TreeSet (java.util.TreeSet)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 JFileChooser (javax.swing.JFileChooser)1 FileFilter (javax.swing.filechooser.FileFilter)1 TreeNode (javax.swing.tree.TreeNode)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1