Skip to content

Commit

Permalink
PR(TEST): Fix all the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzadlone committed Mar 6, 2025
1 parent a78f79e commit 11e7b2b
Show file tree
Hide file tree
Showing 72 changed files with 841 additions and 1,088 deletions.
4 changes: 0 additions & 4 deletions tests/integration/acp/add_policy/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ func TestACP_AddPolicy_BasicYAML_ValidPolicyID(t *testing.T) {
- actor
`,

ExpectedPolicyID: "66f3e364004a181e9b129f65dea317322d2285226e926d7e8cdfd644954e4262",
},
},
}
Expand Down Expand Up @@ -92,8 +90,6 @@ func TestACP_AddPolicy_BasicJSON_ValidPolicyID(t *testing.T) {
}
}
`,

ExpectedPolicyID: "66f3e364004a181e9b129f65dea317322d2285226e926d7e8cdfd644954e4262",
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ func TestACP_AddPolicy_ExtraPermissionsAndExtraRelations_ValidPolicyID(t *testin
types:
- actor
`,

ExpectedPolicyID: "af2a2eaa2d6701262ea60665487c87e3d41ab727194e1ea18ec16348149a02cc",
},
},
}
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/acp/add_policy/with_extra_perms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ func TestACP_AddPolicy_ExtraPermissions_ValidPolicyID(t *testing.T) {
actor:
name: actor
`,

ExpectedPolicyID: "a756ba5a7fe25e3fc36a4f113016a49b718b09028c917199ae68f478addc048c",
},
},
}
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/acp/add_policy/with_extra_relations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ func TestACP_AddPolicy_ExtraRelations_ValidPolicyID(t *testing.T) {
types:
- actor
`,

ExpectedPolicyID: "bdfe4d449b8a42b1daf247e37b5a62ee139ff5b79fa15a970d5d7ae32c08d1e5",
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ func TestACP_AddPolicy_WithRelationManagingOtherRelation_ValidPolicyID(t *testin
types:
- actor
`,

ExpectedPolicyID: "725caeee6c5043f019e7dc3bb6a627520c235f063e862696c67ac89b5c1fc840",
},
},
}
Expand Down
38 changes: 26 additions & 12 deletions tests/integration/acp/add_policy/with_multi_policies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ package test_acp_add_policy
import (
"testing"

"github.com/sourcenetwork/immutable"

testUtils "github.com/sourcenetwork/defradb/tests/integration"
)

Expand Down Expand Up @@ -46,8 +48,6 @@ func TestACP_AddPolicy_AddMultipleDifferentPolicies_ValidPolicyIDs(t *testing.T)
- actor
`,

ExpectedPolicyID: "2eb8b503c9fc0b7c1f7b04d68a6faa0f82a299db0ae02fed68f9897612439cb6",
},

testUtils.AddPolicy{
Expand Down Expand Up @@ -81,8 +81,6 @@ func TestACP_AddPolicy_AddMultipleDifferentPolicies_ValidPolicyIDs(t *testing.T)
types:
- actor
`,

ExpectedPolicyID: "6b766a9aafabf0bf65102f73b7cd81963b65e1fd87ce763f386cc685147325ee",
},
},
}
Expand Down Expand Up @@ -128,7 +126,9 @@ func TestACP_AddPolicy_AddMultipleDifferentPoliciesInDifferentFmts_ValidPolicyID
}
`,

ExpectedPolicyID: "66f3e364004a181e9b129f65dea317322d2285226e926d7e8cdfd644954e4262",
ExpectedPolicyID: immutable.Some(
"66f3e364004a181e9b129f65dea317322d2285226e926d7e8cdfd644954e4262",
),
},

testUtils.AddPolicy{
Expand Down Expand Up @@ -163,7 +163,9 @@ func TestACP_AddPolicy_AddMultipleDifferentPoliciesInDifferentFmts_ValidPolicyID
- actor
`,

ExpectedPolicyID: "757c772e9c4418de530ecd72cbc56dfc4e0c22aa2f3b2d219afa7663b2f0af00",
ExpectedPolicyID: immutable.Some(
"757c772e9c4418de530ecd72cbc56dfc4e0c22aa2f3b2d219afa7663b2f0af00",
),
},
},
}
Expand Down Expand Up @@ -203,15 +205,19 @@ func TestACP_AddPolicy_AddDuplicatePolicyByOtherCreator_ValidPolicyIDs(t *testin

Policy: policyUsedByBoth,

ExpectedPolicyID: "66f3e364004a181e9b129f65dea317322d2285226e926d7e8cdfd644954e4262",
ExpectedPolicyID: immutable.Some(
"66f3e364004a181e9b129f65dea317322d2285226e926d7e8cdfd644954e4262",
),
},

