Search in sources :

Example 6 with Audit

use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.

the class AsqatasunOrchestratorImpl method auditPage.

@Override
public Audit auditPage(Contract contract, String pageUrl, String clientIp, Set<Parameter> parameterSet, Locale locale) {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Page audit on " + pageUrl);
        for (Parameter param : parameterSet) {
            LOGGER.debug("param " + param.getValue() + " " + param.getParameterElement().getParameterElementCode());
        }
    }
    Act act = createAct(contract, ScopeEnum.PAGE, clientIp);
    AuditTimeoutThread auditPageThread = new AuditPageThread(pageUrl, auditService, act, parameterSet, locale, delay);
    Audit audit = submitAuditAndLaunch(auditPageThread, act);
    return audit;
}
Also used : Audit(org.asqatasun.entity.audit.Audit) Parameter(org.asqatasun.entity.parameterization.Parameter)

Example 7 with Audit

use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.

the class AuditServiceImplTest method testAuditGroupOfPages.

/**
     * Test of auditPage method, of class AuditServiceImpl.
     */
public void testAuditGroupOfPages() {
    System.out.println("auditGroupOfPages");
    String siteUrl = "http://My.testUrl.org";
    String pageUrl = "http://My.testUrlPage1.org";
    Set<Parameter> paramSet = null;
    List<String> urlList = new ArrayList<>();
    urlList.add(pageUrl);
    AuditServiceImpl instance = initialiseAuditService();
    Audit auditCreateByAuditCommand = EasyMock.createMock(Audit.class);
    AuditCommand mockAuditCommand = EasyMock.createMock(AuditCommand.class);
    EasyMock.expect(mockAuditCommand.getAudit()).andReturn(auditCreateByAuditCommand).anyTimes();
    EasyMock.replay(mockAuditCommand);
    AuditCommandFactory mockAuditCommandFactory = EasyMock.createMock(AuditCommandFactory.class);
    EasyMock.expect(mockAuditCommandFactory.create(siteUrl, urlList, paramSet)).andReturn(mockAuditCommand).anyTimes();
    EasyMock.replay(mockAuditCommandFactory);
    instance.setAuditCommandFactory(mockAuditCommandFactory);
    // anyTimes the audit is created and set-up, the auditServiceThreadQueue is 
    // called to effectively launch the site audit
    AuditServiceThreadQueue mockAuditServiceThreadQueue = EasyMock.createMock(AuditServiceThreadQueue.class);
    mockAuditServiceThreadQueue.add(instance);
    EasyMock.expectLastCall().anyTimes();
    mockAuditServiceThreadQueue.addPageAudit(mockAuditCommand);
    EasyMock.expectLastCall().anyTimes();
    EasyMock.replay(mockAuditServiceThreadQueue);
    instance.setAuditServiceThreadQueue(mockAuditServiceThreadQueue);
    Audit result = instance.auditSite(siteUrl, urlList, paramSet);
    assertEquals(auditCreateByAuditCommand, result);
    EasyMock.verify(mockAuditServiceThreadQueue);
    EasyMock.verify(mockAuditCommand);
    EasyMock.verify(mockAuditCommandFactory);
}
Also used : Audit(org.asqatasun.entity.audit.Audit) AuditCommandFactory(org.asqatasun.service.command.factory.AuditCommandFactory) Parameter(org.asqatasun.entity.parameterization.Parameter) AuditCommand(org.asqatasun.service.command.AuditCommand)

Example 8 with Audit

use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.

the class AuditServiceImplTest method testAuditScenario.

/**
     * Test of auditPage method, of class AuditServiceImpl.
     */
public void testAuditScenario() {
    System.out.println("auditScenario");
    String scenarioName = "MyScenario";
    String scenario = "";
    AuditServiceImpl instance = initialiseAuditService();
    Audit auditCreateByAuditCommand = EasyMock.createMock(Audit.class);
    AuditCommand mockAuditCommand = EasyMock.createMock(AuditCommand.class);
    EasyMock.expect(mockAuditCommand.getAudit()).andReturn(auditCreateByAuditCommand).anyTimes();
    EasyMock.replay(mockAuditCommand);
    AuditCommandFactory mockAuditCommandFactory = EasyMock.createMock(AuditCommandFactory.class);
    EasyMock.expect(mockAuditCommandFactory.create(scenarioName, scenario, null)).andReturn(mockAuditCommand).anyTimes();
    EasyMock.replay(mockAuditCommandFactory);
    instance.setAuditCommandFactory(mockAuditCommandFactory);
    // anyTimes the audit is created and set-up, the auditServiceThreadQueue is 
    // called to effectively launch the pageUpload audit
    AuditServiceThreadQueue mockAuditServiceThreadQueue = EasyMock.createMock(AuditServiceThreadQueue.class);
    mockAuditServiceThreadQueue.add(instance);
    EasyMock.expectLastCall().anyTimes();
    mockAuditServiceThreadQueue.addScenarioAudit(mockAuditCommand);
    EasyMock.expectLastCall().anyTimes();
    EasyMock.replay(mockAuditServiceThreadQueue);
    instance.setAuditServiceThreadQueue(mockAuditServiceThreadQueue);
    Audit result = instance.auditScenario(scenarioName, scenario, null);
    assertEquals(auditCreateByAuditCommand, result);
    EasyMock.verify(mockAuditServiceThreadQueue);
    EasyMock.verify(mockAuditCommand);
    EasyMock.verify(mockAuditCommandFactory);
}
Also used : Audit(org.asqatasun.entity.audit.Audit) AuditCommandFactory(org.asqatasun.service.command.factory.AuditCommandFactory) AuditCommand(org.asqatasun.service.command.AuditCommand)

