1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.fit.core;
20
21 import static org.junit.jupiter.api.Assertions.assertEquals;
22 import static org.junit.jupiter.api.Assertions.fail;
23 import static org.junit.jupiter.api.Assumptions.assumeTrue;
24
25 import javax.ws.rs.core.Response;
26 import org.apache.syncope.client.lib.SyncopeClientFactoryBean;
27 import org.apache.syncope.common.lib.SyncopeClientException;
28 import org.apache.syncope.common.lib.types.ClientExceptionType;
29 import org.apache.syncope.common.rest.api.service.OIDCJWKSService;
30 import org.apache.syncope.fit.AbstractITCase;
31 import org.junit.jupiter.api.BeforeAll;
32 import org.junit.jupiter.api.Test;
33 import org.springframework.http.HttpStatus;
34
35 public class OIDCJWKSITCase extends AbstractITCase {
36
37 private static OIDCJWKSService WA_OIDC_JWKS_SERVICE;
38
39 @BeforeAll
40 public static void setup() {
41 assumeTrue(CLIENT_FACTORY.getContentType() == SyncopeClientFactoryBean.ContentType.JSON);
42
43 WA_OIDC_JWKS_SERVICE = ANONYMOUS_CLIENT.getService(OIDCJWKSService.class);
44 }
45
46 @Test
47 public void deleteGetSet() {
48 try {
49 OIDC_JWKS_SERVICE.delete();
50
51 WA_OIDC_JWKS_SERVICE.get();
52 fail("Should not locate an OIDC JWKS");
53 } catch (SyncopeClientException e) {
54 assertEquals(ClientExceptionType.NotFound, e.getType());
55 }
56
57 Response response = WA_OIDC_JWKS_SERVICE.generate("syncope", "RSA", 2048);
58 assertEquals(HttpStatus.CREATED.value(), response.getStatus());
59 try {
60 WA_OIDC_JWKS_SERVICE.generate("syncope", "RSA", 2048);
61 fail("Should not recreate an OIDC JWKS");
62 } catch (SyncopeClientException e) {
63 assertEquals(ClientExceptionType.EntityExists, e.getType());
64 }
65 }
66 }