Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tavern/internal/ent/migrate/schema.go

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

4 changes: 4 additions & 0 deletions tavern/internal/ent/schema/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"entgo.io/contrib/entgql"
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
Expand Down Expand Up @@ -74,6 +75,9 @@ func (Beacon) Edges() []ent.Edge {
edge.To("host", Host.Type).
Required().
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
).
Comment("Host this beacon is running on."),
edge.From("tasks", Task.Type).
Annotations(
Expand Down
7 changes: 7 additions & 0 deletions tavern/internal/ent/schema/host_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"entgo.io/contrib/entgql"
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
Expand Down Expand Up @@ -63,11 +64,17 @@ func (HostFile) Edges() []ent.Edge {
edge.To("host", Host.Type).
Required().
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
).
Comment("Host the file was reported on."),
edge.From("task", Task.Type).
Required().
Unique().
Ref("reported_files").
Annotations(
entsql.OnDelete(entsql.Cascade),
).
Comment("Task that reported this file."),
}
}
Expand Down
7 changes: 7 additions & 0 deletions tavern/internal/ent/schema/host_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package schema
import (
"entgo.io/contrib/entgql"
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
Expand Down Expand Up @@ -61,11 +62,17 @@ func (HostProcess) Edges() []ent.Edge {
edge.To("host", Host.Type).
Required().
Unique().
Annotations(
entsql.OnDelete(entsql.Cascade),
).
Comment("Host the process was reported on."),
edge.From("task", Task.Type).
Required().
Unique().
Ref("reported_processes").
Annotations(
entsql.OnDelete(entsql.Cascade),
).
Comment("Task that reported this process."),
}
}
Expand Down
7 changes: 7 additions & 0 deletions tavern/internal/ent/schema/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"entgo.io/contrib/entgql"
"entgo.io/ent"
"entgo.io/ent/dialect/entsql"
"entgo.io/ent/schema"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
Expand Down Expand Up @@ -59,9 +60,15 @@ func (Task) Edges() []ent.Edge {
return []ent.Edge{
edge.From("quest", Quest.Type).
Ref("tasks").
Annotations(
entsql.OnDelete(entsql.Cascade),
).
Required().
Unique(),
edge.To("beacon", Beacon.Type).
Annotations(
entsql.OnDelete(entsql.Cascade),
).
Required().
Unique(),
edge.To("reported_files", HostFile.Type).
Expand Down
76 changes: 76 additions & 0 deletions tavern/internal/graphql/generated/mutation.generated.go

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

13 changes: 13 additions & 0 deletions tavern/internal/graphql/generated/root_.generated.go

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

40 changes: 40 additions & 0 deletions tavern/internal/graphql/mutation.resolvers.go

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

5 changes: 5 additions & 0 deletions tavern/internal/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,11 @@ input SubmitTaskResultInput {
error: String
}
type Mutation {
####
# Admin
####
dropAllData: Boolean! @requireRole(role: ADMIN)

###
# Quest
###
Expand Down
5 changes: 5 additions & 0 deletions tavern/internal/graphql/schema/mutation.graphql
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
type Mutation {
####
# Admin
####
dropAllData: Boolean! @requireRole(role: ADMIN)

###
# Quest
###
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
state: |
INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,access_token,is_activated,is_admin)
VALUES (5,"test_oauth_id","https://photos.com","test","secretToken","accessToken",true,true);
INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at)
VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13");
INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at)
VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13");
INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at)
VALUES (2000,"Test Tome","Used in a unit test :D", "kcarretto", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13");
INSERT INTO `files` (id, name, content, hash, created_at, last_modified_at)
VALUES (3000, "TestFile1", "hello world", "a948904f2f0f479b8f8197694b30184b0d2ed1c1cd2a1ec0fb85d299a192a447", "2023-03-04 14:51:13", "2023-03-04 14:51:13");
INSERT INTO `files` (id, name, content, hash, created_at, last_modified_at)
VALUES (3001, "TestFile2", "some test", "a9d9e8df0488c7e7e9236e43fe0c9385d7ea6920700db55d305f55dca76ddb0b", "2023-03-04 14:51:13", "2023-03-04 14:51:13");
INSERT INTO `tome_files` (tome_id, file_id)
VALUES (2000, 3000);
INSERT INTO `tome_files` (tome_id, file_id)
VALUES (2000, 3001);
requestor:
session_token: secretToken
query: |
mutation DropAllData {
dropAllData
}

expected:
dropAllData: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
state: |
INSERT INTO `users` (id,oauth_id,photo_url,name,session_token,access_token,is_activated,is_admin)
VALUES (5,"test_oauth_id","https://photos.com","test","secretToken","accessToken",true,false);
INSERT INTO `hosts` (id, name, identifier, platform, created_at, last_modified_at)
VALUES (1010,"db1","EXISTING-HOST", "PLATFORM_UNSPECIFIED", "2024-01-22 14:51:13", "2024-01-22 14:51:13");
INSERT INTO `beacons` (id, name, identifier, beacon_host, created_at, last_modified_at)
VALUES (1337,"delightful-lich","ABCDEFG-123456",1010, "2024-01-22 14:51:13", "2024-01-22 14:51:13");
INSERT INTO `tomes` (id, name, description, author, eldritch, hash, created_at, last_modified_at)
VALUES (2000,"Test Tome","Used in a unit test :D", "kcarretto", "print('Hello World!')", "abcdefg", "2023-03-04 14:51:13", "2023-03-04 14:51:13");
INSERT INTO `files` (id, name, content, hash, created_at, last_modified_at)
VALUES (3000, "TestFile1", "hello world", "a948904f2f0f479b8f8197694b30184b0d2ed1c1cd2a1ec0fb85d299a192a447", "2023-03-04 14:51:13", "2023-03-04 14:51:13");
INSERT INTO `files` (id, name, content, hash, created_at, last_modified_at)
VALUES (3001, "TestFile2", "some test", "a9d9e8df0488c7e7e9236e43fe0c9385d7ea6920700db55d305f55dca76ddb0b", "2023-03-04 14:51:13", "2023-03-04 14:51:13");
INSERT INTO `tome_files` (tome_id, file_id)
VALUES (2000, 3000);
INSERT INTO `tome_files` (tome_id, file_id)
VALUES (2000, 3001);
requestor:
session_token: secretToken
query: |
mutation DropAllData {
dropAllData
}

expected_error: "permission denied"
5 changes: 5 additions & 0 deletions tavern/internal/www/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,11 @@ input SubmitTaskResultInput {
error: String
}
type Mutation {
####
# Admin
####
dropAllData: Boolean! @requireRole(role: ADMIN)

###
# Quest
###
Expand Down