testUtils.AddPolicy{
Identity: testUtils.ClientIdentity(2),

Policy: policyUsedByBoth,

ExpectedPolicyID: "ec02815cb630850678bda5e2d75cfacebc96f5610e32a602f7bfc414e21474ad",
ExpectedPolicyID: immutable.Some(
"ec02815cb630850678bda5e2d75cfacebc96f5610e32a602f7bfc414e21474ad",
),
},
},
}
Expand Down Expand Up @@ -250,7 +256,9 @@ func TestACP_AddPolicy_AddMultipleDuplicatePolicies_Error(t *testing.T) {
`,

ExpectedPolicyID: "66f3e364004a181e9b129f65dea317322d2285226e926d7e8cdfd644954e4262",
ExpectedPolicyID: immutable.Some(
"66f3e364004a181e9b129f65dea317322d2285226e926d7e8cdfd644954e4262",
),
},

testUtils.AddPolicy{
Expand Down Expand Up @@ -278,7 +286,9 @@ func TestACP_AddPolicy_AddMultipleDuplicatePolicies_Error(t *testing.T) {
`,

ExpectedPolicyID: "ec02815cb630850678bda5e2d75cfacebc96f5610e32a602f7bfc414e21474ad",
ExpectedPolicyID: immutable.Some(
"ec02815cb630850678bda5e2d75cfacebc96f5610e32a602f7bfc414e21474ad",
),
},
},
}
Expand Down Expand Up @@ -316,7 +326,9 @@ func TestACP_AddPolicy_AddMultipleDuplicatePoliciesDifferentFmts_ProducesDiffere
- actor
`,

ExpectedPolicyID: "66f3e364004a181e9b129f65dea317322d2285226e926d7e8cdfd644954e4262",
ExpectedPolicyID: immutable.Some(
"66f3e364004a181e9b129f65dea317322d2285226e926d7e8cdfd644954e4262",
),
},

testUtils.AddPolicy{
Expand Down Expand Up @@ -351,7 +363,9 @@ func TestACP_AddPolicy_AddMultipleDuplicatePoliciesDifferentFmts_ProducesDiffere
}
`,

