Search in sources :

Example 1 with ProductExecutionProfile

use of com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutionProfile in project sechub by mercedes-benz.

the class ProductExecutionProfileRestControllerRestDocTest method restdoc_admin_fetches_profile.

@Test
@UseCaseRestDoc(useCase = UseCaseAdminFetchesExecutionProfile.class)
public void restdoc_admin_fetches_profile() throws Exception {
    /* prepare */
    String apiEndpoint = https(PORT_USED).buildAdminFetchesProductExecutionProfile(PROFILE_ID.pathElement());
    Class<? extends Annotation> useCase = UseCaseAdminFetchesExecutionProfile.class;
    String profileId = "existing-profile-1";
    TestExecutionProfile testprofile = new TestExecutionProfile();
    testprofile.description = "a description";
    testprofile.enabled = true;
    UUID randomUUID = UUID.randomUUID();
    TestExecutorConfig configFromUser = new TestExecutorConfig();
    configFromUser.enabled = false;
    configFromUser.name = "New name";
    configFromUser.productIdentifier = ProductIdentifier.PDS_CODESCAN.name();
    configFromUser.executorVersion = 1;
    configFromUser.setup.baseURL = "https://product.example.com";
    configFromUser.setup.credentials.user = "env:EXAMPLE_USENAME";
    configFromUser.setup.credentials.password = "env:EXAMPLE_PASSWORD";
    configFromUser.uuid = randomUUID;
    TestExecutorSetupJobParam param1 = new TestExecutorSetupJobParam("example.key1", "A value but changed. Remark: the other parameter (example.key2) has been removed by this call");
    configFromUser.setup.jobParameters.add(param1);
    testprofile.configurations.add(configFromUser);
    testprofile.projectIds.add("project-1");
    testprofile.projectIds.add("project-2");
    ProductExecutionProfile profile = JSONConverter.get().fromJSON(ProductExecutionProfile.class, JSONConverter.get().toJSON(testprofile));
    when(fetchService.fetchProductExecutorConfig(profileId)).thenReturn(profile);
    /* execute + test @formatter:off */
    this.mockMvc.perform(get(apiEndpoint, profileId).contentType(MediaType.APPLICATION_JSON_VALUE)).andExpect(status().isOk()).andDo(defineRestService().with().useCaseData(useCase).tag(RestDocFactory.extractTag(apiEndpoint)).responseSchema(OpenApiSchema.EXECUTION_PROFILE_FETCH.getSchema()).and().document(responseFields(fieldWithPath(PROPERTY_ID).optional().ignored(), fieldWithPath(PROPERTY_DESCRIPTION).description("A short description for the profile"), fieldWithPath(PROPERTY_ENABLED).description("Enabled state of profile, default is false").optional(), fieldWithPath(PROPERTY_CONFIGURATIONS + "[]." + ProductExecutorConfig.PROPERTY_UUID).description("uuid of configuration"), fieldWithPath(PROPERTY_CONFIGURATIONS + "[]." + ProductExecutorConfig.PROPERTY_NAME).description("name of configuration"), fieldWithPath(PROPERTY_CONFIGURATIONS + "[]." + ProductExecutorConfig.PROPERTY_ENABLED).description("enabled state of this config"), fieldWithPath(PROPERTY_CONFIGURATIONS + "[]." + ProductExecutorConfig.PROPERTY_PRODUCTIDENTIFIER).description("executed product"), fieldWithPath(PROPERTY_CONFIGURATIONS + "[]." + ProductExecutorConfig.PROPERTY_EXECUTORVERSION).description("executor version"), fieldWithPath(PROPERTY_CONFIGURATIONS + "[]." + ProductExecutorConfig.PROPERTY_SETUP + "." + ProductExecutorConfigSetup.PROPERTY_BASEURL).ignored(), fieldWithPath(PROPERTY_CONFIGURATIONS + "[]." + ProductExecutorConfig.PROPERTY_SETUP + "." + ProductExecutorConfigSetup.PROPERTY_CREDENTIALS + "." + ProductExecutorConfigSetupCredentials.PROPERTY_USER).ignored(), fieldWithPath(PROPERTY_CONFIGURATIONS + "[]." + ProductExecutorConfig.PROPERTY_SETUP + "." + ProductExecutorConfigSetup.PROPERTY_CREDENTIALS + "." + ProductExecutorConfigSetupCredentials.PROPERTY_PASSWORD).ignored(), fieldWithPath(PROPERTY_CONFIGURATIONS + "[]." + ProductExecutorConfig.PROPERTY_SETUP + "." + ProductExecutorConfigSetup.PROPERTY_JOBPARAMETERS + "[]." + ProductExecutorConfigSetupJobParameter.PROPERTY_KEY).ignored(), fieldWithPath(PROPERTY_CONFIGURATIONS + "[]." + ProductExecutorConfig.PROPERTY_SETUP + "." + ProductExecutorConfigSetup.PROPERTY_JOBPARAMETERS + "[]." + ProductExecutorConfigSetupJobParameter.PROPERTY_VALUE).ignored(), fieldWithPath(PROPERTY_PROJECT_IDS + "[]").description("Projects can be linked by their ids here")), pathParameters(parameterWithName(PROFILE_ID.paramName()).description("The profile id"))));
/* @formatter:on */
}
Also used : TestExecutionProfile(com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfile) ProductExecutionProfile(com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutionProfile) TestExecutorConfig(com.mercedesbenz.sechub.test.executorconfig.TestExecutorConfig) TestExecutorSetupJobParam(com.mercedesbenz.sechub.test.executorconfig.TestExecutorSetupJobParam) UUID(java.util.UUID) UseCaseAdminFetchesExecutionProfile(com.mercedesbenz.sechub.sharedkernel.usecases.admin.config.UseCaseAdminFetchesExecutionProfile) UseCaseRestDoc(com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseRestDoc) WebMvcTest(org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest) Test(org.junit.Test)

Aggregations

ProductExecutionProfile (com.mercedesbenz.sechub.domain.scan.product.config.ProductExecutionProfile)1 UseCaseRestDoc (com.mercedesbenz.sechub.sharedkernel.usecases.UseCaseRestDoc)1 UseCaseAdminFetchesExecutionProfile (com.mercedesbenz.sechub.sharedkernel.usecases.admin.config.UseCaseAdminFetchesExecutionProfile)1 TestExecutionProfile (com.mercedesbenz.sechub.test.executionprofile.TestExecutionProfile)1 TestExecutorConfig (com.mercedesbenz.sechub.test.executorconfig.TestExecutorConfig)1 TestExecutorSetupJobParam (com.mercedesbenz.sechub.test.executorconfig.TestExecutorSetupJobParam)1 UUID (java.util.UUID)1 Test (org.junit.Test)1 WebMvcTest (org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest)1