Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@ startSolidNextcloud server

And then run the tester interactively and with code mounted from the host:
```
# docker tag solidtestsuite/solid-crud-tests:v7.0.5 solid-crud-tests

docker run --rm --network=testnet --env COOKIE="$COOKIE_server" --env COOKIE_ALICE="$COOKIE_server" --env COOKIE_BOB="$COOKIE_thirdparty" --env-file ./env-vars-testers.list -it -v /Users/michiel/gh/solid-contrib/solid-crud-tests/test:/app/test --name tester -v /Users/michiel/hevel:/hevel solid-crud-tests /bin/bash
```

And then inside that:
```
./node_modules/.bin/jest test/surface/notifications.test.ts
```


For Wh2Ws testing:

docker exec -it pubsub php server/serverWh2Ws.php
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module.exports = {
roots: ["<rootDir>/test"],
preset: "ts-jest",
testEnvironment: "node",
testTimeout: 60000,
testTimeout: 6000,
verbose: false,
runner: "jest-serial-runner",
collectCoverage: false,
Expand Down
12 changes: 8 additions & 4 deletions test/helpers/NotificationsClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class NotificationsClient {
this.sentHook = [];
this.resourceUrl = resourceUrl;
this.authFetcher = authFetcher;
this.disabled = !!process.env.SKIP_WPS;
this.disabled = !!process.env.SKIP_WPS && !!process.env.SKIP_SECURE_WEBSOCKETS && !!process.env.SKIP_WEBHOOKS;
this.discoveryLinks = {
insecureWs: undefined,
storageWide: undefined,
Expand All @@ -77,6 +77,7 @@ export class NotificationsClient {
method: "HEAD",
});
const linkHeaders = resourceFetchResult.headers.raw()["link"];
console.log({linkHeaders});
if (Array.isArray(linkHeaders) && linkHeaders.length > 0) {
let obj = {};
for (let i = 0; i < linkHeaders.length; i++) {
Expand Down Expand Up @@ -139,27 +140,30 @@ export class NotificationsClient {
}

async getReady(): Promise<void> {
console.log('in getReady!');
if (this.disabled) {
console.log('disabled, not getting ready!');
return;
}
const descriptions = await this.getLinksToNotifications();
console.log({ descriptions });
if (
typeof descriptions.insecureWs === "string" &&
descriptions.insecureWs.length > 0
descriptions.insecureWs.length > 0 && !process.env.SKIP_WPS
) {
// console.log("get ready for insecure websockets");
await this.setupInsecureWs(descriptions.insecureWs);
}
if (
typeof descriptions.storageWide === "string" &&
descriptions.storageWide.length > 0
descriptions.storageWide.length > 0 && !process.env.SKIP_SECURE_WEBSOCKETS
) {
// console.log("get ready for storage wide");
await this.subscribeToChannels(descriptions.storageWide);
}
if (
typeof descriptions.resourceSpecific === "string" &&
descriptions.resourceSpecific.length > 0
descriptions.resourceSpecific.length > 0 && !process.env.SKIP_WEBHOOKS
) {
// console.log("get ready for resource specific");
await this.subscribeToChannels(descriptions.resourceSpecific);
Expand Down
25 changes: 20 additions & 5 deletions test/surface/notifications.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe("Notifications", () => {
);
// console.log({ newCookie });
}
console.log("getAuthFetcher", oidcIssuer, newCookie, appOrigin);
authFetcher = await getAuthFetcher(oidcIssuer, newCookie, appOrigin);
});
describe("When overwriting plain text with plain text using PUT", () => {
Expand Down Expand Up @@ -124,7 +125,9 @@ describe("Notifications", () => {
authFetcher,
8123 // webHooksPort
);
console.log('getting ready');
await notificationsClientResource.getReady();
console.log('got ready');
const headers = {
"Content-Type": "text/plain",
};
Expand Down Expand Up @@ -170,11 +173,23 @@ describe("Notifications", () => {
ifSecureWebsockets(
"emits secure websockets notification on the resource",
() => {
// FIXME: expect the new format!
// expect(notificationsClientResource.receivedSecure).toEqual(
// expect.arrayContaining([`ack ${resourceUrl}`, `pub ${resourceUrl}`])
// );
}
expect(Array.isArray(notificationsClientResource.receivedSecure)).toEqual(true);
expect(notificationsClientResource.receivedSecure.length).toEqual(1);
const msgObj = JSON.parse(notificationsClientResource.receivedSecure[0]);
expect(Array.isArray(msgObj["@context"])).toEqual(true);
expect(Array.isArray(msgObj["type"])).toEqual(true);
expect(Array.isArray(msgObj["object"]["type"])).toEqual(true);
expect(
msgObj["@context"].indexOf(
"https://www.w3.org/ns/solid/notification/v1"
)
).not.toEqual(-1);
expect(msgObj["type"][0]).toEqual("Update");
expect(msgObj["object"]["id"]).toEqual(resourceUrl);
expect(
msgObj["object"]["type"].indexOf("http://www.w3.org/ns/ldp#Resource")
).not.toEqual(-1);
}
);
ifWebhooks(
"webhooks advertised using server-wide or resource-specific Link header",
Expand Down