Search in sources :

Example 26 with ExternalResource

use of org.apache.syncope.core.persistence.api.entity.resource.ExternalResource in project syncope by apache.

the class ResourceTest method findAll.

@Test
public void findAll() {
    List<GrantedAuthority> authorities = StandardEntitlement.values().stream().map(entitlement -> new SyncopeGrantedAuthority(entitlement, SyncopeConstants.ROOT_REALM)).collect(Collectors.toList());
    UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken(new org.springframework.security.core.userdetails.User("admin", "FAKE_PASSWORD", authorities), "FAKE_PASSWORD", authorities);
    auth.setDetails(new SyncopeAuthenticationDetails("Master"));
    SecurityContextHolder.getContext().setAuthentication(auth);
    try {
        List<ExternalResource> resources = resourceDAO.findAll();
        assertNotNull(resources);
        assertFalse(resources.isEmpty());
    } finally {
        SecurityContextHolder.getContext().setAuthentication(null);
    }
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) Assertions.fail(org.junit.jupiter.api.Assertions.fail) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) StandardEntitlement(org.apache.syncope.common.lib.types.StandardEntitlement) Assertions.assertNull(org.junit.jupiter.api.Assertions.assertNull) Autowired(org.springframework.beans.factory.annotation.Autowired) SyncopeGrantedAuthority(org.apache.syncope.core.spring.security.SyncopeGrantedAuthority) DelegatedAdministrationException(org.apache.syncope.core.spring.security.DelegatedAdministrationException) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) SecurityContextHolder(org.springframework.security.core.context.SecurityContextHolder) EntityViolationType(org.apache.syncope.common.lib.types.EntityViolationType) SyncopeConstants(org.apache.syncope.common.lib.SyncopeConstants) Mapping(org.apache.syncope.core.persistence.api.entity.resource.Mapping) SyncopeAuthenticationDetails(org.apache.syncope.core.spring.security.SyncopeAuthenticationDetails) Collectors(java.util.stream.Collectors) AnyTypeDAO(org.apache.syncope.core.persistence.api.dao.AnyTypeDAO) ConnInstance(org.apache.syncope.core.persistence.api.entity.ConnInstance) MappingItem(org.apache.syncope.core.persistence.api.entity.resource.MappingItem) InvalidEntityException(org.apache.syncope.core.persistence.api.attrvalue.validation.InvalidEntityException) GrantedAuthority(org.springframework.security.core.GrantedAuthority) Test(org.junit.jupiter.api.Test) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource) List(java.util.List) Provision(org.apache.syncope.core.persistence.api.entity.resource.Provision) MappingPurpose(org.apache.syncope.common.lib.types.MappingPurpose) ObjectClass(org.identityconnectors.framework.common.objects.ObjectClass) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) ExternalResourceDAO(org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO) Transactional(org.springframework.transaction.annotation.Transactional) SyncopeGrantedAuthority(org.apache.syncope.core.spring.security.SyncopeGrantedAuthority) SyncopeGrantedAuthority(org.apache.syncope.core.spring.security.SyncopeGrantedAuthority) GrantedAuthority(org.springframework.security.core.GrantedAuthority) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource) SyncopeAuthenticationDetails(org.apache.syncope.core.spring.security.SyncopeAuthenticationDetails) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 27 with ExternalResource

use of org.apache.syncope.core.persistence.api.entity.resource.ExternalResource in project syncope by apache.

the class TaskTest method delete.

@Test
public void delete() {
    PropagationTask task = taskDAO.find("1e697572-b896-484c-ae7f-0c8f63fcbc6c");
    assertNotNull(task);
    ExternalResource resource = task.getResource();
    assertNotNull(resource);
    taskDAO.delete(task);
    task = taskDAO.find("1e697572-b896-484c-ae7f-0c8f63fcbc6c");
    assertNull(task);
    resource = resourceDAO.find(resource.getKey());
    assertNotNull(resource);
    assertFalse(taskDAO.findAll(TaskType.PROPAGATION, resource, null, null, null, -1, -1, Collections.<OrderByClause>emptyList()).contains(task));
}
Also used : PropagationTask(org.apache.syncope.core.persistence.api.entity.task.PropagationTask) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 28 with ExternalResource

use of org.apache.syncope.core.persistence.api.entity.resource.ExternalResource in project syncope by apache.

the class VirSchemaTest method save.

@Test
public void save() {
    ExternalResource csv = resourceDAO.find("resource-csv");
    Provision provision = csv.getProvision(ObjectClass.ACCOUNT).get();
    assertNotNull(provision);
    VirSchema virSchema = entityFactory.newEntity(VirSchema.class);
    virSchema.setKey("virtual");
    virSchema.setProvision(provision);
    virSchema.setReadonly(true);
    virSchema.setExtAttrName("EXT_ATTR");
    virSchemaDAO.save(virSchema);
    VirSchema actual = virSchemaDAO.find("virtual");
    assertNotNull(actual);
    assertTrue(actual.isReadonly());
    assertEquals("EXT_ATTR", actual.getExtAttrName());
}
Also used : Provision(org.apache.syncope.core.persistence.api.entity.resource.Provision) VirSchema(org.apache.syncope.core.persistence.api.entity.VirSchema) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 29 with ExternalResource

