fix tests for v7 upgrade

main
Jackson Morgan 11 months ago
parent b605fdc30a
commit d9b90e84b4
  1. 2843
      package-lock.json
  2. 8
      packages/solid-react/test/test-server/configs/components-config/unauthenticatedServer.json
  3. 5
      packages/solid-react/test/test-server/configs/solid-css-seed.json
  4. 19
      packages/solid-react/test/test-server/solidServer.helper.ts
  5. 1
      packages/solid/babel.config.js
  6. 1
      packages/solid/data/.internal/accounts/cookies/6ee53737-216c-4984-b530-95b3ff8784ea$.json
  7. 1
      packages/solid/data/.internal/accounts/data/93dbc3a7-58f0-424f-be3d-96a7f9eedf33$.json
  8. 1
      packages/solid/data/.internal/accounts/index/owner/e7464d2a-9987-4564-b7e2-670a3c5c1af4$.json
  9. 1
      packages/solid/data/.internal/accounts/index/password/decb4d7a-0853-47b0-aeae-d1f98506052f$.json
  10. 1
      packages/solid/data/.internal/accounts/index/password/email/hello@example.com$.json
  11. 1
      packages/solid/data/.internal/accounts/index/pod/b9f98f5e-653d-480c-9e04-78a567580c24$.json
  12. 1
      packages/solid/data/.internal/accounts/index/pod/baseUrl/http%3A%2F%2Flocalhost%3A3001%2Fexample%2F$.json
  13. 1
      packages/solid/data/.internal/accounts/index/webIdLink/28985848-10cd-429f-85fa-d1cc78484c52$.json
  14. 1
      packages/solid/data/.internal/accounts/index/webIdLink/webId/http%3A%2F%2Flocalhost%3A3001%2Fexample%2Fprofile%2Fcard#me$.json
  15. 1
      packages/solid/data/.internal/idp/keys/cookie-secret$.json
  16. 1
      packages/solid/data/.internal/idp/keys/jwks$.json
  17. 1
      packages/solid/data/.internal/setup/current-base-url$.json
  18. 1
      packages/solid/data/.internal/setup/current-server-version$.json
  19. 1
      packages/solid/data/.internal/setup/v6-migration$.json
  20. 26
      packages/solid/data/example/.acl
  21. 1
      packages/solid/data/example/.meta
  22. 27
      packages/solid/data/example/README$.markdown
  23. 14
      packages/solid/data/example/README.acl
  24. 12
      packages/solid/data/example/profile/card$.ttl
  25. 19
      packages/solid/data/example/profile/card.acl
  26. 4
      packages/solid/jest.config.js
  27. 3
      packages/solid/package.json
  28. 9
      packages/solid/test/Integration.test.ts
  29. 26
      packages/solid/test/authFetch.helper.ts
  30. 3
      packages/solid/test/solidServer.helper.ts

