Skip to content

Commit 3a45b57

Browse files
timea-solidacoburn
andauthored
JCL-264: use HTTPS on storage & added custom client which trusts all … (#632)
* JCL-264: use HTTPS on storage & added custom client which trusts all certs in e2e tests (#622) * Adjust dependency version --------- Co-authored-by: Aaron Coburn <aaronc@inrupt.com>
1 parent 578e1a5 commit 3a45b57

File tree

20 files changed

+624
-430
lines changed

20 files changed

+624
-430
lines changed

integration/base/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
</dependency>
3636
<dependency>
3737
<groupId>com.inrupt.client</groupId>
38-
<artifactId>inrupt-client-okhttp</artifactId>
38+
<artifactId>inrupt-client-integration-customokhttp</artifactId>
3939
<version>${project.version}</version>
4040
</dependency>
4141
<dependency>

integration/base/src/main/java/com/inrupt/client/integration/base/AccessGrantScenarios.java

Lines changed: 54 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public class AccessGrantScenarios {
101101
private static final URI PURPOSE2 = URI.create("https://purpose.example/de605b08-76c7-4f04-9cec-a438810b0c03");
102102
protected static final Set<URI> PURPOSES = new HashSet<>(Arrays.asList(PURPOSE1, PURPOSE2));
103103
protected static final String GRANT_EXPIRATION = "2024-04-03T12:00:00Z";
104-
private static String sharedTextFileName = "sharedFile.txt";
104+
private static final String sharedTextFileName = "sharedFile.txt";
105105
protected static URI sharedTextFileURI;
106106
private static URI privateContainerURI;
107107
private static Session requesterSession;
@@ -111,27 +111,37 @@ public class AccessGrantScenarios {
111111

112112
@BeforeAll
113113
static void setup() throws IOException {
114-
authServer = new MockUMAAuthorizationServer();
115-
authServer.start();
116-
117-
mockHttpServer = new MockSolidServer(authServer.getMockServerUrl());
118-
mockHttpServer.start();
119-
120-
identityProviderServer = new MockOpenIDProvider(MOCK_RESOURCE_OWNER_USERNAME);
121-
identityProviderServer.start();
122-
123-
webIdService = new MockWebIdService(
124-
mockHttpServer.getMockServerUrl(),
125-
identityProviderServer.getMockServerUrl(),
126-
MOCK_RESOURCE_OWNER_USERNAME);
127-
webIdService.start();
128-
129-
webidUrl = config
130-
.getOptionalValue("inrupt.test.webid", String.class)
131-
.orElse(URIBuilder.newBuilder(URI.create(webIdService.getMockServerUrl()))
132-
.path(MOCK_RESOURCE_OWNER_USERNAME)
133-
.build()
134-
.toString());
114+
LOGGER.info("Setup AccessGrantScenarios test");
115+
if (config.getOptionalValue("inrupt.test.webid", String.class).isPresent()) {
116+
LOGGER.info("Running AccessGrantScenarios on live server");
117+
webidUrl = config.getOptionalValue("inrupt.test.webid", String.class).get();
118+
requesterWebidUrl = config.getOptionalValue("inrupt.test.requester.webid", String.class).get();
119+
} else {
120+
LOGGER.info("Running AccessGrantScenarios on Mock services");
121+
authServer = new MockUMAAuthorizationServer();
122+
authServer.start();
123+
124+
mockHttpServer = new MockSolidServer(authServer.getMockServerUrl());
125+
mockHttpServer.start();
126+
127+
identityProviderServer = new MockOpenIDProvider(MOCK_RESOURCE_OWNER_USERNAME);
128+
identityProviderServer.start();
129+
130+
webIdService = new MockWebIdService(
131+
mockHttpServer.getMockServerUrl(),
132+
identityProviderServer.getMockServerUrl(),
133+
MOCK_RESOURCE_OWNER_USERNAME);
134+
webIdService.start();
135+
136+
webidUrl = URIBuilder.newBuilder(URI.create(webIdService.getMockServerUrl()))
137+
.path(MOCK_RESOURCE_OWNER_USERNAME)
138+
.build()
139+
.toString();
140+
requesterWebidUrl = URIBuilder.newBuilder(URI.create(webIdService.getMockServerUrl()))
141+
.path(MOCK_REQUESTER_USERNAME)
142+
.build()
143+
.toString();
144+
}
135145

136146
State.WEBID = URI.create(webidUrl);
137147
final SolidSyncClient client = SolidSyncClient.getClientBuilder().build();
@@ -161,24 +171,18 @@ static void setup() throws IOException {
161171
prepareAcpOfResource(authResourceOwnerClient, sharedTextFileURI, SolidNonRDFSource.class);
162172
}
163173

164-
requesterWebidUrl = config
165-
.getOptionalValue("inrupt.test.requester.webid", String.class)
166-
.orElse(URIBuilder.newBuilder(URI.create(webIdService.getMockServerUrl()))
167-
.path(MOCK_REQUESTER_USERNAME)
168-
.build()
169-
.toString());
170-
171-
accessGrantServer = new MockAccessGrantServer(
172-
URI.create(webidUrl),
173-
URI.create(requesterWebidUrl),
174-
sharedTextFileURI,
175-
authServer.getMockServerUrl()
176-
);
177-
accessGrantServer.start();
178-
179-
ACCESS_GRANT_PROVIDER = config
180-
.getOptionalValue("inrupt.test.access-grant.provider", String.class)
181-
.orElse(accessGrantServer.getMockServerUrl());
174+
if (config.getOptionalValue("inrupt.test.access-grant.provider", String.class).isPresent()) {
175+
ACCESS_GRANT_PROVIDER = config.getOptionalValue("inrupt.test.access-grant.provider", String.class).get();
176+
} else {
177+
accessGrantServer = new MockAccessGrantServer(
178+
URI.create(webidUrl),
179+
URI.create(requesterWebidUrl),
180+
sharedTextFileURI,
181+
authServer.getMockServerUrl()
182+
);
183+
accessGrantServer.start();
184+
ACCESS_GRANT_PROVIDER = accessGrantServer.getMockServerUrl();
185+
}
182186

183187
LOGGER.info("Integration Test Issuer: [{}]", issuer);
184188
LOGGER.info("Integration Test Pod Host: [{}]", podUrl);
@@ -190,11 +194,15 @@ static void teardown() {
190194
//cleanup pod
191195
Utils.deleteContentsRecursively(authResourceOwnerClient, privateContainerURI);
192196

193-
mockHttpServer.stop();
194-
identityProviderServer.stop();
195-
authServer.stop();
196-
webIdService.stop();
197-
accessGrantServer.stop();
197+
if (config.getOptionalValue("inrupt.test.webid", String.class).isEmpty()) {
198+
mockHttpServer.stop();
199+
identityProviderServer.stop();
200+
authServer.stop();
201+
webIdService.stop();
202+
}
203+
if (config.getOptionalValue("inrupt.test.access-grant.provider", String.class).isEmpty()) {
204+
accessGrantServer.stop();
205+
}
198206
}
199207

200208
@ParameterizedTest
@@ -475,8 +483,7 @@ void accessGrantGetRdfTest(final Session resourceOwnerSession, final Session req
475483
final AccessGrant grant = resourceOwnerAccessGrantClient.grantAccess(request)
476484
.toCompletableFuture().join();
477485
final Session newSession = AccessGrantSession.ofAccessGrant(requesterSession, grant);
478-
final SolidSyncClient requesterClient = SolidSyncClient.getClientBuilder()
479-
.build().session(newSession);
486+
final SolidSyncClient requesterClient = SolidSyncClient.getClient().session(newSession);
480487

481488
try (final SolidRDFSource resource = requesterClient.read(testRDFresourceURI, SolidRDFSource.class)) {
482489
assertTrue(resource.getMetadata().getContentType().contains(Utils.TEXT_TURTLE));

integration/base/src/main/java/com/inrupt/client/integration/base/AuthenticationScenarios.java

Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
/*
22
* Copyright Inrupt Inc.
3-
*
3+
*
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal in
66
* the Software without restriction, including without limitation the rights to use,
77
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
88
* Software, and to permit persons to whom the Software is furnished to do so,
99
* subject to the following conditions:
10-
*
10+
*
1111
* The above copyright notice and this permission notice shall be included in
1212
* all copies or substantial portions of the Software.
13-
*
13+
*
1414
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
1515
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
1616
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
@@ -73,33 +73,37 @@ public class AuthenticationScenarios {
7373
private static final String CLIENT_ID = config.getValue("inrupt.test.client-id", String.class);
7474
private static final String CLIENT_SECRET = config.getValue("inrupt.test.client-secret", String.class);
7575
private static final String AUTH_METHOD = config
76-
.getOptionalValue("inrupt.test.auth-method", String.class)
77-
.orElse("client_secret_basic");
76+
.getOptionalValue("inrupt.test.auth-method", String.class)
77+
.orElse("client_secret_basic");
7878
private static SolidSyncClient localAuthClient;
7979

8080
@BeforeAll
8181
static void setup() {
82-
authServer = new MockUMAAuthorizationServer();
83-
authServer.start();
84-
85-
mockHttpServer = new MockSolidServer(authServer.getMockServerUrl());
86-
mockHttpServer.start();
87-
88-
identityProviderServer = new MockOpenIDProvider(MOCK_USERNAME);
89-
identityProviderServer.start();
90-
91-
webIdService = new MockWebIdService(
92-
mockHttpServer.getMockServerUrl(),
93-
identityProviderServer.getMockServerUrl(),
94-
MOCK_USERNAME);
95-
webIdService.start();
96-
97-
webidUrl = config
98-
.getOptionalValue("inrupt.test.webid", String.class)
99-
.orElse(URIBuilder.newBuilder(URI.create(webIdService.getMockServerUrl()))
100-
.path(MOCK_USERNAME)
101-
.build()
102-
.toString());
82+
LOGGER.info("Setup AuthenticationScenarios test");
83+
if (config.getOptionalValue("inrupt.test.webid", String.class).isPresent()) {
84+
LOGGER.info("Running AuthenticationScenarios on live server");
85+
webidUrl = config.getOptionalValue("inrupt.test.webid", String.class).get();
86+
} else {
87+
LOGGER.info("Running AuthenticationScenarios on Mock services");
88+
authServer = new MockUMAAuthorizationServer();
89+
authServer.start();
90+
91+
mockHttpServer = new MockSolidServer(authServer.getMockServerUrl());
92+
mockHttpServer.start();
93+
94+
identityProviderServer = new MockOpenIDProvider(MOCK_USERNAME);
95+
identityProviderServer.start();
96+
97+
webIdService = new MockWebIdService(
98+
mockHttpServer.getMockServerUrl(),
99+
identityProviderServer.getMockServerUrl(),
100+
MOCK_USERNAME);
101+
webIdService.start();
102+
webidUrl = URIBuilder.newBuilder(URI.create(webIdService.getMockServerUrl()))
103+
.path(MOCK_USERNAME)
104+
.build()
105+
.toString();
106+
}
103107

104108
State.WEBID = URI.create(webidUrl);
105109
final SolidSyncClient client = SolidSyncClient.getClient();
@@ -120,8 +124,8 @@ static void setup() {
120124
localAuthClient = SolidSyncClient.getClient().session(session);
121125

122126
publicContainerURI = URIBuilder.newBuilder(URI.create(podUrl))
123-
.path("public-auth-test-" + UUID.randomUUID() + "/")
124-
.build();
127+
.path("public-auth-test-" + UUID.randomUUID() + "/")
128+
.build();
125129
publicResourceURI = URIBuilder.newBuilder(publicContainerURI)
126130
.path(testResourceName)
127131
.build();
@@ -141,16 +145,19 @@ static void setup() {
141145
LOGGER.info("Integration Test Issuer: [{}]", issuer);
142146
LOGGER.info("Integration Test Pod Host: [{}]", URI.create(podUrl).getHost());
143147
}
148+
144149
@AfterAll
145150
static void teardown() {
146151
//cleanup pod
147152
Utils.deleteContentsRecursively(localAuthClient, publicContainerURI);
148153
Utils.deleteContentsRecursively(localAuthClient, privateContainerURI);
149154

150-
mockHttpServer.stop();
151-
identityProviderServer.stop();
152-
authServer.stop();
153-
webIdService.stop();
155+
if (config.getOptionalValue("inrupt.test.webid", String.class).isEmpty()) {
156+
mockHttpServer.stop();
157+
identityProviderServer.stop();
158+
authServer.stop();
159+
webIdService.stop();
160+
}
154161
}
155162

156163
@Test

integration/base/src/main/java/com/inrupt/client/integration/base/CoreModulesResourceJena.java

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public class CoreModulesResourceJena {
7373
private static final Config config = ConfigProvider.getConfig();
7474
private static final SolidSyncClient client = SolidSyncClient.getClient().session(Session.anonymous());
7575
private static String podUrl;
76+
private static String webidUrl;
7677
private static final String MOCK_USERNAME = "someuser";
7778
private static final String TYPE = "type";
7879
private static final String LINK = "Link";
@@ -88,24 +89,30 @@ public class CoreModulesResourceJena {
8889

8990
@BeforeAll
9091
static void setup() {
91-
authServer = new MockUMAAuthorizationServer();
92-
authServer.start();
92+
LOGGER.info("Setup CoreModulesResourceJena test");
9393

94-
mockHttpServer = new MockSolidServer(authServer.getMockServerUrl());
95-
mockHttpServer.start();
94+
if (config.getOptionalValue("inrupt.test.webid", String.class).isPresent()) {
95+
LOGGER.info("Running CoreModulesResourceJena on live server");
96+
webidUrl = config.getOptionalValue("inrupt.test.webid", String.class).get();
97+
} else {
98+
LOGGER.info("Running CoreModulesResourceJena on Mock services");
99+
authServer = new MockUMAAuthorizationServer();
100+
authServer.start();
96101

97-
identityProviderServer = new MockOpenIDProvider(MOCK_USERNAME);
98-
identityProviderServer.start();
102+
mockHttpServer = new MockSolidServer(authServer.getMockServerUrl());
103+
mockHttpServer.start();
99104

100-
webIdService = new MockWebIdService(
101-
mockHttpServer.getMockServerUrl(),
102-
identityProviderServer.getMockServerUrl(),
103-
MOCK_USERNAME);
104-
webIdService.start();
105+
identityProviderServer = new MockOpenIDProvider(MOCK_USERNAME);
106+
identityProviderServer.start();
105107

106-
final String webidUrl = config
107-
.getOptionalValue("inrupt.test.webid", String.class)
108-
.orElse(webIdService.getMockServerUrl() + Utils.FOLDER_SEPARATOR + MOCK_USERNAME);
108+
webIdService = new MockWebIdService(
109+
mockHttpServer.getMockServerUrl(),
110+
identityProviderServer.getMockServerUrl(),
111+
MOCK_USERNAME);
112+
webIdService.start();
113+
webidUrl = webIdService.getMockServerUrl() + Utils.FOLDER_SEPARATOR + MOCK_USERNAME;
114+
115+
}
109116

110117
State.WEBID = URI.create(webidUrl);
111118
//find storage from WebID using only core module
@@ -142,10 +149,12 @@ static void teardown() {
142149
//cleanup pod
143150
Utils.deleteContentsRecursively(localAuthClient, publicContainerURI);
144151

145-
mockHttpServer.stop();
146-
identityProviderServer.stop();
147-
authServer.stop();
148-
webIdService.stop();
152+
if (config.getOptionalValue("inrupt.test.webid", String.class).isEmpty()) {
153+
mockHttpServer.stop();
154+
identityProviderServer.stop();
155+
authServer.stop();
156+
webIdService.stop();
157+
}
149158
}
150159

151160
@Test

integration/base/src/main/java/com/inrupt/client/integration/base/DomainModulesResource.java

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -85,24 +85,28 @@ public class DomainModulesResource {
8585

8686
@BeforeAll
8787
static void setup() {
88-
authServer = new MockUMAAuthorizationServer();
89-
authServer.start();
90-
91-
mockHttpServer = new MockSolidServer(authServer.getMockServerUrl());
92-
mockHttpServer.start();
93-
94-
identityProviderServer = new MockOpenIDProvider(MOCK_USERNAME);
95-
identityProviderServer.start();
96-
97-
webIdService = new MockWebIdService(
98-
mockHttpServer.getMockServerUrl(),
99-
identityProviderServer.getMockServerUrl(),
100-
MOCK_USERNAME);
101-
webIdService.start();
102-
103-
webidUrl = config
104-
.getOptionalValue("inrupt.test.webid", String.class)
105-
.orElse(webIdService.getMockServerUrl() + Utils.FOLDER_SEPARATOR + MOCK_USERNAME);
88+
LOGGER.info("Setup DomainModulesResource test");
89+
if (config.getOptionalValue("inrupt.test.webid", String.class).isPresent()) {
90+
LOGGER.info("Running DomainModulesResource on live server");
91+
webidUrl = config.getOptionalValue("inrupt.test.webid", String.class).get();
92+
} else {
93+
LOGGER.info("Running DomainModulesResource on Mock services");
94+
authServer = new MockUMAAuthorizationServer();
95+
authServer.start();
96+
97+
mockHttpServer = new MockSolidServer(authServer.getMockServerUrl());
98+
mockHttpServer.start();
99+
100+
identityProviderServer = new MockOpenIDProvider(MOCK_USERNAME);
101+
identityProviderServer.start();
102+
103+
webIdService = new MockWebIdService(
104+
mockHttpServer.getMockServerUrl(),
105+
identityProviderServer.getMockServerUrl(),
106+
MOCK_USERNAME);
107+
webIdService.start();
108+
webidUrl = webIdService.getMockServerUrl() + Utils.FOLDER_SEPARATOR + MOCK_USERNAME;
109+
}
106110

107111
State.WEBID = URI.create(webidUrl);
108112
//find storage from WebID using domain-specific webID solid concept
@@ -138,10 +142,12 @@ static void teardown() {
138142
//cleanup pod
139143
Utils.deleteContentsRecursively(localAuthClient, publicContainerURI);
140144

141-
mockHttpServer.stop();
142-
identityProviderServer.stop();
143-
authServer.stop();
144-
webIdService.stop();
145+
if (config.getOptionalValue("inrupt.test.webid", String.class).isEmpty()) {
146+
mockHttpServer.stop();
147+
identityProviderServer.stop();
148+
authServer.stop();
149+
webIdService.stop();
150+
}
145151
}
146152

147153
@Test

0 commit comments

Comments
 (0)