Skip to content

Commit

Permalink
change to identity interface in test
Browse files Browse the repository at this point in the history
  • Loading branch information
fredcarle committed Oct 25, 2024
1 parent 3210fbf commit 62154fa
Show file tree
Hide file tree
Showing 82 changed files with 720 additions and 706 deletions.
14 changes: 7 additions & 7 deletions tests/integration/acp.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ type AddPolicy struct {
Policy string

// The policy creator identity, i.e. actor creating the policy.
Identity identRef
Identity identity

// The expected policyID generated based on the Policy loaded in to the ACP system.
ExpectedPolicyID string
Expand Down Expand Up @@ -159,13 +159,13 @@ type AddDocActorRelationship struct {
// The target public identity, i.e. the identity of the actor to tie the document's relation with.
//
// This is a required field. To test the invalid usage of not having this arg, use -1 index.
TargetIdentity identRef
TargetIdentity identity

// The requestor identity, i.e. identity of the actor creating the relationship.
// Note: This identity must either own or have managing access defined in the policy.
//
// This is a required field. To test the invalid usage of not having this arg, use -1 index.
RequestorIdentity identRef
RequestorIdentity identity

// Result returns true if it was a no-op due to existing before, and false if a new relationship was made.
ExpectedExistence bool
Expand All @@ -192,7 +192,7 @@ func addDocActorRelationshipACP(
collectionName,
docID,
action.Relation,
getIdentityDID(s, action.TargetIdentity),
action.TargetIdentity.DID(s),
)

expectedErrorRaised := AssertError(s.t, s.testCase.Description, err, action.ExpectedError)
Expand Down Expand Up @@ -239,13 +239,13 @@ type DeleteDocActorRelationship struct {
// The target public identity, i.e. the identity of the actor with whom the relationship is with.
//
// This is a required field. To test the invalid usage of not having this arg, use -1 index.
TargetIdentity identRef
TargetIdentity identity

// The requestor identity, i.e. identity of the actor deleting the relationship.
// Note: This identity must either own or have managing access defined in the policy.
//
// This is a required field. To test the invalid usage of not having this arg, use -1 index.
RequestorIdentity identRef
RequestorIdentity identity

// Result returns true if the relationship record was expected to be found and deleted,
// and returns false if no matching relationship record was found (no-op).
Expand Down Expand Up @@ -273,7 +273,7 @@ func deleteDocActorRelationshipACP(
collectionName,
docID,
action.Relation,
getIdentityDID(s, action.TargetIdentity),
action.TargetIdentity.DID(s),
)

expectedErrorRaised := AssertError(s.t, s.testCase.Description, err, action.ExpectedError)
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/acp/add_policy/basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestACP_AddPolicy_BasicYAML_ValidPolicyID(t *testing.T) {

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: test
Expand Down Expand Up @@ -62,7 +62,7 @@ func TestACP_AddPolicy_BasicJSON_ValidPolicyID(t *testing.T) {

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
{
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/acp/add_policy/with_empty_args_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestACP_AddPolicy_EmptyPolicyData_Error(t *testing.T) {

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: "",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestACP_AddPolicy_ExtraPermissionsAndExtraRelations_ValidPolicyID(t *testin

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: test
Expand Down
4 changes: 2 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 @@ -23,7 +23,7 @@ func TestACP_AddPolicy_ExtraPermissions_ValidPolicyID(t *testing.T) {

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: a policy
Expand Down Expand Up @@ -63,7 +63,7 @@ func TestACP_AddPolicy_ExtraDuplicatePermissions_Error(t *testing.T) {

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: a policy
Expand Down
4 changes: 2 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 @@ -23,7 +23,7 @@ func TestACP_AddPolicy_ExtraRelations_ValidPolicyID(t *testing.T) {

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: a policy
Expand Down Expand Up @@ -67,7 +67,7 @@ func TestACP_AddPolicy_ExtraDuplicateRelations_Error(t *testing.T) {

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: a policy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestACP_AddPolicy_NoRelations_Error(t *testing.T) {

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: a policy
Expand Down Expand Up @@ -58,7 +58,7 @@ func TestACP_AddPolicy_NoRelationsLabel_Error(t *testing.T) {

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: a policy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestACP_AddPolicy_MissingRequiredOwnerRelation_Error(t *testing.T) {

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: a policy
Expand Down Expand Up @@ -61,7 +61,7 @@ func TestACP_AddPolicy_DuplicateOwnerRelation_Error(t *testing.T) {

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: a policy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestACP_AddPolicy_OneResourceThatIsEmpty_Error(t *testing.T) {

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: a policy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestACP_AddPolicy_WithRelationManagingOtherRelation_ValidPolicyID(t *testin
Description: "Test acp, where a relation is managing another relation, valid policy id",
Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: a policy
Expand Down
20 changes: 10 additions & 10 deletions tests/integration/acp/add_policy/with_multi_policies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestACP_AddPolicy_AddMultipleDifferentPolicies_ValidPolicyIDs(t *testing.T)

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: a policy
Expand Down Expand Up @@ -51,7 +51,7 @@ func TestACP_AddPolicy_AddMultipleDifferentPolicies_ValidPolicyIDs(t *testing.T)
},

testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: a policy
Expand Down Expand Up @@ -97,7 +97,7 @@ func TestACP_AddPolicy_AddMultipleDifferentPoliciesInDifferentFmts_ValidPolicyID

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
{
Expand Down Expand Up @@ -132,7 +132,7 @@ func TestACP_AddPolicy_AddMultipleDifferentPoliciesInDifferentFmts_ValidPolicyID
},

testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: test2
Expand Down Expand Up @@ -199,15 +199,15 @@ func TestACP_AddPolicy_AddDuplicatePolicyByOtherCreator_ValidPolicyIDs(t *testin

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: policyUsedByBoth,

ExpectedPolicyID: "66f3e364004a181e9b129f65dea317322d2285226e926d7e8cdfd644954e4262",
},

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

Policy: policyUsedByBoth,

Expand All @@ -226,7 +226,7 @@ func TestACP_AddPolicy_AddMultipleDuplicatePolicies_Error(t *testing.T) {

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: test
Expand Down Expand Up @@ -254,7 +254,7 @@ func TestACP_AddPolicy_AddMultipleDuplicatePolicies_Error(t *testing.T) {
},

testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: test
Expand Down Expand Up @@ -293,7 +293,7 @@ func TestACP_AddPolicy_AddMultipleDuplicatePoliciesDifferentFmts_ProducesDiffere

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: test
Expand All @@ -320,7 +320,7 @@ func TestACP_AddPolicy_AddMultipleDuplicatePoliciesDifferentFmts_ProducesDiffere
},

testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestACP_AddPolicy_MultipleResources_ValidID(t *testing.T) {

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: test
Expand Down Expand Up @@ -78,7 +78,7 @@ func TestACP_AddPolicy_MultipleResourcesUsingRelationDefinedInOther_Error(t *tes

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: test
Expand Down Expand Up @@ -130,7 +130,7 @@ func TestACP_AddPolicy_SecondResourcesMissingRequiredOwner_Error(t *testing.T) {

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: test
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/acp/add_policy/with_no_perms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestACP_AddPolicy_NoPermissionsOnlyOwner_ValidID(t *testing.T) {

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: test
Expand Down Expand Up @@ -66,7 +66,7 @@ func TestACP_AddPolicy_NoPermissionsMultiRelations_ValidID(t *testing.T) {

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: test
Expand Down Expand Up @@ -104,7 +104,7 @@ func TestACP_AddPolicy_NoPermissionsLabelOnlyOwner_ValidID(t *testing.T) {

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: test
Expand Down Expand Up @@ -137,7 +137,7 @@ func TestACP_AddPolicy_NoPermissionsLabelMultiRelations_ValidID(t *testing.T) {

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: test
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/acp/add_policy/with_no_resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestACP_AddPolicy_NoResource_ValidID(t *testing.T) {

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: test
Expand Down Expand Up @@ -56,7 +56,7 @@ func TestACP_AddPolicy_NoResourceLabel_ValidID(t *testing.T) {

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: test
Expand Down Expand Up @@ -85,7 +85,7 @@ func TestACP_AddPolicy_PolicyWithOnlySpace_NameIsRequired(t *testing.T) {
}),
Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: " ",

Expand Down
4 changes: 2 additions & 2 deletions tests/integration/acp/add_policy/with_perm_expr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestACP_AddPolicy_PermissionExprWithOwnerInTheEndWithMinus_ValidID(t *testi

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: test
Expand Down Expand Up @@ -65,7 +65,7 @@ func TestACP_AddPolicy_PermissionExprWithOwnerInTheEndWithMinusNoSpace_ValidID(t

Actions: []any{
testUtils.AddPolicy{
Identity: testUtils.UserIdentity(1),
Identity: testUtils.ClientIdentity(1),

Policy: `
name: test
Expand Down
Loading

0 comments on commit 62154fa

Please sign in to comment.