Example 9 with Audit

use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.

the class AuditServiceThreadImplTest method testGetAudit.

/**
     * Test of getAudit method, of class AuditServiceThreadImpl.
     */
public void testGetAudit() {
    System.out.println("getAudit");
    Audit audit = createMock(Audit.class);
    Audit auditReturnedByAuditCommand = createMock(Audit.class);
    AuditCommand mockAuditCommand = createMock(AuditCommand.class);
    expect(mockAuditCommand.getAudit()).andReturn(auditReturnedByAuditCommand);
    replay(mockAuditCommand);
    AuditServiceThreadImpl instance = initialiseAuditServiceThread(audit);
    assertEquals(audit, instance.getAudit());
    instance = initialiseAuditServiceThread(mockAuditCommand);
    assertEquals(auditReturnedByAuditCommand, instance.getAudit());
}
Also used : Audit(org.asqatasun.entity.audit.Audit) AuditCommand(org.asqatasun.service.command.AuditCommand)

Example 10 with Audit

use of org.asqatasun.entity.audit.Audit in project Asqatasun by Asqatasun.

the class AuditServiceThreadImplTest method testRun.

/**
     * Test of run method, of class AuditServiceThreadImpl.
     */
public void testRun() {
    System.out.println("run");
    Audit mockAudit = createMock(Audit.class);
    expect(mockAudit.getId()).andReturn(1l).anyTimes();
    AuditCommand mockAuditCommand = createMock(AuditCommand.class);
    mockAuditCommand.init();
    expectLastCall().once();
    mockAuditCommand.loadContent();
    expectLastCall().once();
    mockAuditCommand.adaptContent();
    expectLastCall().once();
    mockAuditCommand.process();
    expectLastCall().once();
    mockAuditCommand.consolidate();
    expectLastCall().once();
    mockAuditCommand.analyse();
    expectLastCall().once();
    expect(mockAuditCommand.getAudit()).andReturn(mockAudit).anyTimes();
    replay(mockAudit);
    replay(mockAuditCommand);
    AuditServiceThreadImpl instance = initialiseAuditServiceThread(mockAuditCommand);
    AuditServiceThreadListener auditServiceThreadListener = createMock(AuditServiceThreadListener.class);
    auditServiceThreadListener.auditCompleted(instance);
    expectLastCall().once();
    replay(auditServiceThreadListener);
    instance.add(auditServiceThreadListener);
    instance.run();
    verify(mockAudit);
    verify(mockAuditCommand);
    verify(auditServiceThreadListener);
}
Also used : Audit(org.asqatasun.entity.audit.Audit) AuditCommand(org.asqatasun.service.command.AuditCommand)

Aggregations

Audit (org.asqatasun.entity.audit.Audit)47 WebResource (org.asqatasun.entity.subject.WebResource)11 ForbiddenPageException (org.asqatasun.webapp.exception.ForbiddenPageException)10 Parameter (org.asqatasun.entity.parameterization.Parameter)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 Site (org.asqatasun.entity.subject.Site)7 AuditCommand (org.asqatasun.service.command.AuditCommand)7 ForbiddenUserException (org.asqatasun.webapp.exception.ForbiddenUserException)6 Secured (org.springframework.security.access.annotation.Secured)6 AuditCommandFactory (org.asqatasun.service.command.factory.AuditCommandFactory)5 Contract (org.asqatasun.webapp.entity.contract.Contract)5 Content (org.asqatasun.entity.audit.Content)4 ProcessResult (org.asqatasun.entity.audit.ProcessResult)4 Page (org.asqatasun.entity.subject.Page)4 AuditImpl (org.asqatasun.entity.audit.AuditImpl)3 SSP (org.asqatasun.entity.audit.SSP)2 Test (org.asqatasun.entity.reference.Test)2 ScenarioLoader (org.asqatasun.scenarioloader.ScenarioLoader)2 Act (org.asqatasun.webapp.entity.contract.Act)2 IOException (java.io.IOException)1