Search in sources :

Example 1 with TestExecutionProfileList

use of com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfileList in project sechub by mercedes-benz.

the class ProductExecutionProfileRestControllerRestDocTest method restDoc_admin_fetches_profiles_list.

@Test
@UseCaseRestDoc(useCase = UseCaseAdminFetchesExecutionProfileList.class)
public void restDoc_admin_fetches_profiles_list() throws Exception {
    /* prepare */
    String apiEndpoint = https(PORT_USED).buildAdminFetchesListOfProductExecutionProfiles();
    Class<? extends Annotation> useCase = UseCaseAdminFetchesExecutionProfileList.class;
    TestExecutionProfileList profileList = new TestExecutionProfileList();
    TestExecutionProfileListEntry entry1 = new TestExecutionProfileListEntry();
    entry1.description = "A short decription for profile1";
    entry1.id = "profile1";
    TestExecutionProfileListEntry entry2 = new TestExecutionProfileListEntry();
    entry2.description = "A short decription for profile2";
    entry2.id = "profile2";
    profileList.executionProfiles.add(entry1);
    profileList.executionProfiles.add(entry2);
    ProductExecutionProfilesList list = JSONConverter.get().fromJSON(ProductExecutionProfilesList.class, JSONConverter.get().toJSON(profileList));
    when(fetchListService.fetchProductExecutionProfileList()).thenReturn(list);
    /* execute + test @formatter:off */
    this.mockMvc.perform(get(apiEndpoint).contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andDo(defineRestService().with().useCaseData(useCase).tag(RestDocFactory.extractTag(apiEndpoint)).responseSchema(OpenApiSchema.EXECUTION_PROFILE_LIST.getSchema()).and().document(responseFields(fieldWithPath("type").description("Always `executorProfileList` as an identifier for the list"), fieldWithPath("executionProfiles[]." + PROPERTY_ID).description("The profile id"), fieldWithPath("executionProfiles[]." + PROPERTY_DESCRIPTION).description("A profile description"), fieldWithPath("executionProfiles[]." + PROPERTY_ENABLED).description("Enabled state of profile"))));
/* @formatter:on */
}
Also used : TestExecutionProfileListEntry(com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfileListEntry) UseCaseAdminFetchesExecutionProfileList(com.mercedesbenz.sechub.sharedkernel.usecases.admin.config.UseCaseAdminFetchesExecutionProfileList) TestExecutionProfileList(com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfileList) ProductExecutionProfilesList(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutionProfilesList) UseCaseRestDoc(com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseRestDoc) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest) Test(org.junit.Test)

Example 2 with TestExecutionProfileList

use of com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfileList in project sechub by mercedes-benz.

the class ExecutionProfileScenario1IntTest method administrator_can_fetch_execution_profile_list_and_list_contains_default_profile_1.

@Test
public void administrator_can_fetch_execution_profile_list_and_list_contains_default_profile_1() {
    /* execute */
    TestExecutionProfileList profiles = as(SUPER_ADMIN).fetchProductExecutionProfiles();
    /* test */
    for (TestExecutionProfileListEntry profileEntry : profiles.executionProfiles) {
        if (profileEntry.id.equals(ExecutionConstants.DEFAULT_EXECUTION_PROFILE_ID)) {
            return;
        }
    }
    fail("Default profile not found! Found only profiles:" + JSONConverter.get().toJSON(profiles));
}
Also used : TestExecutionProfileListEntry(com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfileListEntry) TestExecutionProfileList(com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfileList) Test(org.junit.Test)

Example 3 with TestExecutionProfileList

use of com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfileList in project sechub by mercedes-benz.

the class DataCollectorUtils method fetchProfileInformationAboutProject.

public static String fetchProfileInformationAboutProject(String profileId, UIContext uiContext) {
    StringBuilder sb = new StringBuilder();
    sb.append("Profiles:\n");
    DeveloperAdministration administration = uiContext.getAdministration();
    TestExecutionProfileList list = administration.fetchExecutionProfileList();
    for (TestExecutionProfileListEntry entry : list.executionProfiles) {
        TestExecutionProfile profile = administration.fetchExecutionProfile(entry.id);
        if (profile.projectIds.contains(profileId)) {
            sb.append("- ");
            sb.append(profile.id);
            if (profile.enabled) {
                sb.append("(enabled)");
            } else {
                sb.append("(disabled)");
            }
            sb.append("\n  with executor configurations:");
            /* @formatter:off */
            for (TestExecutorConfig config : profile.configurations) {
                sb.append("\n   *").append(config.name).append(", executor:").append(config.productIdentifier).append(" V").append(config.executorVersion).append(", enabled:").append(config.enabled).append(", uuid=").append(config.uuid);
            }
            /* @formatter:on */
            sb.append("\n");
        }
    }
    return sb.toString();
}
Also used : TestExecutionProfileListEntry(com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfileListEntry) TestExecutionProfileList(com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfileList) TestExecutionProfile(com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfile) DeveloperAdministration(com.mercedesbenz.sechub.developertools.admin.DeveloperAdministration) TestExecutorConfig(com.mercedesbenz.sechub.test.executorconfig.TestExecutorConfig)

Aggregations

TestExecutionProfileList (com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfileList)3 TestExecutionProfileListEntry (com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfileListEntry)3 Test (org.junit.Test)2 DeveloperAdministration (com.mercedesbenz.sechub.developertools.admin.DeveloperAdministration)1 ProductExecutionProfilesList (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutionProfilesList)1 UseCaseRestDoc (com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseRestDoc)1 UseCaseAdminFetchesExecutionProfileList (com.mercedesbenz.sechub.sharedkernel.usecases.admin.config.UseCaseAdminFetchesExecutionProfileList)1 TestExecutionProfile (com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfile)1 TestExecutorConfig (com.mercedesbenz.sechub.test.executorconfig.TestExecutorConfig)1 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)1