Search in sources :

Example 1 with TestUser

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

the class SecHubExecutionScenarioSecHubClientIntTest method sechub_client_can_execute_a_config_file_which_uses_template_variables_of_environment_entries.

// we use startDownloadJobReport here - old implementation okay here
@SuppressWarnings("deprecation")
@Test
public void sechub_client_can_execute_a_config_file_which_uses_template_variables_of_environment_entries() {
    /* @formatter:off */
    /* prepare */
    TestProject project = PROJECT_3;
    TestUser user = USER_1;
    assertProject(project).hasNoWhiteListEntries();
    List<String> list = new ArrayList<>();
    as(SUPER_ADMIN).updateWhiteListForProject(project, list).assignUserToProject(user, project);
    Map<String, String> envEntries = new LinkedHashMap<>();
    envEntries.put("SHTEST_VERSION", "1.0");
    envEntries.put("SHTEST_FOLDERS1", IntegrationTestMockMode.CODE_SCAN__CHECKMARX__GREEN__FAST.getTarget());
    /* execute */
    IntegrationTestJSONLocation location = CLIENT_JSON_SOURCESCAN_GENERIC_TEMPLATE;
    UUID jobUUID = as(user).withSecHubClient().startAsynchronScanFor(project, location, envEntries).assertFileUploaded(project).assertJobTriggered().getJobUUID();
    waitForJobDoneAndFailWhenJobIsFailing(project, jobUUID);
    /* why test green result ? Because we set test folders in a way we
		 * will expect green traffic light - which is only the case when
		 * we have an explicit path set by the environment entry inside
		 * template... We could also rely on server validation of version
		 * but this way is better, because we rely on test environment /mocked
		 * adapter behavior which is well known.
		 */
    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) ArrayList(java.util.ArrayList) UUID(java.util.UUID) TestUser(com.mercedesbenz.sechub.integrationtest.api.TestUser) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 2 with TestUser

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

the class SecHubExecutionScenario2IntTest method when_user_exists_user_cannot_be_signed_in_again.

@Test
public void when_user_exists_user_cannot_be_signed_in_again() {
    /* @formatter:off */
    assertUser(USER_1).doesExist();
    /* already created */
    // signup is not existing
    assertSignup(USER_1).doesNotExist();
    TestUser newUser = new AnonymousTestUser(USER_1.getUserId(), "somewhere." + System.currentTimeMillis() + "@example.org");
    /* 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 3 with TestUser

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

the class SecHubExecutionScenarioSecHubClientIntTest method sechub_client_can_execute_a_config_file_which_uses_template_variables_of_environment_entries_but_no_data_section.

// we use startDownloadJobReport here - old implementation okay here
@SuppressWarnings("deprecation")
@Test
public void sechub_client_can_execute_a_config_file_which_uses_template_variables_of_environment_entries_but_no_data_section() {
    /* @formatter:off */
    /* prepare */
    TestProject project = PROJECT_3;
    TestUser user = USER_1;
    assertProject(project).hasNoWhiteListEntries();
    List<String> list = new ArrayList<>();
    as(SUPER_ADMIN).updateWhiteListForProject(project, list).assignUserToProject(user, project);
    Map<String, String> envEntries = new LinkedHashMap<>();
    envEntries.put("SHTEST_VERSION", "1.0");
    envEntries.put("SHTEST_FOLDERS1", IntegrationTestMockMode.CODE_SCAN__CHECKMARX__GREEN__1_SECOND_WAITING.getTarget());
    /* execute */
    IntegrationTestJSONLocation location = IntegrationTestJSONLocation.CLIENT_JSON_SOURCESCAN_GENERIC_TEMPLATE_NO_DATA_SECTION;
    UUID jobUUID = as(user).withSecHubClient().startAsynchronScanFor(project, location, envEntries).assertFileUploaded(project).assertJobTriggered().getJobUUID();
    waitForJobDoneAndFailWhenJobIsFailing(project, jobUUID);
    /* why test green result ? Because we set test folders in a way we
		 * will expect green traffic light - which is only the case when
		 * we have an explicit path set by the environment entry inside
		 * template... We could also rely on server validation of version
		 * but this way is better, because we rely on test environment /mocked
		 * adapter behavior which is well known.
		 */
    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) ArrayList(java.util.ArrayList) UUID(java.util.UUID) TestUser(com.mercedesbenz.sechub.integrationtest.api.TestUser) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 4 with TestUser

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

the class SecHubExecutionScenarioSecHubClientIntTest method a_project_having_no_white_list_entries_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_white_list_entries_but_no_problems_can_be_executed_as_codescan_and_results_green() {
    /* @formatter:off */
    /* prepare */
    TestProject project = PROJECT_3;
    TestUser user = USER_1;
    assertProject(project).hasNoWhiteListEntries();
    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).hasStatus(SecHubStatus.SUCCESS).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 5 with TestUser

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

the class UserAdministrationScenario2IntTest method user1_can_NOT_revoke_user_admin_rights.

@Test
public void user1_can_NOT_revoke_user_admin_rights() {
    /* prepare */
    TestUser adminUser = USER_2;
    as(SUPER_ADMIN).grantSuperAdminRightsTo(adminUser);
    assertUser(adminUser).isSuperAdmin();
    /* execute + test */
    assertUser(USER_1).canNotRevokeSuperAdminRightsFrom(adminUser, HttpStatus.FORBIDDEN);
}
Also used : 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