Skip to content

Commit

Permalink
chore: Update Hasura (#1035)
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Jul 26, 2022
1 parent 60afcfd commit 2434950
Show file tree
Hide file tree
Showing 9 changed files with 748 additions and 1,904 deletions.
2 changes: 1 addition & 1 deletion hasura.planx.uk/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM hasura/graphql-engine:v2.7.0.cli-migrations-v2
FROM hasura/graphql-engine:v2.8.4.cli-migrations-v2
WORKDIR /
COPY metadata hasura-metadata
COPY migrations hasura-migrations
3 changes: 0 additions & 3 deletions hasura.planx.uk/metadata/tables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
- flow_id
- id
- type
backend_only: false
select_permissions:
- role: public
permission:
Expand All @@ -34,7 +33,6 @@
- node_title
- node_type
- user_exit
backend_only: false
select_permissions:
- role: public
permission:
Expand Down Expand Up @@ -312,7 +310,6 @@
- flow_id
- session_id
- user_data
backend_only: false
- table:
schema: public
name: team_members
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "public"."lowcal_sessions" alter column "email" drop not null;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table "public"."lowcal_sessions" alter column "email" set not null;
6 changes: 5 additions & 1 deletion hasura.planx.uk/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"devDependencies": {
"hasura-cli": "^2.2.0"
"hasura-cli": "^2.8.4"
},
"engines": {
"node": "^16",
"pnpm": "^6"
}
}
14 changes: 7 additions & 7 deletions hasura.planx.uk/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 12 additions & 9 deletions hasura.planx.uk/tests/lowcal_sessions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe("lowcal_sessions", () => {

describe("UPDATE without permission", () => {
test("cannot update without 'x-hasura-lowcal-session-id' header", async () => {
const res = await gqlPublic(updateByPK, { sessionId: alice1, data: { x: 1 } });
const res = await gqlPublic(updateByPK, { sessionId: alice1, data: { x: 1 } }, { "x-hasura-lowcal-email": "alice@opensystemslab.io" });
expect(res).toHaveProperty("errors");
expect(res.errors[0].message).toContain('missing session variable: "x-hasura-lowcal-session-id"');
});
Expand All @@ -118,15 +118,9 @@ describe("lowcal_sessions", () => {
});

test("'x-hasura-lowcal-session-id' header must have value", async () => {
const res = await gqlPublic(updateByPK, { sessionId: alice1, data: { x: 1 } }, { "x-hasura-lowcal-session-id": null});
const res = await gqlPublic(updateByPK, { sessionId: alice1, data: { x: 1 } }, { "x-hasura-lowcal-session-id": null, "x-hasura-lowcal-email": "alice@opensystemslab.io"});
expect(res).toHaveProperty("errors");
expect(res.errors[0].message).toContain('missing session variable: "x-hasura-lowcal-session-id"');
});

test("'x-hasura-lowcal-email' header must have value", async () => {
const res = await gqlPublic(updateByPK, { sessionId: alice1, data: { x: 1 } }, { "x-hasura-lowcal-session-id": uuidV4(), "x-hasura-lowcal-email": null });
expect(res).toHaveProperty("errors");
expect(res.errors[0].message).toContain('missing session variable: "x-hasura-lowcal-email"');
expect(res.errors[0].message).toContain("invalid input syntax for type uuid: \"null\"");
});

test("Alice cannot update her own session with invalid sessionId", async () => {
Expand All @@ -147,6 +141,15 @@ describe("lowcal_sessions", () => {
expect(res.data.update_lowcal_sessions_by_pk).toBeNull();
});

test("Alice cannot update her own session with a missing email", async () => {
const headers = {
"x-hasura-lowcal-session-id": alice1,
"x-hasura-lowcal-email": null
};
const res = await gqlPublic(updateByPK, { sessionId: alice1, data: { x: 1 } }, headers);
expect(res.data.update_lowcal_sessions_by_pk).toBeNull();
});

test("Mallory cannot update Alice's session", async () => {
const headers = {
"x-hasura-lowcal-session-id": uuidV4(),
Expand Down
15 changes: 13 additions & 2 deletions hasura.planx.uk/tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,24 @@
"test:watch": "jest --watch"
},
"dependencies": {
"isomorphic-fetch": "^2.2.1",
"jest": "^26.4.2",
"isomorphic-fetch": "^3.0.0",
"jest": "^28.1.3",
"uuid": "^8.3.2"
},
"jest": {
"setupFilesAfterEnv": [
"./jest.setup.js"
]
},
"engines": {
"node": "^16",
"pnpm": "^6"
},
"pnpm": {
"overrides": {
"minimist@<1.2.6": ">=1.2.6",
"path-parse@<1.0.7": ">=1.0.7",
"ansi-regex@>=5.0.0 <5.0.1": ">=5.0.1"
}
}
}
Loading

0 comments on commit 2434950

Please sign in to comment.