Skip to content

Commit

Permalink
improved test, formating & documentation (#557)
Browse files Browse the repository at this point in the history
* improved test, formating & documentation
  • Loading branch information
timea-solid authored Jun 27, 2023
1 parent b27cc24 commit 08afa32
Show file tree
Hide file tree
Showing 11 changed files with 234 additions and 157 deletions.
36 changes: 25 additions & 11 deletions integration/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Integration tests

The integration tests contain two scenarios of tests:
The integration tests contain more test scenarios:

* resource CRUD related scenarios;
* authentication & authorization scenarios.
Expand All @@ -11,13 +11,19 @@ These scenarios can be run against different Solid servers.

## Running the integration tests locally

The default setup (which comes with the project) uses an internal Mock Solid Server. One can simply run the tests locally and they will run on the internal Mock Solid Server. The tests only need a dummy client-id and client-secret as found in the `./base/src/main/resources/META-INF/microprofile-config.properties` file. Navigate to one of the concrete openid or uma tests found in this module and hit `run`.
The default setup (which comes with the project) uses an internal Mock Solid Server. One can simply run the tests locally, and they will run on the internal Mock Solid Server. The tests need some dummy values for:
* the owner `client-id`
* the owner `client-secret`
* the `requester.client-id` used in Access Grants scenarios
* and the `requester.client-secret`

## Set up a live server
They can be found in the `./base/src/main/resources/META-INF/microprofile-config.properties` file. Navigate to one of the concrete openid or uma tests found in this module and hit `run`.

To set up a server one needs to add more configurations to the `./base/src/main/resources/META-INF/microprofile-config.properties` file.
## Running the tests on a live Solid server

But first let's take a look at the possible configuration values in the properties file.
To set up a server, one needs to add more configurations to the `./base/src/main/resources/META-INF/microprofile-config.properties` file.

Let's take a look at the possible configuration values in the properties file.
All the possible value are listed next:

* `inrupt.test.client-id` // mandatory
Expand All @@ -26,14 +32,20 @@ All the possible value are listed next:
* `inrupt.test.webid`
* `inrupt.test.public-resource-path` // default is no dedicated container, everything gets created on the storage root
* `inrupt.test.private-resource-path` // default is a container named `private`
* `inrupt.test.access-grant.provider`
* `inrupt.test.requester.webid`
* `inrupt.test.requester.client-id` // mandatory
* `inrupt.test.requester.client-secret` // mandatory

`inrupt.test.client-id` & `inrupt.test.client-secret` are used to signal the server that this is a registered client. These two fields are mandatory and are the only configuration needed to run the tests on the integrated Mock Solid Server.

`inrupt.test.auth-method` refers to the [client authentication](https://openid.net/specs/openid-connect-core-1_0.html#ClientAuthentication) method and has a default value of `client_secret_basic`. This value is used when this property is not provided.
Mandatory fields are:
* `inrupt.test.client-id` & `inrupt.test.client-secret` are used to signal the server that this is a registered client acting as the owner of resources.
* `inrupt.test.requester.client-id` & `inrupt.test.requester.client-secret` are used in the Access Grant scenarios tests and act as the second client, the requestor. The requestor wants to access resources which are owned by the client representing the owner (the first pair of id and secret).

`inrupt.test.webid` is needed only if we want to run the integration tests on a live service. Otherwise, this property needs to be left out because it will be populated by the Mocked services with a mock username called `someuser`.

`inrupt.test.public-resource-path` & `inrupt.test.private-resource-path` are properties used to fine grain the containers we use for testing.
Optional fields are:
* `inrupt.test.webid` is needed only if we want to run the integration tests on a live service. Otherwise, this property needs to be left out because it will be populated by the Mocked services with a mock username called `someuser`.
* `inrupt.test.requester.webid` is only needed in the access grants test scenarios and can be also left empty because the Mocked services will create a username called `requester`.
* `inrupt.test.auth-method` refers to the [client authentication](https://openid.net/specs/openid-connect-core-1_0.html#ClientAuthentication) method and has a default value of `client_secret_basic`. This value is used when this property is not provided.
* `inrupt.test.public-resource-path` & `inrupt.test.private-resource-path` are properties used to fine grain the containers we use for testing.

## The embedded Mock Solid Server

Expand All @@ -49,3 +61,5 @@ The Mock Solid Server is actually a collection of services which try to mock, as
* `MockSolidServer` - mocks the storage service of a Pod provider. It mocks the behavior of private and public resources by looking if the resource path contains the `inrupt.test.private-resource-path`. And it mocks, according to Solid Protocol methods like GET, PUT, POST and PATCH.

* `MockUMAAuthorizationServer` - mocks the authorization service, in our case a UMA service. UMA authorization is the default, hard-coded, in the Mocked services. This can be seen in any request on a private resource in the MockSolidServer. When not authorized, the Solid Server will respond with a WWW-Authenticate header which contains a UMA ticket.

* `MockAccessGrantServer` - mocks the access grant service, which is a VC service here. A couple of hardcoded assumptions are embedded in the Mock to make it work. Especially regarding the status of grants: active or revoked.
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ static void teardown() {

@ParameterizedTest
@MethodSource("provideSessions")
@DisplayName(":accessGrantLifecycle Access Grant issuance lifecycle")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/accessGrantLifecycle " +
"Access Grant issuance lifecycle")
void accessGrantIssuanceLifecycleTest(final Session resourceOwnerSession, final Session requesterSession) {
//test is NOT run locally, AccessGrantServerMock needs to be aware of grant statuses.
//We do not do this for now.
Expand Down Expand Up @@ -297,7 +298,8 @@ void accessGrantIssuanceLifecycleTest(final Session resourceOwnerSession, final

@ParameterizedTest
@MethodSource("provideSessions")
@DisplayName(":accessGrantOverride Access Grant with request overrides")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/accessGrantOverride " +
"Access Grant with request overrides")
void accessGrantWithRequestOverridesTest(final Session resourceOwnerSession, final Session requesterSession) {
LOGGER.info("Integration Test - Access Grant with request overrides");

Expand Down Expand Up @@ -328,7 +330,8 @@ void accessGrantWithRequestOverridesTest(final Session resourceOwnerSession, fin
//Query access grant related tests
@ParameterizedTest
@MethodSource("provideSessions")
@DisplayName(":accessGrantQueryByRequestor Lookup Access Grants by requester")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/accessGrantQueryByRequestor " +
"Lookup Access Grants by requester")
void accessGrantQueryByRequesterTest(final Session resourceOwnerSession, final Session requesterSession) {
LOGGER.info("Integration Test - Lookup Access Grants by requester");

Expand Down Expand Up @@ -367,7 +370,8 @@ void accessGrantQueryByRequesterTest(final Session resourceOwnerSession, final S

@ParameterizedTest
@MethodSource("provideSessions")
@DisplayName(":accessGrantQueryByPurpose Lookup Access Grants by purpose of a dedicated resource")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/accessGrantQueryByPurpose " +
"Lookup Access Grants by purpose of a dedicated resource")
void accessGrantQueryByPurposeTest(final Session resourceOwnerSession, final Session requesterSession) {
LOGGER.info("Integration Test - Lookup Access Grants by purpose");

Expand Down Expand Up @@ -407,7 +411,8 @@ void accessGrantQueryByPurposeTest(final Session resourceOwnerSession, final Ses
//Interacting with resource related tests
@ParameterizedTest
@MethodSource("provideSessions")
@DisplayName(":accessGrantGetRdf Fetching RDF using Access Grant")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/accessGrantGetRdf " +
"Fetching RDF using Access Grant")
void accessGrantGetRdfTest(final Session resourceOwnerSession, final Session requesterSession) {
LOGGER.info("Integration Test - Fetching RDF using Access Grant");

Expand Down Expand Up @@ -450,7 +455,8 @@ void accessGrantGetRdfTest(final Session resourceOwnerSession, final Session req

@ParameterizedTest
@MethodSource("provideSessions")
@DisplayName(":accessGrantSetRdf Appending RDF using Access Grant")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/accessGrantSetRdf " +
"Appending RDF using Access Grant")
void accessGrantSetRdfTest(final Session resourceOwnerSession, final Session requesterSession) {
LOGGER.info("Integration Test - Appending RDF using Access Grant");

Expand Down Expand Up @@ -503,7 +509,8 @@ void accessGrantSetRdfTest(final Session resourceOwnerSession, final Session req

@ParameterizedTest
@MethodSource("provideSessions")
@DisplayName(":accessGrantCreateRdf Creating RDF using Access Grant")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/accessGrantCreateRdf " +
"Creating RDF using Access Grant")
void accessGrantCreateRdfTest(final Session resourceOwnerSession, final Session requesterSession) {
LOGGER.info("Integration Test - Creating RDF using Access Grant");

Expand Down Expand Up @@ -546,7 +553,8 @@ void accessGrantCreateRdfTest(final Session resourceOwnerSession, final Session

@ParameterizedTest
@MethodSource("provideSessions")
@DisplayName(":accessGrantGetNonRdf Fetching non-RDF using Access Grant")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/accessGrantGetNonRdf " +
"Fetching non-RDF using Access Grant")
void accessGrantGetNonRdfTest(final Session resourceOwnerSession, final Session requesterSession)
throws IOException {
LOGGER.info("Integration Test - Fetching non-RDF using Access Grant");
Expand Down Expand Up @@ -596,7 +604,8 @@ void accessGrantGetNonRdfTest(final Session resourceOwnerSession, final Session

@ParameterizedTest
@MethodSource("provideSessions")
@DisplayName(":accessGrantSetNonRdf Overwriting non-RDF using Access Grant")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/accessGrantSetNonRdf " +
"Overwriting non-RDF using Access Grant")
void accessGrantSetNonRdfTest(final Session resourceOwnerSession, final Session requesterSession)
throws IOException {
LOGGER.info("Integration Test - Overwriting non-RDF using Access Grant");
Expand Down Expand Up @@ -660,7 +669,8 @@ void accessGrantSetNonRdfTest(final Session resourceOwnerSession, final Session

@ParameterizedTest
@MethodSource("provideSessions")
@DisplayName(":accessGrantCreateNonRdf Creating non-RDF using Access Grant")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/accessGrantCreateNonRdf " +
"Creating non-RDF using Access Grant")
void accessGrantCreateNonRdfTest(final Session resourceOwnerSession, final Session requesterSession)
throws IOException {
LOGGER.info("Integration Test - Creating non-RDF using Access Grant");
Expand Down Expand Up @@ -707,7 +717,6 @@ void accessGrantCreateNonRdfTest(final Session resourceOwnerSession, final Sessi
private static <T extends SolidResource> void prepareAcpOfResource(final SolidSyncClient authClient,
final URI resourceURI,
final Class<T> clazz) {

SolidResource resource = null;
try {
if (SolidNonRDFSource.class.isAssignableFrom(clazz)) {
Expand All @@ -733,13 +742,13 @@ private static <T extends SolidResource> void prepareAcpOfResource(final SolidSy

private static Stream<Arguments> provideSessions() throws SolidClientException {
resourceOwnerSession = OpenIdSession.ofClientCredentials(
URI.create(issuer), //Client credentials
URI.create(issuer),
RESOURCE_OWNER_CLIENT_ID,
RESOURCE_OWNER_CLIENT_SECRET,
AUTH_METHOD);

requesterSession = OpenIdSession.ofClientCredentials(
URI.create(issuer), //Client credentials
URI.create(issuer),
REQUESTER_CLIENT_ID,
REQUESTER_CLIENT_SECRET,
AUTH_METHOD);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ static void teardown() {
}

@Test
@DisplayName(":unauthenticatedPublicNode Unauthenticated fetch of public resource succeeds")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/unauthenticatedPublicNode " +
"Unauthenticated fetch of public resource succeeds")
void fetchPublicResourceUnauthenticatedTest() {
LOGGER.info("Integration Test - Unauthenticated fetch of public resource");
//create a public resource
Expand All @@ -181,7 +182,8 @@ void fetchPublicResourceUnauthenticatedTest() {

@ParameterizedTest
@MethodSource("provideSessions")
@DisplayName(":unauthenticatedPrivateNode Unauthenticated fetch of a private resource fails")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/unauthenticatedPrivateNode" +
" Unauthenticated fetch of a private resource fails")
void fetchPrivateResourceUnauthenticatedTest(final Session session) {
LOGGER.info("Integration Test - Unauthenticated fetch of a private resource");
//create private resource
Expand All @@ -201,7 +203,8 @@ void fetchPrivateResourceUnauthenticatedTest(final Session session) {

@ParameterizedTest
@MethodSource("provideSessions")
@DisplayName(":authenticatedPublicNode Authenticated fetch of public resource succeeds")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/authenticatedPublicNode " +
"Authenticated fetch of public resource succeeds")
void fetchPublicResourceAuthenticatedTest(final Session session) {
LOGGER.info("Integration Test - Authenticated fetch of public resource");
//create public resource
Expand All @@ -218,7 +221,8 @@ void fetchPublicResourceAuthenticatedTest(final Session session) {

@ParameterizedTest
@MethodSource("provideSessions")
@DisplayName(":authenticatedPrivateNode Authenticated fetch of private resource succeeds")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/authenticatedPrivateNode " +
"Authenticated fetch of private resource succeeds")
void fetchPrivateResourceAuthenticatedTest(final Session session) {
LOGGER.info("Integration Test - Authenticated fetch of private resource");
//create private resource
Expand All @@ -234,7 +238,8 @@ void fetchPrivateResourceAuthenticatedTest(final Session session) {

@ParameterizedTest
@MethodSource("provideSessions")
@DisplayName(":authenticatedPrivateNodeAfterLogin Unauthenticated, then auth fetch of private resource")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/authenticatedPrivateNodeAfterLogin " +
"Unauthenticated, then auth fetch of private resource")
void fetchPrivateResourceUnauthAuthTest(final Session session) {
LOGGER.info("Integration Test - Unauthenticated, then auth fetch of private resource");
//create private resource
Expand All @@ -256,7 +261,8 @@ void fetchPrivateResourceUnauthAuthTest(final Session session) {

@ParameterizedTest
@MethodSource("provideSessions")
@DisplayName(":authenticatedMultisessionNode Multiple sessions authenticated in parallel")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/authenticatedMultisessionNode " +
"Multiple sessions authenticated in parallel")
void multiSessionTest(final Session session) {
LOGGER.info("Integration Test - Multiple sessions authenticated in parallel");
//create private resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ static void teardown() {
}

@Test
@DisplayName("./solid-client-java:coreModulesLayerRdfSourceCrud CRUD on RDF resource")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/coreModulesLayerRdfSourceCrud " +
"CRUD on RDF resource")
void crudRdfTest() {
LOGGER.info("Integration Test - CRUD on RDF resource");

Expand Down Expand Up @@ -252,7 +253,8 @@ void crudRdfTest() {
}

@Test
@DisplayName("./solid-client-java:coreModulesLayerContainerCrud create and remove Containers")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/coreModulesLayerContainerCrud" +
" create and remove Containers")
void containerCreateDeleteTest() {
LOGGER.info("Integration Test - create and remove Containers");

Expand Down Expand Up @@ -301,7 +303,7 @@ void containerCreateDeleteTest() {
}

@Test
@DisplayName("./solid-client-java:coreModulesLayerNonRdfSourceCrud " +
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/coreModulesLayerNonRdfSourceCrud " +
"can create, delete, and differentiate between RDF and non-RDF Resources")
void nonRdfTest() {
LOGGER.info("Integration Test - create, delete, and differentiate between RDF and non-RDF Resources");
Expand Down Expand Up @@ -334,7 +336,7 @@ void nonRdfTest() {
}

@Test
@DisplayName("./solid-client-java:coreModulesLayerBlankNodeSupport " +
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/coreModulesLayerBlankNodeSupport " +
"can update statements containing Blank Nodes in different instances of the same model")
void blankNodesTest() {
LOGGER.info("Integration Test - update statements containing Blank Nodes " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ static void teardown() {
}

@Test
@DisplayName("./solid-client-java:baseRdfSourceCrud CRUD on RDF resource")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/baseRdfSourceCrud " +
"CRUD on RDF resource")
void crudRdfTest() {
LOGGER.info("Integration Test - CRUD on RDF resource");

Expand Down Expand Up @@ -189,7 +190,8 @@ void crudRdfTest() {
}

@Test
@DisplayName("./solid-client-java:baseContainerCrud create and remove Containers")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/baseContainerCrud " +
"create and remove Containers")
void containerCreateDeleteTest() {
LOGGER.info("Integration Test - create and remove Containers");

Expand All @@ -202,7 +204,7 @@ void containerCreateDeleteTest() {
}

@Test
@DisplayName("./solid-client-java:blankNodeSupport " +
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/blankNodeSupport " +
"can update statements containing Blank Nodes in different instances of the same model")
void blankNodesTest() {
LOGGER.info("Integration Test - update statements containing Blank Nodes in " +
Expand Down Expand Up @@ -256,7 +258,8 @@ void blankNodesTest() {
}

@Test
@DisplayName("./solid-client-java:podStorageFinding find pod storage from webID")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/podStorageFinding " +
"find pod storage from webID")
void findStorageTest() {
LOGGER.info("Integration Test - find pod storage from webID");

Expand All @@ -271,7 +274,8 @@ void findStorageTest() {
}

@Test
@DisplayName("./solid-client-java:ldpNavigation from a leaf container navigate until finding the root")
@DisplayName("https://w3id.org/inrupt/qa/manifest/solid-client-java/ldpNavigation " +
"from a leaf container navigate until finding the root")
void ldpNavigationTest() {
LOGGER.info("Integration Test - from a leaf container navigate until finding the root");

Expand Down
Loading

0 comments on commit 08afa32

Please sign in to comment.