mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
chore: Remove assumption that DataAccessors have a root container by default
This commit is contained in:
@@ -3,14 +3,23 @@ import * as url from 'url';
|
||||
import { namedNode, quad } from '@rdfjs/data-model';
|
||||
import { Parser } from 'n3';
|
||||
import type { MockResponse } from 'node-mocks-http';
|
||||
import { RootContainerInitializer } from '../../src/init/RootContainerInitializer';
|
||||
import { LDP } from '../../src/util/UriConstants';
|
||||
import { BasicConfig } from '../configs/BasicConfig';
|
||||
import { BasicHandlersConfig } from '../configs/BasicHandlersConfig';
|
||||
import { BASE } from '../configs/Util';
|
||||
import { call } from '../util/Util';
|
||||
|
||||
describe('An integrated AuthenticatedLdpHandler', (): void => {
|
||||
describe('with simple handlers', (): void => {
|
||||
const handler = new BasicConfig().getHttpHandler();
|
||||
const config = new BasicConfig();
|
||||
const handler = config.getHttpHandler();
|
||||
|
||||
beforeAll(async(): Promise<void> => {
|
||||
// Initialize store
|
||||
const initializer = new RootContainerInitializer(BASE, config.store);
|
||||
await initializer.handleSafe();
|
||||
});
|
||||
|
||||
it('can add, read and delete data based on incoming requests.', async(): Promise<void> => {
|
||||
// POST
|
||||
@@ -61,7 +70,14 @@ describe('An integrated AuthenticatedLdpHandler', (): void => {
|
||||
});
|
||||
|
||||
describe('with simple PATCH handlers', (): void => {
|
||||
const handler = new BasicHandlersConfig().getHttpHandler();
|
||||
const config = new BasicHandlersConfig();
|
||||
const handler = config.getHttpHandler();
|
||||
|
||||
beforeAll(async(): Promise<void> => {
|
||||
// Initialize store
|
||||
const initializer = new RootContainerInitializer(BASE, config.store);
|
||||
await initializer.handleSafe();
|
||||
});
|
||||
|
||||
it('can handle simple SPARQL updates.', async(): Promise<void> => {
|
||||
// POST
|
||||
@@ -126,7 +142,14 @@ describe('An integrated AuthenticatedLdpHandler', (): void => {
|
||||
});
|
||||
|
||||
describe('with simple PUT handlers', (): void => {
|
||||
const handler = new BasicHandlersConfig().getHttpHandler();
|
||||
const config = new BasicHandlersConfig();
|
||||
const handler = config.getHttpHandler();
|
||||
|
||||
beforeAll(async(): Promise<void> => {
|
||||
// Initialize store
|
||||
const initializer = new RootContainerInitializer(BASE, config.store);
|
||||
await initializer.handleSafe();
|
||||
});
|
||||
|
||||
it('should overwrite the content on PUT request.', async(): Promise<void> => {
|
||||
// POST
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import type { MockResponse } from 'node-mocks-http';
|
||||
import { RootContainerInitializer } from '../../src/init/RootContainerInitializer';
|
||||
import { BasicHandlersWithAclConfig } from '../configs/BasicHandlersWithAclConfig';
|
||||
import { BASE } from '../configs/Util';
|
||||
import { AclTestHelper } from '../util/TestHelpers';
|
||||
import { call } from '../util/Util';
|
||||
|
||||
@@ -9,6 +11,12 @@ describe('A server with authorization', (): void => {
|
||||
const { store } = config;
|
||||
const aclHelper = new AclTestHelper(store, 'http://test.com/');
|
||||
|
||||
beforeAll(async(): Promise<void> => {
|
||||
// Initialize store
|
||||
const initializer = new RootContainerInitializer(BASE, config.store);
|
||||
await initializer.handleSafe();
|
||||
});
|
||||
|
||||
it('can create new entries.', async(): Promise<void> => {
|
||||
await aclHelper.setSimpleAcl({ read: true, write: true, append: true }, 'agent');
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { createReadStream, mkdirSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import * as rimraf from 'rimraf';
|
||||
import { RootContainerInitializer } from '../../src/init/RootContainerInitializer';
|
||||
import { RepresentationMetadata } from '../../src/ldp/representation/RepresentationMetadata';
|
||||
import { FileDataAccessor } from '../../src/storage/accessors/FileDataAccessor';
|
||||
import { InMemoryDataAccessor } from '../../src/storage/accessors/InMemoryDataAccessor';
|
||||
@@ -40,6 +41,10 @@ describe.each([ dataAccessorStore, inMemoryDataAccessorStore ])('A server using
|
||||
// Make sure the root directory exists
|
||||
mkdirSync(rootFilePath, { recursive: true });
|
||||
|
||||
// Initialize store
|
||||
const initializer = new RootContainerInitializer(BASE, config.store);
|
||||
await initializer.handleSafe();
|
||||
|
||||
// Use store instead of file access so tests also work for non-file backends
|
||||
await config.store.setRepresentation({ path: `${BASE}/permanent.txt` }, {
|
||||
binary: true,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { mkdirSync } from 'fs';
|
||||
import * as rimraf from 'rimraf';
|
||||
import { RootContainerInitializer } from '../../src/init/RootContainerInitializer';
|
||||
import type { HttpHandler } from '../../src/server/HttpHandler';
|
||||
import { FileDataAccessor } from '../../src/storage/accessors/FileDataAccessor';
|
||||
import { InMemoryDataAccessor } from '../../src/storage/accessors/InMemoryDataAccessor';
|
||||
@@ -35,6 +36,10 @@ describe.each(configs)('A server using a %s', (name, configFn): void => {
|
||||
config = configFn(rootFilePath);
|
||||
handler = config.getHttpHandler();
|
||||
fileHelper = new FileTestHelper(handler, new URL(BASE));
|
||||
|
||||
// Initialize store
|
||||
const initializer = new RootContainerInitializer(BASE, config.store);
|
||||
await initializer.handleSafe();
|
||||
});
|
||||
|
||||
afterAll(async(): Promise<void> => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import streamifyArray from 'streamify-array';
|
||||
import { RootContainerInitializer } from '../../src/init/RootContainerInitializer';
|
||||
import type { Representation } from '../../src/ldp/representation/Representation';
|
||||
import { RepresentationMetadata } from '../../src/ldp/representation/RepresentationMetadata';
|
||||
import { InMemoryDataAccessor } from '../../src/storage/accessors/InMemoryDataAccessor';
|
||||
@@ -13,6 +14,7 @@ import { SingleThreadedResourceLocker } from '../../src/util/locking/SingleThrea
|
||||
import { WrappedExpiringResourceLocker } from '../../src/util/locking/WrappedExpiringResourceLocker';
|
||||
import { guardedStreamFrom } from '../../src/util/StreamUtil';
|
||||
import { CONTENT_TYPE } from '../../src/util/UriConstants';
|
||||
import { BASE } from '../configs/Util';
|
||||
|
||||
describe('A LockingResourceStore', (): void => {
|
||||
let path: string;
|
||||
@@ -28,6 +30,10 @@ describe('A LockingResourceStore', (): void => {
|
||||
path = `${base}path`;
|
||||
source = new DataAccessorBasedStore(new InMemoryDataAccessor(base), new SingleRootIdentifierStrategy(base));
|
||||
|
||||
// Initialize store
|
||||
const initializer = new RootContainerInitializer(BASE, source);
|
||||
await initializer.handleSafe();
|
||||
|
||||
locker = new SingleThreadedResourceLocker();
|
||||
expiringLocker = new WrappedExpiringResourceLocker(locker, 1000);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import { join } from 'path';
|
||||
import fetch from 'cross-fetch';
|
||||
import type { HttpServerFactory } from '../../src/server/HttpServerFactory';
|
||||
import { readableToString } from '../../src/util/StreamUtil';
|
||||
import { instantiateFromConfig } from '../configs/Util';
|
||||
import { initServerStore, instantiateFromConfig } from '../configs/Util';
|
||||
|
||||
const port = 6003;
|
||||
const baseUrl = `http://localhost:${port}/`;
|
||||
@@ -21,6 +21,7 @@ describe('A server with a pod handler', (): void => {
|
||||
},
|
||||
) as HttpServerFactory;
|
||||
server = factory.startServer(port);
|
||||
await initServerStore(server, baseUrl);
|
||||
});
|
||||
|
||||
afterAll(async(): Promise<void> => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { RootContainerInitializer } from '../../src/init/RootContainerInitializer';
|
||||
import { SparqlDataAccessor } from '../../src/storage/accessors/SparqlDataAccessor';
|
||||
import { INTERNAL_QUADS } from '../../src/util/ContentTypes';
|
||||
import { SingleRootIdentifierStrategy } from '../../src/util/identifiers/SingleRootIdentifierStrategy';
|
||||
@@ -13,6 +14,12 @@ describeIf('docker', 'a server with a SPARQL endpoint as storage', (): void => {
|
||||
const handler = config.getHttpHandler();
|
||||
const fileHelper = new FileTestHelper(handler, new URL(BASE));
|
||||
|
||||
beforeAll(async(): Promise<void> => {
|
||||
// Initialize store
|
||||
const initializer = new RootContainerInitializer(BASE, config.store);
|
||||
await initializer.handleSafe();
|
||||
});
|
||||
|
||||
it('can add a Turtle file to the store.', async():
|
||||
Promise<void> => {
|
||||
// POST
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { Server } from 'http';
|
||||
import fetch from 'cross-fetch';
|
||||
import WebSocket from 'ws';
|
||||
import type { HttpServerFactory } from '../../src/server/HttpServerFactory';
|
||||
import { instantiateFromConfig } from '../configs/Util';
|
||||
import { initServerStore, instantiateFromConfig } from '../configs/Util';
|
||||
|
||||
const port = 6001;
|
||||
const serverUrl = `http://localhost:${port}/`;
|
||||
@@ -20,6 +20,7 @@ describe('A server with the Solid WebSockets API behind a proxy', (): void => {
|
||||
},
|
||||
) as HttpServerFactory;
|
||||
server = factory.startServer(port);
|
||||
await initServerStore(server, serverUrl, headers);
|
||||
});
|
||||
|
||||
afterAll(async(): Promise<void> => {
|
||||
|
||||
Reference in New Issue
Block a user