2843
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -1,9 +1,8 @@
{
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^6.0.0/components/context.jsonld",
"@context": "https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^7.0.0/components/context.jsonld",
"import": [
"css:config/app/init/initialize-intro.json",
"css:config/app/main/default.json",
"css:config/app/init/initialize-prefilled-root.json",
"css:config/app/setup/optional.json",
"css:config/app/variables/default.json",
"css:config/http/handler/default.json",
"css:config/http/middleware/default.json",
@ -13,9 +12,9 @@
"css:config/identity/access/public.json",
"css:config/identity/email/default.json",
"css:config/identity/handler/default.json",
"css:config/identity/oidc/default.json",
"css:config/identity/ownership/token.json",
"css:config/identity/pod/static.json",
"css:config/identity/registration/enabled.json",
"css:config/ldp/authentication/dpop-bearer.json",
"css:config/ldp/authorization/webacl.json",
"css:config/ldp/handler/default.json",
@ -24,6 +23,7 @@
"css:config/ldp/modes/default.json",
"css:config/storage/backend/memory.json",
"css:config/storage/key-value/resource-store.json",
"css:config/storage/location/root.json",
"css:config/storage/middleware/default.json",
"css:config/util/auxiliary/acl.json",
"css:config/util/identifiers/suffix.json",

@ -1,8 +1,9 @@
[
{
"podName": "example",
"email": "hello@example.com",
"password": "abc123",
"template": "./template"
"pods": [
{ "name": "example" }
]
}
]

@ -12,28 +12,25 @@ export async function createApp(): Promise<App> {
} as App;
}
const appRunner = new AppRunner();
return appRunner.create(
{
return appRunner.create({
loaderProperties: {
mainModulePath: resolveModulePath(""),
typeChecking: false,
},
path.join(
config: path.join(
__dirname,
"configs",
"components-config",
"unauthenticatedServer.json",
),
{},
{
variableBindings: {},
shorthand: {
port: 3_001,
loggingLevel: "off",
seededPodConfigJson: path.join(
__dirname,
"configs",
"solid-css-seed.json",
),
seedConfig: path.join(__dirname, "configs", "solid-css-seed.json"),
},
);
});
}
export interface ISecretData {

@ -0,0 +1 @@
module.exports = { presets: ["@babel/preset-env"] };

@ -1 +0,0 @@
{"key":"accounts/cookies/6ee53737-216c-4984-b530-95b3ff8784ea","payload":{"expires":"2024-11-01T02:16:14.618Z","payload":"93dbc3a7-58f0-424f-be3d-96a7f9eedf33"}}

@ -1 +0,0 @@
{"key":"accounts/data/93dbc3a7-58f0-424f-be3d-96a7f9eedf33","payload":{"linkedLoginsCount":1,"id":"93dbc3a7-58f0-424f-be3d-96a7f9eedf33","**password**":{"decb4d7a-0853-47b0-aeae-d1f98506052f":{"accountId":"93dbc3a7-58f0-424f-be3d-96a7f9eedf33","email":"hello@example.com","password":"$2a$10$UTqS/jXMtrsa9FzMKEw1XeLUi29wqKs16qf8Opx0rF.KACOu6CE2K","verified":true,"id":"decb4d7a-0853-47b0-aeae-d1f98506052f"}},"**clientCredentials**":{},"**pod**":{"b9f98f5e-653d-480c-9e04-78a567580c24":{"baseUrl":"http://localhost:3001/example/","accountId":"93dbc3a7-58f0-424f-be3d-96a7f9eedf33","id":"b9f98f5e-653d-480c-9e04-78a567580c24","**owner**":{"e7464d2a-9987-4564-b7e2-670a3c5c1af4":{"podId":"b9f98f5e-653d-480c-9e04-78a567580c24","webId":"http://localhost:3001/example/profile/card#me","visible":false,"id":"e7464d2a-9987-4564-b7e2-670a3c5c1af4"}}}},"**webIdLink**":{"28985848-10cd-429f-85fa-d1cc78484c52":{"webId":"http://localhost:3001/example/profile/card#me","accountId":"93dbc3a7-58f0-424f-be3d-96a7f9eedf33","id":"28985848-10cd-429f-85fa-d1cc78484c52"}},"rememberLogin":false}}

@ -1 +0,0 @@
{"key":"accounts/index/owner/e7464d2a-9987-4564-b7e2-670a3c5c1af4","payload":["93dbc3a7-58f0-424f-be3d-96a7f9eedf33"]}

@ -1 +0,0 @@
{"key":"accounts/index/password/decb4d7a-0853-47b0-aeae-d1f98506052f","payload":["93dbc3a7-58f0-424f-be3d-96a7f9eedf33"]}

@ -1 +0,0 @@
{"key":"accounts/index/password/email/hello%40example.com","payload":["93dbc3a7-58f0-424f-be3d-96a7f9eedf33"]}

@ -1 +0,0 @@
{"key":"accounts/index/pod/b9f98f5e-653d-480c-9e04-78a567580c24","payload":["93dbc3a7-58f0-424f-be3d-96a7f9eedf33"]}

@ -1 +0,0 @@
{"key":"accounts/index/pod/baseUrl/http%3A%2F%2Flocalhost%3A3001%2Fexample%2F","payload":["93dbc3a7-58f0-424f-be3d-96a7f9eedf33"]}

@ -1 +0,0 @@
{"key":"accounts/index/webIdLink/28985848-10cd-429f-85fa-d1cc78484c52","payload":["93dbc3a7-58f0-424f-be3d-96a7f9eedf33"]}

@ -1 +0,0 @@
{"key":"accounts/index/webIdLink/webId/http%3A%2F%2Flocalhost%3A3001%2Fexample%2Fprofile%2Fcard%23me","payload":["93dbc3a7-58f0-424f-be3d-96a7f9eedf33"]}

@ -1 +0,0 @@
{"key":"idp/keys/cookie-secret","payload":["aa579c6db82269c7b53b347a94c95ddef902adca35b9094f837748b196b00c94d12c062612cb116a81345c77a7275c02ab112d6c4eb82288d5857570498e67fa"]}

@ -1 +0,0 @@
{"key":"idp/keys/jwks","payload":{"keys":[{"kty":"EC","x":"ZFsT8AmP1xjP28ty6KZx_gWfA9sPycaO9magjOcOVVg","y":"P3hMr5z0q6c4opLXkmKAMyvWRxHIlBLMQ3OFDrl1B1c","crv":"P-256","d":"wF0eIwetdxmZ8fTj5vLAjda13eKzFuOlz72aldsmV7Y","alg":"ES256"}]}}

@ -1 +0,0 @@
{"key":"setup/current-base-url","payload":"http://localhost:3001/"}

@ -1 +0,0 @@
{"key":"setup/current-server-version","payload":"7.1.3"}

@ -1 +0,0 @@
{"key":"setup/v6-migration","payload":true}

@ -1,26 +0,0 @@
# Root ACL resource for the agent account
@prefix acl: <http://www.w3.org/ns/auth/acl#>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
# The homepage is readable by the public
<#public>
a acl:Authorization;
acl:agentClass foaf:Agent;
acl:accessTo <./>;
acl:mode acl:Read.
# The owner has full access to every resource in their pod.
# Other agents have no access rights,
# unless specifically authorized in other .acl resources.
<#owner>
a acl:Authorization;
acl:agent <http://localhost:3001/example/profile/card#me>;
# Optional owner email, to be used for account recovery:
# Set the access to the root storage folder itself
acl:accessTo <./>;
# All resources will inherit this authorization, by default
acl:default <./>;
# The owner has all of the access modes allowed
acl:mode
acl:Read, acl:Write, acl:Control.

@ -1 +0,0 @@
<http://localhost:3001/example/> a <http://www.w3.org/ns/pim/space#Storage>.

@ -1,27 +0,0 @@
# Welcome to your pod
## A place to store your data
Your pod is a **secure storage space** for your documents and data.
<br>
You can choose to share those with other people and apps.
As the owner of this pod,
identified by <a href="http://localhost:3001/example/profile/card#me">http://localhost:3001/example/profile/card#me</a>,
you have access to all of your documents.
## Working with your pod
The easiest way to interact with pods
is through Solid apps.
<br>
For example,
you can open your pod in [Databrowser](https://solidos.github.io/mashlib/dist/browse.html?uri=http://localhost:3001/example/).
## Accessing your account
To keep track of your pods, webIDs and any other resources,
you can [log in](http://localhost:3001/.account/) to your account.
There you can, for example, update the owners of this pod.
## Learn more
The [Solid website](https://solidproject.org/)
and the people on its [forum](https://forum.solidproject.org/)
will be glad to help you on your journey.

@ -1,14 +0,0 @@
@prefix acl: <http://www.w3.org/ns/auth/acl#>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
<#public>
a acl:Authorization;
acl:accessTo <./README>;
acl:agentClass foaf:Agent;
acl:mode acl:Read.
<#owner>
a acl:Authorization;
acl:accessTo <./README>;
acl:agent <http://localhost:3001/example/profile/card#me>;
acl:mode acl:Read, acl:Write, acl:Control.

@ -1,12 +0,0 @@
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
@prefix solid: <http://www.w3.org/ns/solid/terms#>.
<>
a foaf:PersonalProfileDocument;
foaf:maker <http://localhost:3001/example/profile/card#me>;
foaf:primaryTopic <http://localhost:3001/example/profile/card#me>.
<http://localhost:3001/example/profile/card#me>
solid:oidcIssuer <http://localhost:3001/>;
a foaf:Person.

@ -1,19 +0,0 @@
# ACL resource for the WebID profile document
@prefix acl: <http://www.w3.org/ns/auth/acl#>.
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
# The WebID profile is readable by the public.
# This is required for discovery and verification,
# e.g. when checking identity providers.
<#public>
a acl:Authorization;
acl:agentClass foaf:Agent;
acl:accessTo <./card>;
acl:mode acl:Read.
# The owner has full access to the profile
<#owner>
a acl:Authorization;
acl:agent <http://localhost:3001/example/profile/card#me>;
acl:accessTo <./card>;
acl:mode acl:Read, acl:Write, acl:Control.

@ -4,4 +4,8 @@ module.exports = {
...sharedConfig,
rootDir: "./",
setupFiles: ["<rootDir>/test/setup-tests.ts"],
transform: {
"^.+\\.(ts|tsx)?$": "ts-jest",
"^.+\\.(js|jsx)$": "babel-jest",
},
};

@ -7,7 +7,7 @@
"example": "ts-node ./example/example.ts",
"build": "tsc --project tsconfig.build.json",
"watch": "tsc --watch",
"test": "jest --coverage",
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --coverage",
"test:watch": "jest --watch",
"prepublishOnly": "npm run test && npm run build",
"build:ldo": "ldo build --input src/.shapes --output src/.ldo",
@ -31,6 +31,7 @@
"@rdfjs/types": "^1.0.1",
"@solid/community-server": "^7.1.3",
"@types/jest": "^27.0.3",
"cross-env": "^7.0.3",
"dotenv": "^16.3.1",
"jest-rdf": "^1.8.0",
"ts-jest": "^27.1.2",

@ -153,7 +153,14 @@ describe("Integration", () => {
>;
let solidLdoDataset: SolidLdoDataset;
let previousJestId: string | undefined;
let previousNodeEnv: string | undefined;
beforeAll(async () => {
// Remove Jest ID so that community solid server doesn't use the Jest Import
previousJestId = process.env.JEST_WORKER_ID;
previousNodeEnv = process.env.NODE_ENV;
delete process.env.JEST_WORKER_ID;
process.env.NODE_ENV = "other_test";
// Start up the server
app = await createApp();
await app.start();
@ -163,6 +170,8 @@ describe("Integration", () => {
afterAll(async () => {
app.stop();
process.env.JEST_WORKER_ID = previousJestId;
process.env.NODE_ENV = previousNodeEnv;
});
beforeEach(async () => {

@ -17,8 +17,6 @@ async function getAuthorization(): Promise<string> {
const indexResponse = await fetch("http://localhost:3001/.account/");
const { controls } = await indexResponse.json();
console.log("First controls", controls);
// And then we log in to the account API
const response = await fetch(controls.password.login, {
method: "POST",
@ -30,7 +28,6 @@ async function getAuthorization(): Promise<string> {
});
// This authorization value will be used to authenticate in the next step
const result = await response.json();
console.log(result);
return result.authorization;
}
@ -44,9 +41,6 @@ async function getSecret(
});
const { controls } = await indexResponse.json();
console.log("controls", controls);
console.log("authorization", authorization);
// Here we request the server to generate a token on our account
const response = await fetch(controls.account.clientCredentials, {
method: "POST",
@ -67,7 +61,6 @@ async function getSecret(
// Store the secret somewhere safe as there is no way to request it again from the server!
// The `resource` value can be used to delete the token at a later point in time.
const response2 = await response.json();
console.log("response2", response2);
return response2;
}
@ -78,7 +71,6 @@ async function getAccessToken(
try {
// A key pair is needed for encryption.
// This function from `solid-client-authn` generates such a pair for you.
console.log("a");
const dpopKey = await generateDpopKeyPair();
// These are the ID and secret generated in the previous step.
@ -90,7 +82,6 @@ async function getAccessToken(
// http://localhost:3001/.well-known/openid-configuration
// if your server is hosted at http://localhost:3000/.
const tokenUrl = "http://localhost:3001/.oidc/token";
console.log("b");
const response = await fetch(tokenUrl, {
method: "POST",
headers: {
@ -101,21 +92,12 @@ async function getAccessToken(
},
body: "grant_type=client_credentials&scope=webid",
});
console.log("c");
// console.log(process.env.JEST_WORKER_ID ?? process.env.NODE_ENV);
// console.log(process.env.JEST_WORKER_ID);
// console.log(process.env.NODE_ENV);
console.log("d");
// This is the Access token that will be used to do an authenticated request to the server.
// The JSON also contains an "expires_in" field in seconds,
// which you can use to know when you need request a new Access token.
const response2 = await response.text();
console.log("response2 getAccessToken", response2);
throw new Error();
// return { accessToken: response2.accessToken, dpopKey };
const response2 = await response.json();
return { accessToken: response2.access_token, dpopKey };
} catch (err) {
console.error(err);
throw err;
@ -123,12 +105,8 @@ async function getAccessToken(
}
export async function generateAuthFetch() {
console.log(1);
const authorization = await getAuthorization();
console.log(2);
const { id, secret } = await getSecret(authorization);
console.log(3);
const { accessToken, dpopKey } = await getAccessToken(id, secret);
console.log(4);
return await buildAuthenticatedFetch(accessToken, { dpopKey });
}

@ -32,8 +32,7 @@ export async function createApp(): Promise<App> {
variableBindings: {},
shorthand: {
port: 3_001,
loggingLevel: "info",
rootFilePath: path.join(__dirname, "../data"),
loggingLevel: "off",
seedConfig: path.join(__dirname, "configs", "solid-css-seed.json"),
},
});

Loading…
Cancel
Save