Search in sources :

Example 1 with DelegateOrg

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

the class DelegateOrgResourceTest method createDelegateCompanyReceiverCompany.

@Test
public void createDelegateCompanyReceiverCompany() {
    initSpringSecurityContext("mtuyer");
    final DelegateOrgEditionVo vo = new DelegateOrgEditionVo();
    vo.setName("InG");
    vo.setType(DelegateType.COMPANY);
    vo.setReceiver("ing");
    vo.setReceiverType(ReceiverType.COMPANY);
    vo.setCanAdmin(true);
    final int id = resource.create(vo);
    em.flush();
    em.clear();
    final DelegateOrg entity = repository.findOneExpected(id);
    Assertions.assertEquals("ing", entity.getName());
    Assertions.assertEquals("ou=ing,ou=external,ou=people,dc=sample,dc=com", entity.getDn());
    Assertions.assertEquals(DelegateType.COMPANY, entity.getType());
    Assertions.assertEquals("mtuyer", entity.getCreatedBy());
    Assertions.assertEquals("ing", entity.getReceiver());
    Assertions.assertEquals(ReceiverType.COMPANY, entity.getReceiverType());
    Assertions.assertEquals("ou=ing,ou=external,ou=people,dc=sample,dc=com", entity.getReceiverDn());
    Assertions.assertTrue(entity.isCanAdmin());
}
Also used : DelegateOrg(org.ligoj.app.iam.model.DelegateOrg) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest) Test(org.junit.jupiter.api.Test)

Example 2 with DelegateOrg

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

the class DelegateOrgResourceTest method createDelegateCompany.

@Test
public void createDelegateCompany() {
    final DelegateOrgEditionVo vo = new DelegateOrgEditionVo();
    vo.setName("socygan");
    vo.setType(DelegateType.COMPANY);
    vo.setReceiver("fdaugan");
    vo.setCanAdmin(true);
    vo.setCanWrite(true);
    final int id = resource.create(vo);
    em.flush();
    em.clear();
    final DelegateOrg entity = repository.findOneExpected(id);
    Assertions.assertEquals("socygan", entity.getName());
    Assertions.assertEquals("ou=socygan,ou=external,ou=people,dc=sample,dc=com", entity.getDn());
    Assertions.assertNull(entity.getReceiverDn());
    Assertions.assertEquals(DelegateType.COMPANY, entity.getType());
    Assertions.assertEquals(DEFAULT_USER, entity.getCreatedBy());
    Assertions.assertEquals("fdaugan", entity.getReceiver());
    Assertions.assertEquals(ReceiverType.USER, entity.getReceiverType());
    Assertions.assertTrue(entity.isCanWrite());
    Assertions.assertTrue(entity.isCanAdmin());
}
Also used : DelegateOrg(org.ligoj.app.iam.model.DelegateOrg) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest) Test(org.junit.jupiter.api.Test)

Example 3 with DelegateOrg

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

the class DelegateOrgResourceTest method updateToSubTree.

@Test
public void updateToSubTree() {
    initSpringSecurityContext("mtuyer");
    final DelegateOrgEditionVo vo = new DelegateOrgEditionVo();
    vo.setName("cn=any,ou=fonction,ou=groups,dc=sample,dc=com");
    vo.setReceiver("mtuyer");
    final DelegateOrg entity = updateNoChangeBase("mtuyer", vo);
    Assertions.assertTrue(entity.isCanAdmin());
    Assertions.assertFalse(entity.isCanWrite());
}
Also used : DelegateOrg(org.ligoj.app.iam.model.DelegateOrg) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest) Test(org.junit.jupiter.api.Test)

Example 4 with DelegateOrg

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

the class DelegateOrgResourceTest method createOnSubTree.

@Test
public void createOnSubTree() {
    final DelegateOrgEditionVo vo = new DelegateOrgEditionVo();
    vo.setName("cn=Any,dc=sample,dc=com");
    vo.setReceiver("fdaugan");
    vo.setType(DelegateType.TREE);
    final int id = resource.create(vo);
    em.flush();
    em.clear();
    final DelegateOrg entity = repository.findOneExpected(id);
    Assertions.assertEquals("-", entity.getName());
    Assertions.assertEquals("cn=any,dc=sample,dc=com", entity.getDn());
    Assertions.assertEquals(DelegateType.TREE, entity.getType());
    Assertions.assertEquals(DEFAULT_USER, entity.getCreatedBy());
    Assertions.assertEquals("fdaugan", entity.getReceiver());
    Assertions.assertEquals(ReceiverType.USER, entity.getReceiverType());
    Assertions.assertFalse(entity.isCanWrite());
    Assertions.assertFalse(entity.isCanWrite());
}
Also used : DelegateOrg(org.ligoj.app.iam.model.DelegateOrg) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest) Test(org.junit.jupiter.api.Test)

Example 5 with DelegateOrg

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

the class DelegateOrgResourceTest method updateNoChangeFromAnother.

@Test
public void updateNoChangeFromAnother() {
    final DelegateOrgEditionVo vo = new DelegateOrgEditionVo();
    vo.setName("ou=fonction,ou=groups,dc=sample,dc=com");
    vo.setReceiver("fdaugan");
    vo.setCanWrite(true);
    final DelegateOrg entity = updateNoChangeBase("fdaugan", vo);
    Assertions.assertTrue(entity.isCanWrite());
    Assertions.assertTrue(entity.isCanAdmin());
}
Also used : DelegateOrg(org.ligoj.app.iam.model.DelegateOrg) AbstractOrgTest(org.ligoj.app.resource.AbstractOrgTest) Test(org.junit.jupiter.api.Test)

Aggregations

DelegateOrg (org.ligoj.app.iam.model.DelegateOrg)19 Test (org.junit.jupiter.api.Test)13 AbstractOrgTest (org.ligoj.app.resource.AbstractOrgTest)13 ForbiddenException (javax.ws.rs.ForbiddenException)2 GET (javax.ws.rs.GET)1 UriInfo (javax.ws.rs.core.UriInfo)1 CompanyOrg (org.ligoj.app.iam.CompanyOrg)1 ContainerOrg (org.ligoj.app.iam.ContainerOrg)1 GroupOrg (org.ligoj.app.iam.GroupOrg)1 ResourceOrg (org.ligoj.app.iam.ResourceOrg)1 CacheGroup (org.ligoj.app.iam.model.CacheGroup)1 CacheMembership (org.ligoj.app.iam.model.CacheMembership)1 CacheUser (org.ligoj.app.iam.model.CacheUser)1 CacheProjectGroup (org.ligoj.app.model.CacheProjectGroup)1 PageRequest (org.springframework.data.domain.PageRequest)1