Search in sources :

Example 11 with TestUser

use of com.mercedesbenz.sechub.integrationtest.api.TestUser in project sechub by mercedes-benz.

the class DeveloperAdministration method createAsUserTestObject.

/**
 * Creates temporary test user object and provides direct access to integration
 * test object: AsUser. So all things available in integration tests can be done
 * directly without additional methods
 *
 * @return asUser object
 */
AsUser createAsUserTestObject() {
    String user = provider.getUser();
    String token = provider.getApiToken();
    TestUser testUser = new FixedTestUser(user, token);
    return TestAPI.as(testUser);
}
Also used : FixedTestUser(com.mercedesbenz.sechub.integrationtest.api.FixedTestUser) FixedTestUser(com.mercedesbenz.sechub.integrationtest.api.FixedTestUser) TestUser(com.mercedesbenz.sechub.integrationtest.api.TestUser)

Example 12 with TestUser

use of com.mercedesbenz.sechub.integrationtest.api.TestUser in project sechub by mercedes-benz.

the class FullScanDataScenario3SecHubClientIntTest method user_1_starts_job_but_only_admin_can_download_scanlog_or_fullscan_data.

@Test
public void user_1_starts_job_but_only_admin_can_download_scanlog_or_fullscan_data() throws IOException {
    /* prepare - just execute a job */
    TestUser user = USER_1;
    TestProject project = PROJECT_1;
    ExecutionResult result = as(user).withSecHubClient().startSynchronScanFor(project, CLIENT_JSON_SOURCESCAN_GREEN_ZERO_WAIT);
    UUID sechubJobUUID = result.getSechubJobUUID();
    assertNotNull("No sechub jobUUId found-maybe client call failed?", sechubJobUUID);
    /* exeucte (1) - admin can download scan logs */
    String json = as(SUPER_ADMIN).getScanLogsForProject(project);
    /* test */
    assertNotNull(json);
    assertTrue(json.contains(sechubJobUUID.toString()));
    assertTrue(json.contains(user.getUserId()));
    /* execute (2) - admin can download full scan data */
    File scanDataZipFile = as(SUPER_ADMIN).downloadFullScanDataFor(sechubJobUUID);
    /* execute */
    AssertFullScanData assertFullScanData = assertFullScanDataZipFile(scanDataZipFile);
    /* test @formatter:off*/
    assertFullScanData.dumpDownloadFilePath().containsFile("CHECKMARX_" + IntegrationTestDefaultExecutorConfigurations.CHECKMARX_V1.uuid + ".xml").containsFile("metadata_CHECKMARX_" + IntegrationTestDefaultExecutorConfigurations.CHECKMARX_V1.uuid + ".json").containsFile("metadata_SERECO.json").containsFile("SERECO.json").containsFiles(5);
    FullScanDataElement log = assertFullScanData.resolveFileStartingWith("log_");
    assertTrue(log.content.contains("executedBy=" + user.getUserId()));
    assertTrue(log.content.contains("projectId=" + project.getProjectId()));
    /* execute (3) + test - user cannot donload logs or full scan data*/
    expectHttpFailure(() -> as(user).getScanLogsForProject(project), HttpStatus.FORBIDDEN);
    expectHttpFailure(() -> as(user).downloadFullScanDataFor(sechubJobUUID), HttpStatus.FORBIDDEN);
/* execute */
}
Also used : TestProject(com.mercedesbenz.sechub.integrationtest.api.TestProject) AssertFullScanData(com.mercedesbenz.sechub.integrationtest.api.AssertFullScanData) ExecutionResult(com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult) FullScanDataElement(com.mercedesbenz.sechub.integrationtest.api.AssertFullScanData.FullScanDataElement) UUID(java.util.UUID) TestUser(com.mercedesbenz.sechub.integrationtest.api.TestUser) File(java.io.File) Test(org.junit.Test)

Example 13 with TestUser

use of com.mercedesbenz.sechub.integrationtest.api.TestUser in project sechub by mercedes-benz.

the class SecHubExecutionScenario2IntTest method when_another_user_has_got_the_email_used_for_signup_but_different_name_user_cannot_be_signed_in_again.

@Test
public void when_another_user_has_got_the_email_used_for_signup_but_different_name_user_cannot_be_signed_in_again() {
    /* @formatter:off */
    assertUser(USER_1).doesExist();
    /* already created */
    String name = "u_" + System.currentTimeMillis();
    if (name.length() > 15 || name.length() < 5) {
        throw new IllegalStateException("testcase corrupt - name invalid:" + name + ". Testcase checks only for same email recognized. Name must be correct here!");
    }
    TestUser newUser = new AnonymousTestUser(name, USER_1.getEmail());
    /* execute + test */
    expectHttpFailure(() -> as(ANONYMOUS).signUpAs(newUser), HttpStatus.NOT_ACCEPTABLE);
/* @formatter:on */
}
Also used : AnonymousTestUser(com.mercedesbenz.sechub.integrationtest.api.AnonymousTestUser) AnonymousTestUser(com.mercedesbenz.sechub.integrationtest.api.AnonymousTestUser) TestUser(com.mercedesbenz.sechub.integrationtest.api.TestUser) Test(org.junit.Test)

