1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.core.persistence.jpa.inner;
20
21 import static org.junit.jupiter.api.Assertions.assertEquals;
22 import static org.junit.jupiter.api.Assertions.assertNotNull;
23 import static org.junit.jupiter.api.Assertions.assertNull;
24
25 import java.util.UUID;
26 import org.apache.syncope.core.persistence.api.dao.CASSPClientAppDAO;
27 import org.apache.syncope.core.persistence.api.entity.am.CASSPClientApp;
28 import org.apache.syncope.core.persistence.api.entity.policy.AccessPolicy;
29 import org.apache.syncope.core.persistence.api.entity.policy.AuthPolicy;
30 import org.junit.jupiter.api.Test;
31 import org.springframework.beans.factory.annotation.Autowired;
32 import org.springframework.transaction.annotation.Transactional;
33
34 @Transactional("Master")
35 public class CASSPTest extends AbstractClientAppTest {
36
37 @Autowired
38 private CASSPClientAppDAO casspDAO;
39
40 @Test
41 public void find() {
42 int beforeCount = casspDAO.findAll().size();
43
44 CASSPClientApp rp = entityFactory.newEntity(CASSPClientApp.class);
45 rp.setName("CAS");
46 rp.setClientAppId(UUID.randomUUID().getMostSignificantBits() & Long.MAX_VALUE);
47 rp.setDescription("This is a sample CAS RP");
48 rp.setServiceId("https://syncope.apache.org/.*");
49
50 AccessPolicy accessPolicy = buildAndSaveAccessPolicy();
51 rp.setAccessPolicy(accessPolicy);
52
53 AuthPolicy authPolicy = buildAndSaveAuthPolicy();
54 rp.setAuthPolicy(authPolicy);
55
56 casspDAO.save(rp);
57
58 assertNotNull(rp);
59 assertNotNull(rp.getKey());
60
61 int afterCount = casspDAO.findAll().size();
62 assertEquals(afterCount, beforeCount + 1);
63
64 rp = casspDAO.findByName("CAS");
65 assertNotNull(rp);
66
67 rp = casspDAO.findByClientAppId(rp.getClientAppId());
68 assertNotNull(rp);
69
70 casspDAO.delete(rp);
71 assertNull(casspDAO.findByName("CAS"));
72 }
73 }