mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
test: Add integration test for intermediate containers
This commit is contained in:
parent
d5bcec704c
commit
47c54abe22
@ -84,11 +84,14 @@ describe('A Solid server with IDP', (): void => {
|
|||||||
acl:default <./>;
|
acl:default <./>;
|
||||||
acl:mode acl:Read, acl:Write, acl:Control.
|
acl:mode acl:Read, acl:Write, acl:Control.
|
||||||
`;
|
`;
|
||||||
await fetch(`${container}.acl`, {
|
const res = await fetch(`${container}.acl`, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: { 'content-type': 'text/turtle' },
|
headers: { 'content-type': 'text/turtle' },
|
||||||
body: aclTurtle,
|
body: aclTurtle,
|
||||||
});
|
});
|
||||||
|
if (res.status !== 201) {
|
||||||
|
throw new Error('Something went wrong initializing the test ACL');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async(): Promise<void> => {
|
afterAll(async(): Promise<void> => {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { promises as fsPromises } from 'fs';
|
import { promises as fsPromises } from 'fs';
|
||||||
import fetch from 'cross-fetch';
|
import fetch from 'cross-fetch';
|
||||||
import type { ResourceStore, App } from '../../src/';
|
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 { AclHelper } from '../util/AclHelper';
|
||||||
import { deleteResource, getResource, postResource, putResource } from '../util/FetchUtil';
|
import { deleteResource, getResource, postResource, putResource } from '../util/FetchUtil';
|
||||||
import { getPort } from '../util/Util';
|
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);
|
const response = await getResource(identifier.path);
|
||||||
expect(await response.text()).toContain('valid data');
|
expect(await response.text()).toContain('valid data');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('prevents creation of intermediate intermediate containers if they are not allowed.', async(): Promise<void> => {
|
||||||
|
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 });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user