use of org.ligoj.app.model.Project in project ligoj-api by ligoj.
the class ProjectResourceTest method updateInvalidDescription2.
/**
* Create with invalid HTML content.
*/
@Test
public void updateInvalidDescription2() {
create();
final Project project = repository.findByName("Name");
final ProjectEditionVo vo = new ProjectEditionVo();
vo.setId(project.getId());
vo.setName("Name");
vo.setDescription("Description<script >Bad there</script>");
vo.setPkey("artifact-id");
vo.setTeamLeader(DEFAULT_USER);
Assertions.assertThrows(ConstraintViolationException.class, () -> resource.update(vo));
}
use of org.ligoj.app.model.Project in project ligoj-api by ligoj.
the class ProjectResourceTest method findByIdVisibleSinceAdmin.
/**
* test {@link ProjectResource#findById(int)}
*/
@Test
public void findByIdVisibleSinceAdmin() {
initSpringSecurityContext("admin");
final Project byName = repository.findByName("gStack");
Assertions.assertThrows(BusinessException.class, () -> {
resource.findById(byName.getId());
});
}
use of org.ligoj.app.model.Project in project ligoj-api by ligoj.
the class ProjectResourceTest method updateInvalidDescription.
/**
* Create with invalid HTML content.
*/
@Test
public void updateInvalidDescription() {
create();
final Project project = repository.findByName("Name");
final ProjectEditionVo vo = new ProjectEditionVo();
vo.setId(project.getId());
vo.setName("Name");
vo.setDescription("Description<script some=\"..\">Bad there</script>");
vo.setPkey("artifact-id");
vo.setTeamLeader(DEFAULT_USER);
Assertions.assertThrows(ConstraintViolationException.class, () -> resource.update(vo));
vo.setDescription("Description<script >Bad there</script>");
Assertions.assertThrows(ConstraintViolationException.class, () -> resource.update(vo));
}
use of org.ligoj.app.model.Project in project ligoj-api by ligoj.
the class SubscriptionResourceTest method newCreateVoBadParameters.
private SubscriptionEditionVo newCreateVoBadParameters() {
em.createQuery("DELETE Parameter WHERE id LIKE ?1").setParameter(1, "c_%").executeUpdate();
final Project project = new Project();
project.setName("TEST");
project.setPkey("test");
project.setTeamLeader(getAuthenticationName());
em.persist(project);
em.flush();
em.clear();
final SubscriptionEditionVo vo = new SubscriptionEditionVo();
final List<ParameterValueCreateVo> parameters = new ArrayList<>();
final ParameterValueCreateVo parameterValueEditionVo = new ParameterValueCreateVo();
parameterValueEditionVo.setParameter("service:bt:jira:project");
parameterValueEditionVo.setInteger(1007400);
parameters.add(parameterValueEditionVo);
vo.setParameters(parameters);
vo.setNode("service:bt:jira:4");
vo.setProject(project.getId());
return vo;
}
use of org.ligoj.app.model.Project in project ligoj-api by ligoj.
the class SubscriptionResourceTest method createNotSubscribeRight.
@Test
public void createNotSubscribeRight() {
// This users sees only Jenkins nodes
initSpringSecurityContext("user1");
// Make the project visible for this user
final Project project = projectRepository.findByName("gStack");
project.setTeamLeader("user1");
em.merge(project);
final SubscriptionEditionVo vo = new SubscriptionEditionVo();
vo.setNode("service:bt:jira:4");
vo.setProject(project.getId());
em.flush();
em.clear();
// Ensure LDAP cache is loaded
em.flush();
em.clear();
Assertions.assertThrows(ValidationJsonException.class, () -> resource.create(vo));
}
Aggregations