test: Add pod seeding integration test

This commit is contained in:
Joachim Van Herwegen 2022-04-12 16:22:07 +02:00
parent 283c301f08
commit db906ae872
3 changed files with 64 additions and 2 deletions

View File

@ -20,7 +20,7 @@ For example:
You may optionally specify other parameters
as described in the [Identity Provider documentation](./identity-provider.md#json-api).
For example, to use a pre-existing WebID:
For example, to set up a pod without registering the generated WebID with the Identity Provider:
```json
[
{
@ -28,7 +28,10 @@ For example, to use a pre-existing WebID:
"email": "hello@example.com",
"password": "abc123",
"webId": "https://pod.inrupt.com/example/profile/card#me",
"createWebId": false
"register": false
}
]
```
This feature cannot be used to register pods with pre-existing WebIDs,
which requires an interactive validation step.

View File

@ -0,0 +1,58 @@
import fetch from 'cross-fetch';
import { outputJson } from 'fs-extra';
import type { App } from '../../src/init/App';
import { joinFilePath, joinUrl } from '../../src/util/PathUtil';
import { getPort } from '../util/Util';
import { getDefaultVariables, getTestConfigPath, getTestFolder, instantiateFromConfig, removeFolder } from './Config';
const port = getPort('SeedingPods');
const baseUrl = `http://localhost:${port}/`;
const rootFilePath = getTestFolder('seeding-pods');
describe('A server with seeded pods', (): void => {
const seedingJson = joinFilePath(rootFilePath, 'pods.json');
let app: App;
beforeAll(async(): Promise<void> => {
// Create seeding config
await outputJson(seedingJson, [
{
podName: 'alice',
email: 'alice@example.com',
password: 'alice-password',
},
{
podName: 'bob',
email: 'bob@example.com',
password: 'bob-password',
register: false,
},
]);
const variables = {
...getDefaultVariables(port, baseUrl),
'urn:solid-server:default:variable:seededPodConfigJson': seedingJson,
};
const instances = await instantiateFromConfig(
'urn:solid-server:test:Instances',
getTestConfigPath('server-memory.json'),
variables,
) as Record<string, any>;
({ app } = instances);
await app.start();
});
afterAll(async(): Promise<void> => {
await app.stop();
await removeFolder(rootFilePath);
});
it('has created the requested pods.', async(): Promise<void> => {
let response = await fetch(joinUrl(baseUrl, 'alice/profile/card#me'));
expect(response.status).toBe(200);
response = await fetch(joinUrl(baseUrl, 'bob/profile/card#me'));
expect(response.status).toBe(200);
});
});

View File

@ -19,6 +19,7 @@ const portNames = [
'PodQuota',
'RedisResourceLocker',
'RestrictedIdentity',
'SeedingPods',
'ServerFetch',
'SetupMemory',
'SparqlStorage',