use of org.apache.syncope.core.persistence.api.entity.resource.ExternalResource in project syncope by apache.

the class ResourceHistoryConfTest method createDelete.

@Test
public void createDelete() {
    ExternalResource ldapResource = resourceDAO.find("resource-ldap");
    assertNotNull(ldapResource);
    ExternalResourceHistoryConf ldapHistory = entityFactory.newEntity(ExternalResourceHistoryConf.class);
    ldapHistory.setCreation(new Date());
    ldapHistory.setCreator("me");
    ldapHistory.setEntity(ldapResource);
    ldapHistory.setConf(new ResourceTO());
    ldapHistory = resourceHistoryConfDAO.save(ldapHistory);
    assertNotNull(ldapHistory.getKey());
    resourceHistoryConfDAO.flush();
    List<ExternalResourceHistoryConf> history = resourceHistoryConfDAO.findByEntity(ldapResource);
    assertEquals(1, history.size());
    assertEquals(ldapHistory, history.get(0));
    resourceHistoryConfDAO.delete(ldapHistory.getKey());
    resourceHistoryConfDAO.flush();
    assertNull(resourceHistoryConfDAO.find(ldapHistory.getKey()));
    assertTrue(resourceHistoryConfDAO.findByEntity(ldapResource).isEmpty());
}
Also used : ExternalResourceHistoryConf(org.apache.syncope.core.persistence.api.entity.resource.ExternalResourceHistoryConf) ResourceTO(org.apache.syncope.common.lib.to.ResourceTO) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource) Date(java.util.Date) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Example 30 with ExternalResource

use of org.apache.syncope.core.persistence.api.entity.resource.ExternalResource in project syncope by apache.

the class TaskTest method issueSYNCOPE144.

@Test
public void issueSYNCOPE144() {
    ExternalResource resource = resourceDAO.find("ws-target-resource-1");
    assertNotNull(resource);
    Implementation pullActions = entityFactory.newEntity(Implementation.class);
    pullActions.setKey("syncope144");
    pullActions.setEngine(ImplementationEngine.JAVA);
    pullActions.setType(ImplementationType.PULL_ACTIONS);
    pullActions.setBody(PullActions.class.getName());
    pullActions = implementationDAO.save(pullActions);
    PullTask task = entityFactory.newEntity(PullTask.class);
    task.setResource(resource);
    task.setName("issueSYNCOPE144");
    task.setDescription("issueSYNCOPE144 Description");
    task.setActive(true);
    task.setPullMode(PullMode.FULL_RECONCILIATION);
    task.add(pullActions);
    task.setMatchingRule(MatchingRule.UPDATE);
    task.setUnmatchingRule(UnmatchingRule.PROVISION);
    task = taskDAO.save(task);
    assertNotNull(task);
    PullTask actual = taskDAO.find(task.getKey());
    assertEquals(task, actual);
    assertEquals("issueSYNCOPE144", actual.getName());
    assertEquals("issueSYNCOPE144 Description", actual.getDescription());
    actual.setName("issueSYNCOPE144_2");
    actual.setDescription("issueSYNCOPE144 Description_2");
    actual = taskDAO.save(actual);
    assertNotNull(actual);
    assertEquals("issueSYNCOPE144_2", actual.getName());
    assertEquals("issueSYNCOPE144 Description_2", actual.getDescription());
}
Also used : PullTask(org.apache.syncope.core.persistence.api.entity.task.PullTask) AnyTemplatePullTask(org.apache.syncope.core.persistence.api.entity.task.AnyTemplatePullTask) PullActions(org.apache.syncope.core.provisioning.api.pushpull.PullActions) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource) Implementation(org.apache.syncope.core.persistence.api.entity.Implementation) Test(org.junit.jupiter.api.Test) AbstractTest(org.apache.syncope.core.persistence.jpa.AbstractTest)

Aggregations

ExternalResource (org.apache.syncope.core.persistence.api.entity.resource.ExternalResource)59 Test (org.junit.jupiter.api.Test)30 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)28 Provision (org.apache.syncope.core.persistence.api.entity.resource.Provision)23 MappingItem (org.apache.syncope.core.persistence.api.entity.resource.MappingItem)21 ConnInstance (org.apache.syncope.core.persistence.api.entity.ConnInstance)15 List (java.util.List)14 Collectors (java.util.stream.Collectors)14 HashSet (java.util.HashSet)13 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)13 Autowired (org.springframework.beans.factory.annotation.Autowired)13 Set (java.util.Set)12 Transactional (org.springframework.transaction.annotation.Transactional)12 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)10 ExternalResourceDAO (org.apache.syncope.core.persistence.api.dao.ExternalResourceDAO)10 Collections (java.util.Collections)9 AnyTypeDAO (org.apache.syncope.core.persistence.api.dao.AnyTypeDAO)9 Realm (org.apache.syncope.core.persistence.api.entity.Realm)9 PasswordPolicy (org.apache.syncope.core.persistence.api.entity.policy.PasswordPolicy)9 AnyType (org.apache.syncope.core.persistence.api.entity.AnyType)8