diff --git a/test/integration/Identity.test.ts b/test/integration/Identity.test.ts index 5a28fc4ce..53ab9e4b8 100644 --- a/test/integration/Identity.test.ts +++ b/test/integration/Identity.test.ts @@ -84,11 +84,14 @@ describe('A Solid server with IDP', (): void => { acl:default <./>; acl:mode acl:Read, acl:Write, acl:Control. `; - await fetch(`${container}.acl`, { + const res = await fetch(`${container}.acl`, { method: 'PUT', headers: { 'content-type': 'text/turtle' }, body: aclTurtle, }); + if (res.status !== 201) { + throw new Error('Something went wrong initializing the test ACL'); + } }); afterAll(async(): Promise => { diff --git a/test/integration/LdpHandlerWithAuth.test.ts b/test/integration/LdpHandlerWithAuth.test.ts index adb6fad59..6d95ce600 100644 --- a/test/integration/LdpHandlerWithAuth.test.ts +++ b/test/integration/LdpHandlerWithAuth.test.ts @@ -1,7 +1,7 @@ import { promises as fsPromises } from 'fs'; import fetch from 'cross-fetch'; import type { ResourceStore, App } from '../../src/'; -import { BasicRepresentation, isSystemError, joinFilePath } from '../../src/'; +import { BasicRepresentation, isSystemError, joinFilePath, joinUrl } from '../../src/'; import { AclHelper } from '../util/AclHelper'; import { deleteResource, getResource, postResource, putResource } from '../util/FetchUtil'; import { getPort } from '../util/Util'; @@ -234,4 +234,36 @@ describe.each(stores)('An LDP handler with auth using %s', (name, { storeConfig, const response = await getResource(identifier.path); expect(await response.text()).toContain('valid data'); }); + + it('prevents creation of intermediate intermediate containers if they are not allowed.', async(): Promise => { + const url = joinUrl(baseUrl, 'foo/bar/'); + // Not allowed since there are no append permissions on the base container + await aclHelper.setSimpleAcl(baseUrl, { + permissions: { write: true }, + agentClass: 'agent', + default: true, + }); + let response = await fetch(url, { method: 'PUT' }); + expect(response.status).toBe(401); + + // Not allowed since there are no write permissions for the target + await aclHelper.setSimpleAcl(baseUrl, { + permissions: { append: true }, + agentClass: 'agent', + accessTo: true, + }); + response = await fetch(url, { method: 'PUT' }); + expect(response.status).toBe(401); + + // This covers all required permissions + await aclHelper.setSimpleAcl(baseUrl, [ + { permissions: { append: true }, + agentClass: 'agent', + accessTo: true }, + { permissions: { write: true }, + agentClass: 'agent', + default: true }, + ]); + await putResource(url, { contentType: 'text/plain', exists: false }); + }); });