ExpectedPolicyID: "ec02815cb630850678bda5e2d75cfacebc96f5610e32a602f7bfc414e21474ad",
ExpectedPolicyID: immutable.Some(
"ec02815cb630850678bda5e2d75cfacebc96f5610e32a602f7bfc414e21474ad",
),
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ func TestACP_AddPolicy_MultipleResources_ValidID(t *testing.T) {
types:
- actor
`,

ExpectedPolicyID: "a9e1a113ccc2609d7f99a42531017f0fbc9b736640ec8ffc7f09a1e29583ca45",
},
},
}
Expand Down
8 changes: 0 additions & 8 deletions tests/integration/acp/add_policy/with_no_perms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ func TestACP_AddPolicy_NoPermissionsOnlyOwner_ValidID(t *testing.T) {
- actor
`,

ExpectedPolicyID: "db6e4d3efc58f8a7bfe8f35c73c39630f1ad3e6fad7ffeb22563d1284bd176dc",
},
},
}
Expand Down Expand Up @@ -88,8 +86,6 @@ func TestACP_AddPolicy_NoPermissionsMultiRelations_ValidID(t *testing.T) {
- actor
`,

ExpectedPolicyID: "106a38bfb702608e26feda961d9fffd74141ef34eccc17b3de2c15dd7620da46",
},
},
}
Expand Down Expand Up @@ -121,8 +117,6 @@ func TestACP_AddPolicy_NoPermissionsLabelOnlyOwner_ValidID(t *testing.T) {
- actor
`,

ExpectedPolicyID: "db6e4d3efc58f8a7bfe8f35c73c39630f1ad3e6fad7ffeb22563d1284bd176dc",
},
},
}
Expand Down Expand Up @@ -157,8 +151,6 @@ func TestACP_AddPolicy_NoPermissionsLabelMultiRelations_ValidID(t *testing.T) {
- actor
`,

ExpectedPolicyID: "106a38bfb702608e26feda961d9fffd74141ef34eccc17b3de2c15dd7620da46",
},
},
}
Expand Down
4 changes: 0 additions & 4 deletions tests/integration/acp/add_policy/with_no_resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ func TestACP_AddPolicy_NoResource_ValidID(t *testing.T) {
resources:
`,

ExpectedPolicyID: "e3ffe8e802e4612dc41d7a638cd77dc16d51eb1db0d18682eec75b05234e6ee2",
},
},
}
Expand All @@ -65,8 +63,6 @@ func TestACP_AddPolicy_NoResourceLabel_ValidID(t *testing.T) {
actor:
name: actor
`,

ExpectedPolicyID: "e3ffe8e802e4612dc41d7a638cd77dc16d51eb1db0d18682eec75b05234e6ee2",
},
},
}
Expand Down
4 changes: 0 additions & 4 deletions tests/integration/acp/add_policy/with_perm_expr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ func TestACP_AddPolicy_PermissionExprWithOwnerInTheEndWithMinus_ValidID(t *testi
types:
- actor
`,

ExpectedPolicyID: "2b10641de73790b95452f496a37ad53a8d8a0703803f35f6961457af912947c0",
},
},
}
Expand Down Expand Up @@ -90,8 +88,6 @@ func TestACP_AddPolicy_PermissionExprWithOwnerInTheEndWithMinusNoSpace_ValidID(t
types:
- actor
`,

ExpectedPolicyID: "b6b305214247a08903e01466a1bfd01516206458d2725506797300b285e63690",
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ func TestACP_AddPolicy_PermissionlessOwnerWrite_ValidID(t *testing.T) {
types:
- actor
`,

ExpectedPolicyID: "9328e41c1969c6269bfd82162b45831ccec8df9fc8d57902620ad43baaa0d77d",
},
},
}
Expand Down Expand Up @@ -96,8 +94,6 @@ func TestACP_AddPolicy_PermissionlessOwnerRead_ValidID(t *testing.T) {
types:
- actor
`,

ExpectedPolicyID: "74f3c0996d5b1669b9efda5ef45f93a925df9f770e2dcd53f352b5f0693a2b0f",
},
},
}
Expand Down Expand Up @@ -137,8 +133,6 @@ func TestACP_AddPolicy_PermissionlessOwnerReadWrite_ValidID(t *testing.T) {
types:
- actor
`,

ExpectedPolicyID: "9328e41c1969c6269bfd82162b45831ccec8df9fc8d57902620ad43baaa0d77d",
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ func TestACP_AddPolicy_UnusedRelation_ValidID(t *testing.T) {
- actor
`,

ExpectedPolicyID: "ab1102f656ed1f2b037a3c9586611c701243f2086fa64211bd7baff7271c2030",
},
},
}
Expand Down
1 change: 0 additions & 1 deletion tests/integration/acp/demo/demo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ func TestACP_DEMO(t *testing.T) {
}
`,

// Replace: immutable.Some([]int{0, 0, 1}),
Replace: map[string]testUtils.ReplaceType{
"Policy0": testUtils.NewPolicyIndex(0),
"Policy1": testUtils.NewPolicyIndex(1),
Expand Down
22 changes: 14 additions & 8 deletions tests/integration/acp/index/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,24 @@ func TestACP_IndexCreateWithSeparateRequest_OnCollectionWithPolicy_NoError(t *te
Actions: []any{

testUtils.AddPolicy{
Identity: testUtils.ClientIdentity(1),
Policy: userPolicy,
ExpectedPolicyID: "94eb195c0e459aa79e02a1986c7e731c5015721c18a373f2b2a0ed140a04b454",
Identity: testUtils.ClientIdentity(1),
Policy: userPolicy,
},

testUtils.SchemaUpdate{
Schema: `
type Users @policy(
id: "94eb195c0e459aa79e02a1986c7e731c5015721c18a373f2b2a0ed140a04b454",
id: "{{.Policy0}}",
resource: "users"
) {
name: String
age: Int
}
`,

Replace: map[string]testUtils.ReplaceType{
"Policy0": testUtils.NewPolicyIndex(0),
},
},

testUtils.CreateIndex{
Expand Down Expand Up @@ -70,21 +73,24 @@ func TestACP_IndexCreateWithDirective_OnCollectionWithPolicy_NoError(t *testing.
Actions: []any{

testUtils.AddPolicy{
Identity: testUtils.ClientIdentity(1),
Policy: userPolicy,
ExpectedPolicyID: "94eb195c0e459aa79e02a1986c7e731c5015721c18a373f2b2a0ed140a04b454",
Identity: testUtils.ClientIdentity(1),
Policy: userPolicy,
},

testUtils.SchemaUpdate{
Schema: `
type Users @policy(
id: "94eb195c0e459aa79e02a1986c7e731c5015721c18a373f2b2a0ed140a04b454",
id: "{{.Policy0}}",
resource: "users"
) {
name: String @index
age: Int
}
`,

Replace: map[string]testUtils.ReplaceType{
"Policy0": testUtils.NewPolicyIndex(0),
},
},

testUtils.Request{
Expand Down
Loading

0 comments on commit 11e7b2b

Please sign in to comment.