1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.fit.sra;
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.fail;
24 import static org.junit.jupiter.api.Assumptions.assumeTrue;
25
26 import java.io.IOException;
27 import java.io.InputStream;
28 import java.lang.invoke.MethodHandles;
29 import java.util.Properties;
30 import java.util.concurrent.TimeoutException;
31 import org.apache.http.HttpStatus;
32 import org.apache.http.client.methods.CloseableHttpResponse;
33 import org.junit.jupiter.api.BeforeAll;
34
35 public class OAUTH2SRAITCase extends OIDCSRAITCase {
36
37 @BeforeAll
38 public static void startSRA() throws IOException, InterruptedException, TimeoutException {
39 assumeTrue(OAUTH2SRAITCase.class.equals(MethodHandles.lookup().lookupClass()));
40
41 doStartSRA("oauth2");
42 }
43
44 @BeforeAll
45 public static void clientAppSetup() {
46 assumeTrue(OAUTH2SRAITCase.class.equals(MethodHandles.lookup().lookupClass()));
47
48 Properties props = new Properties();
49 try (InputStream propStream = OAUTH2SRAITCase.class.getResourceAsStream("/sra-oauth2.properties")) {
50 props.load(propStream);
51 } catch (Exception e) {
52 fail("Could not load /sra-oauth2.properties", e);
53 }
54 SRA_REGISTRATION_ID = "OAUTH2";
55 CLIENT_APP_ID = 2L;
56 CLIENT_ID = props.getProperty("sra.oauth2.client-id");
57 assertNotNull(CLIENT_ID);
58 CLIENT_SECRET = props.getProperty("sra.oauth2.client-secret");
59 assertNotNull(CLIENT_SECRET);
60 TOKEN_URI = props.getProperty("sra.oauth2.tokenUri");
61 assertNotNull(TOKEN_URI);
62
63 oidcClientAppSetup(
64 OAUTH2SRAITCase.class.getName(), SRA_REGISTRATION_ID, CLIENT_APP_ID, CLIENT_ID, CLIENT_SECRET);
65 }
66
67 @Override
68 protected void checkLogout(final CloseableHttpResponse response) {
69 assertEquals(HttpStatus.SC_NOT_FOUND, response.getStatusLine().getStatusCode());
70 }
71
72 @Override
73 protected boolean checkIdToken() {
74 return false;
75 }
76 }