From 2ac795b1564362b7aa4e0fa7a14b097bbcb07a7c Mon Sep 17 00:00:00 2001 From: Stijn Taelemans Date: Fri, 14 Jan 2022 10:50:43 +0100 Subject: [PATCH 1/6] chore: remove credentials from post request --- packages/solid-crs-manage/lib/app.services.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/solid-crs-manage/lib/app.services.ts b/packages/solid-crs-manage/lib/app.services.ts index 7f3608b1..3cbbb7d8 100644 --- a/packages/solid-crs-manage/lib/app.services.ts +++ b/packages/solid-crs-manage/lib/app.services.ts @@ -31,9 +31,6 @@ export const createPod = async (solidService: SolidSDKService): Promise webId, createPod: 'on', podName: v5(webId, 'a2e08b56-67b9-49b9-894f-696052dbef9a'), - email: `${v5(webId, 'a2e08b56-67b9-49b9-894f-696052dbef9a')}@digita.ai`, - password: 'a', - confirmPassword: 'a', }), } ); From 276f5659ab25440eb51677b14ec843fc3a0707c4 Mon Sep 17 00:00:00 2001 From: Stijn Taelemans Date: Fri, 14 Jan 2022 11:23:57 +0100 Subject: [PATCH 2/6] fix: fixed semcom node uri --- packages/solid-crs-manage/.env.production | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/solid-crs-manage/.env.production b/packages/solid-crs-manage/.env.production index 585224bc..14d6db71 100644 --- a/packages/solid-crs-manage/.env.production +++ b/packages/solid-crs-manage/.env.production @@ -1,4 +1,4 @@ -VITE_SEMCOM_NODE_URI=http://localhost:3003 +VITE_SEMCOM_NODE_URI=https://solid-crs.netwerkdigitaalerfgoed.nl/semcom VITE_TERM_ENDPOINT=https://termennetwerk-api.netwerkdigitaalerfgoed.nl/graphql VITE_ID_PROXY_URI=https://auth.netwerkdigitaalerfgoed.nl/ VITE_WEBID_URI=https://webid.netwerkdigitaalerfgoed.nl/ From dd707c0c0394c1575aeb675e4da84cbc21e36020 Mon Sep 17 00:00:00 2001 From: Stijn Taelemans Date: Fri, 14 Jan 2022 11:35:38 +0100 Subject: [PATCH 3/6] fix: set correct path when logging in WIP --- packages/solid-crs-manage/lib/app.machine.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/solid-crs-manage/lib/app.machine.ts b/packages/solid-crs-manage/lib/app.machine.ts index b6b07a98..a1e75f45 100644 --- a/packages/solid-crs-manage/lib/app.machine.ts +++ b/packages/solid-crs-manage/lib/app.machine.ts @@ -385,6 +385,7 @@ export const appMachine = ( * The user has not been authenticated. */ [AppAuthenticateStates.UNAUTHENTICATED]: { + entry: send(() => new NavigatedEvent(`/login`)), on: { [AppEvents.LOGGED_IN]: { target: AppAuthenticateStates.AUTHENTICATED, From 3846c69c15eb02f3e423a4f5b0e3b21fea189f44 Mon Sep 17 00:00:00 2001 From: Stijn Taelemans Date: Mon, 17 Jan 2022 15:08:17 +0100 Subject: [PATCH 4/6] fix: 403 unauthorized errors on new objects WIP --- .../lib/solid/solid-store.spec.ts | 53 +++++++++++++++++-- .../solid-crs-core/lib/solid/solid-store.ts | 6 ++- packages/solid-crs-core/package.json | 4 +- 3 files changed, 54 insertions(+), 9 deletions(-) diff --git a/packages/solid-crs-core/lib/solid/solid-store.spec.ts b/packages/solid-crs-core/lib/solid/solid-store.spec.ts index 74629826..2f9f92a6 100644 --- a/packages/solid-crs-core/lib/solid/solid-store.spec.ts +++ b/packages/solid-crs-core/lib/solid/solid-store.spec.ts @@ -349,6 +349,9 @@ describe('SolidStore', () => { describe('setPublicAccess', () => { + const resourceUri = 'https://test.uri/resource'; + const containerUri = 'https://test.uri/container/'; + beforeEach(() => { (client.access.getPublicAccess as any) = jest.fn(async () => ({ @@ -365,7 +368,7 @@ describe('SolidStore', () => { it('should update existing acl when one is present', async () => { - await service.setPublicAccess('https://test.uri/'); + await service.setPublicAccess(resourceUri); expect(client.access.setPublicAccess).toHaveBeenCalled(); }); @@ -376,7 +379,7 @@ describe('SolidStore', () => { read: true, })); - await service.setPublicAccess('https://test.uri/'); + await service.setPublicAccess(resourceUri); expect(client.access.setPublicAccess).not.toHaveBeenCalled(); }); @@ -385,7 +388,47 @@ describe('SolidStore', () => { let aclCreated: boolean; - fetchMock.mockOnce(async () => { + fetchMock.mockOnce(async (req) => { + + const body = await req.text(); + + expect(body).toContain(`acl:accessTo <${resourceUri}>`); + + aclCreated = true; + + return { body: 'created', init: { status: 201 } }; + + }); + + (client.access.getPublicAccess as any) = jest.fn(async () => { + + if (!aclCreated) { + + return Promise.reject({ response: { status: 404 } }); + + } + + return { + read: false, + }; + + }); + + await service.setPublicAccess(resourceUri); + expect(client.access.setPublicAccess).toHaveBeenCalled(); + + }); + + it('should set default access for containers', async () => { + + let aclCreated: boolean; + + fetchMock.mockOnce(async (req) => { + + const body = await req.text(); + + expect(body).toContain(`acl:accessTo <./>`); + expect(body).toContain(`acl:default <./>`); aclCreated = true; @@ -407,7 +450,7 @@ describe('SolidStore', () => { }); - await service.setPublicAccess('https://test.uri/'); + await service.setPublicAccess(containerUri); expect(client.access.setPublicAccess).toHaveBeenCalled(); }); @@ -418,7 +461,7 @@ describe('SolidStore', () => { (client.access.getPublicAccess as any) = jest.fn(async () => Promise.reject(errResponse)); - await expect(service.setPublicAccess('https://test.uri/')).rejects.toEqual(errResponse); + await expect(service.setPublicAccess(resourceUri)).rejects.toEqual(errResponse); }); diff --git a/packages/solid-crs-core/lib/solid/solid-store.ts b/packages/solid-crs-core/lib/solid/solid-store.ts index 2d1201c1..bd55e43d 100644 --- a/packages/solid-crs-core/lib/solid/solid-store.ts +++ b/packages/solid-crs-core/lib/solid/solid-store.ts @@ -259,14 +259,16 @@ export class SolidStore implements Store { <#public> a acl:Authorization; acl:agentClass foaf:Agent; - acl:accessTo <${target}>; + acl:accessTo <${target.endsWith('/') ? './' : target}>; + ${ target.endsWith('/') ? 'acl:default <./>;' : '' } acl:mode acl:Read. # The owner has full access to the entire directory. <#owner> a acl:Authorization; acl:agent <${webId}>; - acl:accessTo <${target}>; + acl:accessTo <${target.endsWith('/') ? './' : target}>; + ${ target.endsWith('/') ? 'acl:default <./>;' : '' } acl:mode acl:Read, acl:Write, acl:Control.`; await this.getSession().fetch(`${target}.acl`, { diff --git a/packages/solid-crs-core/package.json b/packages/solid-crs-core/package.json index ff1d9f2e..9c9e1053 100644 --- a/packages/solid-crs-core/package.json +++ b/packages/solid-crs-core/package.json @@ -75,7 +75,7 @@ ], "coverageThreshold": { "global": { - "branches": 90.14, + "branches": 90.3, "statements": 97.55, "lines": 97.43, "functions": 99.4 @@ -104,4 +104,4 @@ "testEnvironment": "jsdom", "maxWorkers": 4 } -} +} \ No newline at end of file From 13c84b0ba4025d81a9cecd62e25a400a3c95d9a3 Mon Sep 17 00:00:00 2001 From: Stijn Taelemans Date: Mon, 17 Jan 2022 15:16:24 +0100 Subject: [PATCH 5/6] chore: run commit tests in line WIP --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 086b98b6..758e6510 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "release:antora": "echo \"$(yaml set docs/antora.yml version $(dot-json lerna.json version))\" > docs/antora.yml", "start": "lerna run start --parallel", "start:watch": "lerna run start:watch --parallel", - "test": "lerna run test --since HEAD", + "test": "lerna run test --since HEAD --stream --concurrency 1", "test:all": "lerna run test", "test:ci": "lerna run test:ci" }, From bb7a78e6edc9cb2b3d3ccb5c32bc94cd5c3bbcfa Mon Sep 17 00:00:00 2001 From: Stijn Taelemans Date: Mon, 17 Jan 2022 15:32:46 +0100 Subject: [PATCH 6/6] test: fix tests WIP --- .../solid-crs-manage/lib/app.machine.spec.ts | 33 +++++++++++++------ packages/solid-crs-manage/package.json | 6 ++-- packages/solid-crs-manage/tests/setup.ts | 2 ++ 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/packages/solid-crs-manage/lib/app.machine.spec.ts b/packages/solid-crs-manage/lib/app.machine.spec.ts index 0f15abb9..cc640ad4 100644 --- a/packages/solid-crs-manage/lib/app.machine.spec.ts +++ b/packages/solid-crs-manage/lib/app.machine.spec.ts @@ -125,27 +125,40 @@ describe('AppMachine', () => { }); - it('should dismiss alert in context when sending dismissAlert', () => { + it('should dismiss alert in context when sending DismissAlertEvent', () => { const alert: Alert = { type: 'success', message: 'foo' }; - machine = interpret( + const machineWithAlerts = interpret( appMachine( solidService, new CollectionMemoryStore([ collection1, collection2 ]), new CollectionObjectMemoryStore([ object1 ]), collection1, object1 - ) - .withContext({ - alerts: [ alert ], - }), + ).withContext({ + alerts: [ alert ], + }), ); - machine.start(); - expect(machine.state.context.alerts.length).toBe(1); - machine.send(new DismissAlertEvent(alert)); - expect(machine.state.context.alerts.length).toBe(0); + machineWithAlerts.start(); + + const first = true; + + machineWithAlerts.onChange((context) => { + + if (first) { + + expect(context.alerts.length).toBe(1); + machineWithAlerts.send(new DismissAlertEvent(alert)); + + } else { + + expect(context.alerts.length).toBe(0); + + } + + }); }); diff --git a/packages/solid-crs-manage/package.json b/packages/solid-crs-manage/package.json index 248b5533..dc681383 100644 --- a/packages/solid-crs-manage/package.json +++ b/packages/solid-crs-manage/package.json @@ -91,10 +91,10 @@ ], "coverageThreshold": { "global": { - "statements": 85.67, + "statements": 85.49, "branches": 85.14, - "lines": 86.9, - "functions": 71.75 + "lines": 86.7, + "functions": 71.26 } }, "automock": false, diff --git a/packages/solid-crs-manage/tests/setup.ts b/packages/solid-crs-manage/tests/setup.ts index 9be7ebdc..5ecf88d7 100644 --- a/packages/solid-crs-manage/tests/setup.ts +++ b/packages/solid-crs-manage/tests/setup.ts @@ -62,6 +62,8 @@ import { AuthenticateRootComponent } from '../lib/features/authenticate/authenti }, }); +(core.routerEventsConfig as any) = () => ({}); + /** * Enable mocks for fetch. */