-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add an audit table for applications submitted via S3 and Power Automate #3397
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
hasura.planx.uk/migrations/1720597665798_create_table_s3_applications/down.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE "public.s3_applications" CASCADE; |
11 changes: 11 additions & 0 deletions
11
hasura.planx.uk/migrations/1720597665798_create_table_s3_applications/up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
CREATE TABLE "public"."s3_applications" ( | ||
"id" serial NOT NULL, | ||
"session_id" text NOT NULL, | ||
"team_slug" text NOT NULL, | ||
"webhook_request" JSONB NOT NULL, | ||
"webhook_response" JSONB NOT NULL, | ||
"created_at" timestamptz NOT NULL DEFAULT now(), | ||
PRIMARY KEY ("id") | ||
); | ||
|
||
COMMENT ON TABLE "public"."s3_applications" IS 'Stores a receipt of applications submitted using the Upload to AWS S3 method with notifications via Power Automate webhook'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
const { introspectAs } = require("./utils"); | ||
|
||
describe("s3_applications", () => { | ||
describe("public", () => { | ||
let i; | ||
beforeAll(async () => { | ||
i = await introspectAs("public"); | ||
}); | ||
|
||
test("cannot query s3 applications", () => { | ||
expect(i.queries).not.toContain("s3_applications"); | ||
}); | ||
|
||
test("cannot create, update, or delete s3 applications", () => { | ||
expect(i).toHaveNoMutationsFor("s3_applications"); | ||
}); | ||
}); | ||
|
||
describe("admin", () => { | ||
let i; | ||
beforeAll(async () => { | ||
i = await introspectAs("admin"); | ||
}); | ||
|
||
test("has full access to query and mutate s3 applications", () => { | ||
expect(i.queries).toContain("s3_applications"); | ||
expect(i.mutations).toContain("insert_s3_applications"); | ||
expect(i.mutations).toContain("update_s3_applications_by_pk"); | ||
expect(i.mutations).toContain("delete_s3_applications"); | ||
}); | ||
}); | ||
|
||
describe("platformAdmin", () => { | ||
let i; | ||
beforeAll(async () => { | ||
i = await introspectAs("platformAdmin"); | ||
}); | ||
|
||
test("cannot query s3_applications", () => { | ||
expect(i.queries).not.toContain("s3_applications"); | ||
}); | ||
|
||
test("cannot create, update, or delete s3_applications", () => { | ||
expect(i).toHaveNoMutationsFor("s3_applications"); | ||
}); | ||
}); | ||
|
||
describe("teamEditor", () => { | ||
let i; | ||
beforeAll(async () => { | ||
i = await introspectAs("teamEditor"); | ||
}); | ||
|
||
test("cannot query s3_applications", () => { | ||
expect(i.queries).not.toContain("s3_applications"); | ||
}); | ||
|
||
test("cannot create, update, or delete s3_applications", () => { | ||
expect(i).toHaveNoMutationsFor("s3_applications"); | ||
}); | ||
}); | ||
|
||
describe("api", () => { | ||
let i; | ||
beforeAll(async () => { | ||
i = await introspectAs("api"); | ||
}); | ||
|
||
test("can query and mutate s3 applications", () => { | ||
expect(i.queries).toContain("s3_applications"); | ||
expect(i.mutations).toContain("insert_s3_applications"); | ||
expect(i.mutations).toContain("update_s3_applications_by_pk"); | ||
}); | ||
|
||
test("cannot delete s3 applications", () => { | ||
expect(i.mutations).not.toContain("delete_s3_applications"); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that these applications will be automatically picked up by the
submission_services_log
view as that's reading Hasura metadata tables directly right?However, I think that the
submission_services_summary
view will require an update to also read from this new table.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question - you're right:
submission_services_log
is automatically picking up these records because it reads from Hasura eventssubmission_services_summary
will need to be manually updated (then Metabase too?) to join to this new audit table so analytics can be correctly trackedI'd prefer to pick this up in a follow-up PR !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, makes total sense! ✅