Example 14 with TestUser

use of com.mercedesbenz.sechub.integrationtest.api.TestUser in project sechub by mercedes-benz.

the class SecHubExecutionScenarioSecHubClientIntTest method a_project_having_no_metadata_but_no_problems_can_be_executed_as_codescan_and_results_green.

// we use startDownloadJobReport here - old implementation okay here
@SuppressWarnings("deprecation")
@Test
public void a_project_having_no_metadata_but_no_problems_can_be_executed_as_codescan_and_results_green() {
    /* @formatter:off */
    /* prepare */
    TestProject project = PROJECT_3;
    TestUser user = USER_1;
    assertProject(project).hasNoMetaData();
    as(SUPER_ADMIN).assignUserToProject(user, project);
    /* execute */
    IntegrationTestJSONLocation location = CLIENT_JSON_SOURCESCAN_GREEN_ZERO_WAIT;
    UUID jobUUID = as(user).withSecHubClient().startAsynchronScanFor(project, location).assertFileUploaded(project).assertJobTriggered().getJobUUID();
    waitForJobDoneAndFailWhenJobIsFailing(project, jobUUID);
    as(user).withSecHubClient().startDownloadJobReport(project, jobUUID, location).hasTrafficLight(TrafficLight.GREEN);
/* @formatter:on */
}
Also used : TestProject(com.mercedesbenz.sechub.integrationtest.api.TestProject) IntegrationTestJSONLocation(com.mercedesbenz.sechub.integrationtest.api.IntegrationTestJSONLocation) UUID(java.util.UUID) TestUser(com.mercedesbenz.sechub.integrationtest.api.TestUser) Test(org.junit.Test)

Example 15 with TestUser

use of com.mercedesbenz.sechub.integrationtest.api.TestUser in project sechub by mercedes-benz.

the class SecHubExecutionScenarioSecHubClientIntTest method a_project_having_metadata_updated_no_problems_can_be_executed_as_codescan_and_results_green.

// we use startDownloadJobReport here - old implementation okay here
@SuppressWarnings("deprecation")
@Test
public void a_project_having_metadata_updated_no_problems_can_be_executed_as_codescan_and_results_green() {
    /* @formatter:off */
    /* prepare */
    TestProject project = PROJECT_3;
    TestUser user = USER_1;
    assertProject(project).hasNoMetaData();
    Map<String, String> metaData = new HashMap<>();
    metaData.put("key1", "value1");
    // add first metaDataEntry
    as(SUPER_ADMIN).assignUserToProject(user, project).updateMetaDataForProject(project, metaData);
    assertProject(project).hasMetaData(metaData);
    // add additional entry
    metaData.put("key2", "value2");
    as(SUPER_ADMIN).updateMetaDataForProject(project, metaData);
    assertProject(project).hasMetaData(metaData);
    // update one entry
    metaData.put("key1", "updatedValue");
    as(SUPER_ADMIN).updateMetaDataForProject(project, metaData);
    assertProject(project).hasMetaData(metaData);
    // remove all entries
    metaData.clear();
    as(SUPER_ADMIN).updateMetaDataForProject(project, metaData);
    assertProject(project).hasNoMetaData();
    /* execute */
    IntegrationTestJSONLocation location = CLIENT_JSON_SOURCESCAN_GREEN_ZERO_WAIT;
    UUID jobUUID = as(user).withSecHubClient().startAsynchronScanFor(project, location).assertFileUploaded(project).assertJobTriggered().getJobUUID();
    waitForJobDoneAndFailWhenJobIsFailing(project, jobUUID);
    as(user).withSecHubClient().startDownloadJobReport(project, jobUUID, location).hasTrafficLight(TrafficLight.GREEN);
/* @formatter:on */
}
Also used : TestProject(com.mercedesbenz.sechub.integrationtest.api.TestProject) IntegrationTestJSONLocation(com.mercedesbenz.sechub.integrationtest.api.IntegrationTestJSONLocation) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) UUID(java.util.UUID) TestUser(com.mercedesbenz.sechub.integrationtest.api.TestUser) Test(org.junit.Test)

Aggregations

TestUser (com.mercedesbenz.sechub.integrationtest.api.TestUser)20 Test (org.junit.Test)16 TestProject (com.mercedesbenz.sechub.integrationtest.api.TestProject)11 UUID (java.util.UUID)9 IntegrationTestJSONLocation (com.mercedesbenz.sechub.integrationtest.api.IntegrationTestJSONLocation)8 LinkedHashMap (java.util.LinkedHashMap)4 ArrayList (java.util.ArrayList)3 AnonymousTestUser (com.mercedesbenz.sechub.integrationtest.api.AnonymousTestUser)2 HashMap (java.util.HashMap)2 AssertFullScanData (com.mercedesbenz.sechub.integrationtest.api.AssertFullScanData)1 FullScanDataElement (com.mercedesbenz.sechub.integrationtest.api.AssertFullScanData.FullScanDataElement)1 FixedTestUser (com.mercedesbenz.sechub.integrationtest.api.FixedTestUser)1 ExecutionResult (com.mercedesbenz.sechub.integrationtest.internal.SecHubClientExecutor.ExecutionResult)1 File (java.io.File)1