Improvements repository validation constraints (#626)

* Add html tag Validator on strings. Add string trim.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Revert unintended changes. Sonar issues.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Remove weired comment.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Raise EclipseLink due to validation problem.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fix permission.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Colour field test.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>

* Fix sonar issues.

Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2018-02-12 14:56:36 +01:00
committed by GitHub
parent 1a6ab123e3
commit d3cb9bb24d
89 changed files with 812 additions and 495 deletions

View File

@@ -728,7 +728,8 @@ public class MgmtDistributionSetResourceTest extends AbstractManagementApiIntegr
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest());
final DistributionSet toLongName = testdataFactory.generateDistributionSet(RandomStringUtils.randomAscii(80));
final DistributionSet toLongName = testdataFactory
.generateDistributionSet(RandomStringUtils.randomAlphanumeric(80));
mvc.perform(post("/rest/v1/distributionsets").content(JsonBuilder.distributionSets(Arrays.asList(toLongName)))
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest());

View File

@@ -539,7 +539,7 @@ public class MgmtDistributionSetTypeResourceTest extends AbstractManagementApiIn
.andExpect(status().isBadRequest());
final DistributionSetType toLongName = entityFactory.distributionSetType().create().key("test123")
.name(RandomStringUtils.randomAscii(80)).build();
.name(RandomStringUtils.randomAlphanumeric(80)).build();
mvc.perform(post("/rest/v1/distributionsettypes")
.content(JsonBuilder.distributionSetTypes(Arrays.asList(toLongName)))
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())

View File

@@ -431,7 +431,7 @@ public class MgmtSoftwareModuleResourceTest extends AbstractManagementApiIntegra
.andExpect(status().isBadRequest());
final SoftwareModule toLongName = entityFactory.softwareModule().create().type(osType)
.name(RandomStringUtils.randomAscii(80)).build();
.name(RandomStringUtils.randomAlphanumeric(80)).build();
mvc.perform(post("/rest/v1/softwaremodules").content(JsonBuilder.softwareModules(Arrays.asList(toLongName)))
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest());

View File

@@ -90,11 +90,10 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
}
private SoftwareModuleType createTestType() {
SoftwareModuleType testType = softwareModuleTypeManagement
.create(entityFactory.softwareModuleType().create().key("test123").name("TestName123")
.description("Desc123").maxAssignments(5));
testType = softwareModuleTypeManagement.update(
entityFactory.softwareModuleType().update(testType.getId()).description("Desc1234"));
SoftwareModuleType testType = softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create()
.key("test123").name("TestName123").description("Desc123").maxAssignments(5));
testType = softwareModuleTypeManagement
.update(entityFactory.softwareModuleType().update(testType.getId()).description("Desc1234"));
return testType;
}
@@ -251,8 +250,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
@Description("Checks the correct behaviour of /rest/v1/softwaremoduletypes/{ID} DELETE requests (soft delete scenario).")
public void deleteSoftwareModuleTypeUsed() throws Exception {
final SoftwareModuleType testType = createTestType();
softwareModuleManagement.create(
entityFactory.softwareModule().create().type(testType).name("name").version("version"));
softwareModuleManagement
.create(entityFactory.softwareModule().create().type(testType).name("name").version("version"));
assertThat(softwareModuleTypeManagement.count()).isEqualTo(4);
@@ -340,14 +339,13 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest());
mvc.perform(post("/rest/v1/softwaremoduletypes")
.content(
"[{\"description\":\"Desc123\",\"id\":9223372036854775807,\"key\":\"test123\",\"maxAssignments\":5}]")
mvc.perform(post("/rest/v1/softwaremoduletypes").content(
"[{\"description\":\"Desc123\",\"id\":9223372036854775807,\"key\":\"test123\",\"maxAssignments\":5}]")
.contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print())
.andExpect(status().isBadRequest());
final SoftwareModuleType toLongName = entityFactory.softwareModuleType().create().key("test123")
.name(RandomStringUtils.randomAscii(80)).build();
.name(RandomStringUtils.randomAlphanumeric(80)).build();
mvc.perform(
post("/rest/v1/softwaremoduletypes").content(JsonBuilder.softwareModuleTypes(Arrays.asList(toLongName)))
.contentType(MediaType.APPLICATION_JSON))
@@ -372,8 +370,8 @@ public class MgmtSoftwareModuleTypeResourceTest extends AbstractManagementApiInt
public void searchSoftwareModuleTypeRsql() throws Exception {
softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create().key("test123")
.name("TestName123").description("Desc123").maxAssignments(5));
softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create()
.key("test1234").name("TestName1234").description("Desc1234").maxAssignments(5));
softwareModuleTypeManagement.create(entityFactory.softwareModuleType().create().key("test1234")
.name("TestName1234").description("Desc1234").maxAssignments(5));
final String rsqlFindLikeDs1OrDs2 = "name==TestName123,name==TestName1234";

View File

@@ -713,8 +713,8 @@ public class MgmtTargetResourceTest extends AbstractManagementApiIntegrationTest
@Test
@Description("Verfies that a properties of new targets are validated as in allowed size range.")
public void createTargetWithInvalidPropertyBadRequest() throws Exception {
final Target test1 = entityFactory.target().create().controllerId("id1").name(RandomStringUtils.randomAscii(80))
.build();
final Target test1 = entityFactory.target().create().controllerId("id1")
.name(RandomStringUtils.randomAlphanumeric(80)).build();
final MvcResult mvcResult = mvc.perform(post(MgmtRestConstants.TARGET_V1_REQUEST_MAPPING)
.content(JsonBuilder.targets(Arrays.asList(test1), true)).contentType(MediaType.APPLICATION_JSON))