use of com.mercedesbenz.sechub.domain.administration.project.ProjectJsonInput.ProjectWhiteList in project sechub by mercedes-benz.
the class ProjectAdministrationRestController method createProject.
/* @formatter:off */
@UseCaseAdminCreatesProject(@Step(number = 1, name = "Rest call", needsRestDoc = true, description = "Administrator creates a new project by calling rest api"))
@RequestMapping(path = AdministrationAPIConstants.API_CREATE_PROJECT, method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE })
@ResponseStatus(HttpStatus.CREATED)
public void createProject(@RequestBody @Valid ProjectJsonInput input) {
Set<URI> whiteListedURIs = new LinkedHashSet<>();
Optional<ProjectWhiteList> whitelistOption = input.getWhiteList();
if (whitelistOption.isPresent()) {
ProjectWhiteList whiteList = whitelistOption.get();
whiteListedURIs.addAll(whiteList.getUris());
}
ProjectMetaData metaData = new ProjectMetaData();
if (input.getMetaData().isPresent()) {
metaData = input.getMetaData().get();
}
/* @formatter:on */
creationService.createProject(input.getName(), input.getDescription(), input.getOwner(), whiteListedURIs, metaData);
}
use of com.mercedesbenz.sechub.domain.administration.project.ProjectJsonInput.ProjectWhiteList in project sechub by mercedes-benz.
the class ProjectJsonInputValidationTest method when_whitelisturivalidation_with_empty_uri_invalid_api_error.
@Test
public void when_whitelisturivalidation_with_empty_uri_invalid_api_error() throws URISyntaxException {
/* prepare */
ProjectWhiteList whiteList = new ProjectWhiteList();
whiteList.getUris().add(URI.create(""));
when(input.getWhiteList()).thenReturn(Optional.of(whiteList));
when(whiteListValidation.validate(any())).thenReturn(failedResult);
/* execute */
toTest.checkWhitelist(errors, input);
/* test */
verify(errors, never()).rejectValue(eq(ProjectJsonInput.PROPERTY_WHITELIST), eq("api.error.whitelist.invalid"), any());
}
use of com.mercedesbenz.sechub.domain.administration.project.ProjectJsonInput.ProjectWhiteList in project sechub by mercedes-benz.
the class ProjectUpdateAdministrationRestController method updateProjectWhitelist.
/* @formatter:off */
@UseCaseUpdateProjectWhitelist(@Step(number = 1, name = "Rest call", description = "White list will be updated", needsRestDoc = true))
@RequestMapping(path = AdministrationAPIConstants.API_UPDATE_PROJECT_WHITELIST, method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_VALUE })
public void updateProjectWhitelist(@Validated @RequestBody ProjectJsonInput input, @PathVariable(name = "projectId") String projectId) {
/* @formatter:on */
Optional<ProjectWhiteList> projectWhiteList = input.getWhiteList();
List<URI> whiteList;
if (projectWhiteList.isPresent()) {
ProjectWhiteList r = projectWhiteList.get();
whiteList = r.getUris();
} else {
whiteList = Collections.emptyList();
}
updateProjectWhitelistService.updateProjectWhitelist(projectId, whiteList);
}
use of com.mercedesbenz.sechub.domain.administration.project.ProjectJsonInput.ProjectWhiteList in project sechub by mercedes-benz.
the class ProjectJsonInputTestMain method main.
public static void main(String[] args) {
ProjectJsonInput input = new ProjectJsonInput();
input.setApiVersion("1.0");
input.setDescription("description");
ProjectWhiteList list = new ProjectWhiteList();
list.getUris().add(URI.create("https://localhost/test"));
Optional<ProjectWhiteList> whitelist = Optional.of(list);
input.setWhiteList(whitelist);
Map<String, String> metaData = new HashMap<>();
metaData.put("key1", "value1");
input.setMetaData(Optional.of(metaData));
System.out.println(input.toJSON());
}
Aggregations