Search in sources :

Example 6 with Project

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));
}
Also used : Project(org.ligoj.app.model.Project) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest) Test(org.junit.jupiter.api.Test)

Example 7 with Project

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());
    });
}
Also used : Project(org.ligoj.app.model.Project) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest) Test(org.junit.jupiter.api.Test)

Example 8 with Project

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));
}
Also used : Project(org.ligoj.app.model.Project) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest) Test(org.junit.jupiter.api.Test)

Example 9 with Project

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;
}
Also used : Project(org.ligoj.app.model.Project) ParameterValueCreateVo(org.ligoj.app.resource.node.ParameterValueCreateVo) ArrayList(java.util.ArrayList)

Example 10 with Project

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));
}
Also used : Project(org.ligoj.app.model.Project) Test(org.junit.jupiter.api.Test) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest)

Aggregations

Project (org.ligoj.app.model.Project)21 Test (org.junit.jupiter.api.Test)12 AbstractOrgTest (org.ligoj.app.resource.AbstractOrgTest)9 Subscription (org.ligoj.app.model.Subscription)6 SubscriptionVo (org.ligoj.app.resource.subscription.SubscriptionVo)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Node (org.ligoj.app.model.Node)2 Parameter (org.ligoj.app.model.Parameter)2 ParameterValue (org.ligoj.app.model.ParameterValue)2 EventVo (org.ligoj.app.resource.node.EventVo)2 Comparator (java.util.Comparator)1 Date (java.util.Date)1 List (java.util.List)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Function (java.util.function.Function)1 Collectors (java.util.stream.Collectors)1 DELETE (javax.ws.rs.DELETE)1