diff --git a/documentation/seeding-pods.md b/documentation/seeding-pods.md index cdd505d94..a5f519641 100644 --- a/documentation/seeding-pods.md +++ b/documentation/seeding-pods.md @@ -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. diff --git a/test/integration/SeedingPods.test.ts b/test/integration/SeedingPods.test.ts new file mode 100644 index 000000000..349739fd2 --- /dev/null +++ b/test/integration/SeedingPods.test.ts @@ -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 => { + // 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; + ({ app } = instances); + await app.start(); + }); + + afterAll(async(): Promise => { + await app.stop(); + await removeFolder(rootFilePath); + }); + + it('has created the requested pods.', async(): Promise => { + 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); + }); +}); diff --git a/test/util/Util.ts b/test/util/Util.ts index 9e89229fd..d6ed25f25 100644 --- a/test/util/Util.ts +++ b/test/util/Util.ts @@ -19,6 +19,7 @@ const portNames = [ 'PodQuota', 'RedisResourceLocker', 'RestrictedIdentity', + 'SeedingPods', 'ServerFetch', 'SetupMemory', 'SparqlStorage',