Skip to content

Commit 8b4587d

Browse files
committed
Improve readability and make access control test informational only
1 parent 9d57085 commit 8b4587d

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

src/main/java/org/solid/testharness/config/TestSubject.java

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -157,29 +157,33 @@ public void prepareServer() {
157157
logger.debug("Test run container content: {}", testRunContainer.getContentAsTurtle());
158158
logger.debug("Test run container access controls: {}", testRunContainer.getAccessDataset());
159159

160-
// check that we can change the access control of a resource so we know those tests can run
161-
final var aclTestContainer = testRunContainer.reserveContainer("acltest");
162-
try {
163-
aclTestContainer .instantiate();
164-
final var builder = aclTestContainer.getAccessDatasetBuilder();
165-
final var bobReadAcl = builder
166-
.setAgentAccess(
167-
aclTestContainer.getUrl().toString(),
168-
config.getWebIds().get(HttpConstants.BOB),
169-
List.of("read")
170-
).build();
171-
aclTestContainer.setAccessDataset(bobReadAcl); // MOCK THIS PASS/FAIL
172-
logger.info("Confirmed we can create a container [{}] and set ACLs on it", aclTestContainer.getUrl());
173-
} catch (TestHarnessException | TestHarnessApiException ex) {
174-
logger.warn("Failed to create a container [{}] and set ACLs on it: {}",
175-
aclTestContainer.getUrl(), ex.getMessage());
176-
throw ex;
177-
}
160+
testAccessControlCapability();
178161
} catch (TestHarnessException | RuntimeException e) {
179162
throw new TestHarnessInitializationException("Failed to prepare server", e);
180163
}
181164
}
182165

166+
private void testAccessControlCapability() throws TestHarnessException {
167+
// check that we can change the access control of a resource so we know those tests can run
168+
final var aclTestContainer = testRunContainer.reserveContainer("acltest");
169+
try {
170+
aclTestContainer .instantiate();
171+
final var builder = aclTestContainer.getAccessDatasetBuilder();
172+
final var bobReadAcl = builder
173+
.setAgentAccess(
174+
aclTestContainer.getUrl().toString(),
175+
config.getWebIds().get(HttpConstants.BOB),
176+
List.of("read")
177+
).build();
178+
aclTestContainer.setAccessDataset(bobReadAcl); // MOCK THIS PASS/FAIL
179+
logger.info("Confirmed we can create a container [{}] and set ACLs on it", aclTestContainer.getUrl());
180+
} catch (TestHarnessException | TestHarnessApiException ex) {
181+
// don't throw an error as we might not be running access control tests
182+
logger.warn("Failed to create a container [{}] and set ACLs on it: {}",
183+
aclTestContainer.getUrl(), ex.getMessage());
184+
}
185+
}
186+
183187
// Determine the ACL mode the server has implemented
184188
private void determineAccessControlImplementation(final SolidClientProvider ownerClient)
185189
throws TestHarnessException {

0 commit comments

Comments
 (0)