Search in sources :

Example 11 with DelegateNode

use of org.ligoj.app.model.DelegateNode in project ligoj-api by ligoj.

the class DelegateNodeResourceTest method createSubNode.

@Test
public void createSubNode() {
    initSpringSecurityContext("user1");
    final DelegateNode delegate = new DelegateNode();
    delegate.setNode("service:build:jenkins:dig");
    delegate.setReceiver("user1");
    Assertions.assertTrue(resource.create(delegate) > 0);
}
Also used : DelegateNode(org.ligoj.app.model.DelegateNode) AbstractJpaTest(org.ligoj.bootstrap.AbstractJpaTest) Test(org.junit.jupiter.api.Test)

Example 12 with DelegateNode

use of org.ligoj.app.model.DelegateNode in project ligoj-api by ligoj.

the class DelegateNodeResourceTest method updateNoChange.

@Test
public void updateNoChange() {
    // Add a special right on for a node
    final DelegateNode delegate = new DelegateNode();
    delegate.setNode("service:build:jenkins");
    delegate.setReceiver("user2");
    delegate.setCanAdmin(true);
    repository.saveAndFlush(delegate);
    initSpringSecurityContext("user2");
    final DelegateNode newDelegate = new DelegateNode();
    newDelegate.setNode("service:build:jenkins");
    newDelegate.setReceiver("user2");
    newDelegate.setCanAdmin(true);
    resource.update(newDelegate);
}
Also used : DelegateNode(org.ligoj.app.model.DelegateNode) AbstractJpaTest(org.ligoj.bootstrap.AbstractJpaTest) Test(org.junit.jupiter.api.Test)

Example 13 with DelegateNode

use of org.ligoj.app.model.DelegateNode in project ligoj-api by ligoj.

the class DelegateNodeResourceTest method createWriteNotAdmin.

@Test
public void createWriteNotAdmin() {
    // Add a special right on for a node
    final DelegateNode delegate = new DelegateNode();
    delegate.setNode("service:build:jenkins");
    delegate.setReceiver("user2");
    delegate.setCanWrite(true);
    repository.saveAndFlush(delegate);
    initSpringSecurityContext("user2");
    final DelegateNode newDelegate = new DelegateNode();
    newDelegate.setNode("service:build:jenkins:dig");
    newDelegate.setReceiver("user2");
    Assertions.assertThrows(NotFoundException.class, () -> {
        resource.create(newDelegate);
    });
}
Also used : DelegateNode(org.ligoj.app.model.DelegateNode) AbstractJpaTest(org.ligoj.bootstrap.AbstractJpaTest) Test(org.junit.jupiter.api.Test)

Example 14 with DelegateNode

use of org.ligoj.app.model.DelegateNode in project ligoj-api by ligoj.

the class DelegateNodeResourceTest method createGrantRefused.

@Test
public void createGrantRefused() {
    // Add a special right on for a node
    final DelegateNode delegate = new DelegateNode();
    delegate.setNode("service:build:jenkins");
    delegate.setReceiver("user2");
    delegate.setCanAdmin(true);
    repository.saveAndFlush(delegate);
    initSpringSecurityContext("user2");
    final DelegateNode newDelegate = new DelegateNode();
    newDelegate.setNode("service:build:jenkins:dig");
    newDelegate.setReceiver("user2");
    newDelegate.setCanWrite(true);
    Assertions.assertThrows(javax.ws.rs.NotFoundException.class, () -> {
        resource.create(newDelegate);
    });
}
Also used : DelegateNode(org.ligoj.app.model.DelegateNode) AbstractJpaTest(org.ligoj.bootstrap.AbstractJpaTest) Test(org.junit.jupiter.api.Test)

Example 15 with DelegateNode

use of org.ligoj.app.model.DelegateNode in project ligoj-api by ligoj.

the class DelegateNodeResourceTest method updateSubNodeReduceRight.

@Test
public void updateSubNodeReduceRight() {
    // Add a special right on for a node
    final DelegateNode delegate = new DelegateNode();
    delegate.setNode("service:build:jenkins");
    delegate.setReceiver("user2");
    delegate.setCanAdmin(true);
    repository.saveAndFlush(delegate);
    initSpringSecurityContext("user2");
    final DelegateNode newDelegate = new DelegateNode();
    newDelegate.setNode("service:build:jenkins");
    newDelegate.setReceiver("user2");
    resource.update(newDelegate);
}
Also used : DelegateNode(org.ligoj.app.model.DelegateNode) AbstractJpaTest(org.ligoj.bootstrap.AbstractJpaTest) Test(org.junit.jupiter.api.Test)

Aggregations

DelegateNode (org.ligoj.app.model.DelegateNode)15 Test (org.junit.jupiter.api.Test)14 AbstractJpaTest (org.ligoj.bootstrap.AbstractJpaTest)14 GET (javax.ws.rs.GET)1 UriInfo (javax.ws.rs.core.UriInfo)1 PageRequest (org.springframework.data.domain.PageRequest)1