mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: Remove unneeded pod files
This commit is contained in:
@@ -1,75 +0,0 @@
|
||||
import type { Server } from 'http';
|
||||
import fetch from 'cross-fetch';
|
||||
import type { Initializer } from '../../src/init/Initializer';
|
||||
import type { HttpServerFactory } from '../../src/server/HttpServerFactory';
|
||||
import { joinFilePath } from '../../src/util/PathUtil';
|
||||
import { readableToString } from '../../src/util/StreamUtil';
|
||||
import { getPort } from '../util/Util';
|
||||
import { getTestConfigPath, instantiateFromConfig } from './Config';
|
||||
|
||||
const port = getPort('PodCreation');
|
||||
const baseUrl = `http://localhost:${port}/`;
|
||||
|
||||
describe('A server with a pod handler', (): void => {
|
||||
let initializer: Initializer;
|
||||
let factory: HttpServerFactory;
|
||||
let server: Server;
|
||||
const settings = { login: 'alice', webId: 'http://test.com/#alice', name: 'Alice Bob' };
|
||||
|
||||
beforeAll(async(): Promise<void> => {
|
||||
const instances = await instantiateFromConfig(
|
||||
'urn:solid-server:test:Instances',
|
||||
getTestConfigPath('server-without-auth.json'),
|
||||
{
|
||||
'urn:solid-server:default:variable:port': port,
|
||||
'urn:solid-server:default:variable:baseUrl': baseUrl,
|
||||
'urn:solid-server:default:variable:podTemplateFolder': joinFilePath(__dirname, '../assets/templates'),
|
||||
},
|
||||
) as Record<string, any>;
|
||||
({ factory, initializer } = instances);
|
||||
await initializer.handleSafe();
|
||||
server = factory.startServer(port);
|
||||
});
|
||||
|
||||
afterAll(async(): Promise<void> => {
|
||||
await new Promise<void>((resolve, reject): void => {
|
||||
server.close((error): void => error ? reject(error) : resolve());
|
||||
});
|
||||
});
|
||||
|
||||
it('creates a pod when posting PodSettings to /pods.', async(): Promise<void> => {
|
||||
const pod = `${baseUrl}${settings.login}/`;
|
||||
|
||||
// Pod should not exist yet
|
||||
let res = await fetch(pod);
|
||||
expect(res.status).toBe(404);
|
||||
|
||||
// Create pod call should return the address of the new pod
|
||||
res = await fetch(`${baseUrl}pods`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'content-type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(settings),
|
||||
});
|
||||
expect(res.status).toBe(201);
|
||||
expect(res.headers.get('location')).toBe(`${baseUrl}${settings.login}/`);
|
||||
|
||||
// Check if all resources are created
|
||||
res = await fetch(`${pod}.acl`);
|
||||
expect(res.status).toBe(200);
|
||||
let body = await readableToString(res.body as any);
|
||||
expect(body).toContain(`acl:agent <${settings.webId}>`);
|
||||
|
||||
res = await fetch(`${pod}profile/card`);
|
||||
expect(res.status).toBe(200);
|
||||
expect(res.headers.get('content-type')).toBe('text/turtle');
|
||||
body = await readableToString(res.body as any);
|
||||
expect(body).toBe(`@prefix foaf: <http://xmlns.com/foaf/0.1/>.
|
||||
|
||||
<${settings.webId}>
|
||||
a foaf:Person ;
|
||||
foaf:name "${settings.name}".
|
||||
`);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user