-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: identify subject by external_id
ENG-2125
- Loading branch information
1 parent
67f7ffc
commit 9f1044c
Showing
6 changed files
with
78 additions
and
15 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,7 +150,7 @@ var _ = Describe("indy.is_authorized", func() { | |
respTTL: durationpb.New(time.Minute * 90), | ||
decisionTimeMatcher: BeEquivalentTo("1645543102"), // All numbers are json.Number ie string | ||
ttlMatcher: BeEquivalentTo("5400"), | ||
regoParam1: `{"id": "` + testAccessToken + `", "type": "token"}`, | ||
regoParam1: `{"id": "` + testAccessToken + `", "subjectType": "token"}`, | ||
}), | ||
Entry("DigitalTwin id", &dtIDCase{ | ||
reqSubject: &authorizationpb.Subject{ | ||
|
@@ -164,7 +164,7 @@ var _ = Describe("indy.is_authorized", func() { | |
respTTL: durationpb.New(time.Minute * 90), | ||
decisionTimeMatcher: BeEquivalentTo("1645543102"), // All numbers are json.Number ie string | ||
ttlMatcher: BeEquivalentTo("5400"), | ||
regoParam1: `{"id": "gid:AAAAFezuHiJHiUeRjrIJV8k3oKo", "type": "id"}`, | ||
regoParam1: `{"id": "gid:AAAAFezuHiJHiUeRjrIJV8k3oKo", "subjectType": "id"}`, | ||
}), | ||
Entry("DigitalTwin property", &dtIDCase{ | ||
reqSubject: &authorizationpb.Subject{ | ||
|
@@ -179,7 +179,22 @@ var _ = Describe("indy.is_authorized", func() { | |
respTTL: durationpb.New(time.Minute * 90), | ||
decisionTimeMatcher: BeEquivalentTo("1645543102"), // All numbers are json.Number ie string | ||
ttlMatcher: BeEquivalentTo("5400"), | ||
regoParam1: `{"id": "[email protected]", "type": "property", "property": "email"}`, | ||
regoParam1: `{"id": "[email protected]", "subjectType": "property", "property": "email"}`, | ||
}), | ||
Entry("DigitalTwin externalID", &dtIDCase{ | ||
reqSubject: &authorizationpb.Subject{ | ||
Subject: &authorizationpb.Subject_ExternalId{ | ||
ExternalId: &authorizationpb.ExternalID{ | ||
Type: "Person", | ||
ExternalId: "some-external-id", | ||
}, | ||
}, | ||
}, | ||
respDecisionTime: timestamppb.New(time.Date(2022, 02, 22, 15, 18, 22, 0, time.UTC)), | ||
respTTL: durationpb.New(time.Minute * 90), | ||
decisionTimeMatcher: BeEquivalentTo("1645543102"), // All numbers are json.Number ie string | ||
ttlMatcher: BeEquivalentTo("5400"), | ||
regoParam1: `{"id": "some-external-id", "subjectType": "external_id", "type": "Person"}`, | ||
}), | ||
) | ||
|
||
|
@@ -218,10 +233,10 @@ var _ = Describe("indy.is_authorized", func() { | |
Entry("Empty resource_references", `{"id": "`+testAccessToken+`"}, [], {}`, | ||
"unable to call IsAuthorized client endpoint", | ||
"invalid IsAuthorizedRequest.Resources: value must contain between 1 and 32 items, inclusive"), | ||
Entry("Invalid digital twin", `{"id": "abc", "type": "id"}, [{"externalId": "res1", "type": "Type", "actions": ["READ"]}, {"externalId": "res2", "type": "Type", "actions": ["READ"]}], {}`, | ||
Entry("Invalid digital twin", `{"id": "abc", "subjectType": "id"}, [{"externalId": "res1", "type": "Type", "actions": ["READ"]}, {"externalId": "res2", "type": "Type", "actions": ["READ"]}], {}`, | ||
"unable to call IsAuthorized client endpoint", | ||
"invalid DigitalTwin.Id: value length must be between 27 and 100 runes"), | ||
Entry("Invalid propertyType", `{"id": "", "type": "property", "property": ""}, [{"externalId": "res1", "type": "Type", "actions": ["READ"]}, {"externalId": "res2", "type": "Type", "actions": ["READ"]}], {}`, | ||
Entry("Invalid propertyType", `{"id": "", "subjectType": "property", "property": ""}, [{"externalId": "res1", "type": "Type", "actions": ["READ"]}, {"externalId": "res2", "type": "Type", "actions": ["READ"]}], {}`, | ||
"unable to call IsAuthorized client endpoint", | ||
"invalid Property.Type: value length must be between 2 and 20 runes"), | ||
) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,7 +172,7 @@ var _ = Describe("indy.what_authorized", func() { | |
respTTL: durationpb.New(time.Minute * 90), | ||
decisionTimeMatcher: BeEquivalentTo("1645543102"), // All numbers are json.Number ie string | ||
ttlMatcher: BeEquivalentTo("5400"), | ||
regoParam1: `{"id": "` + testAccessToken + `", "type": "token"}`, | ||
regoParam1: `{"id": "` + testAccessToken + `", "subjectType": "token"}`, | ||
}), | ||
Entry("DigitalTwin", &dtIDCase{ | ||
reqSubject: &authorizationpb.Subject{ | ||
|
@@ -187,7 +187,7 @@ var _ = Describe("indy.what_authorized", func() { | |
respTTL: nil, | ||
decisionTimeMatcher: BeEquivalentTo("0"), | ||
ttlMatcher: BeEquivalentTo("0"), | ||
regoParam1: `{"id": "gid:AAAAFezuHiJHiUeRjrIJV8k3oKo", "type": "id"}`, | ||
regoParam1: `{"id": "gid:AAAAFezuHiJHiUeRjrIJV8k3oKo", "subjectType": "id"}`, | ||
}), | ||
Entry("DigitalTwin property", &dtIDCase{ | ||
reqSubject: &authorizationpb.Subject{ | ||
|
@@ -203,7 +203,23 @@ var _ = Describe("indy.what_authorized", func() { | |
respTTL: nil, | ||
decisionTimeMatcher: BeEquivalentTo("0"), | ||
ttlMatcher: BeEquivalentTo("0"), | ||
regoParam1: `{"id": "[email protected]", "type": "property", "property": "email"}`, | ||
regoParam1: `{"id": "[email protected]", "subjectType": "property", "property": "email"}`, | ||
}), | ||
Entry("DigitalTwin externalID", &dtIDCase{ | ||
reqSubject: &authorizationpb.Subject{ | ||
Subject: &authorizationpb.Subject_ExternalId{ | ||
ExternalId: &authorizationpb.ExternalID{ | ||
Type: "Person", | ||
ExternalId: "some-external-id", | ||
}, | ||
}, | ||
}, | ||
// Test also nil values | ||
respDecisionTime: nil, | ||
respTTL: nil, | ||
decisionTimeMatcher: BeEquivalentTo("0"), | ||
ttlMatcher: BeEquivalentTo("0"), | ||
regoParam1: `{"id": "some-external-id", "subjectType": "external_id", "type": "Person"}`, | ||
}), | ||
) | ||
|
||
|
@@ -239,10 +255,10 @@ var _ = Describe("indy.what_authorized", func() { | |
Entry("Empty resource_references", `{"id": "`+testAccessToken+`"}, [], {}`, | ||
"unable to call WhatAuthorized client endpoint", | ||
"invalid WhatAuthorizedRequest.ResourceTypes: value must contain between 1 and 10 items, inclusive"), | ||
Entry("Invalid digital twin", `{"id": "abc", "type": "id"}, [{"type": "Type", "actions": ["READ"]}], {}`, | ||
Entry("Invalid digital twin", `{"id": "abc", "subjectType": "id"}, [{"type": "Type", "actions": ["READ"]}], {}`, | ||
"unable to call WhatAuthorized client endpoint", | ||
"invalid DigitalTwin.Id: value length must be between 27 and 100 runes"), | ||
Entry("Invalid propertyType", `{"id": "", "type": "property", "property": ""}, [{"type": "Type", "actions": ["READ"]}, {"type": "Type", "actions": ["READ"]}], {}`, | ||
Entry("Invalid propertyType", `{"id": "", "subjectType": "property", "property": ""}, [{"type": "Type", "actions": ["READ"]}, {"type": "Type", "actions": ["READ"]}], {}`, | ||
"unable to call WhatAuthorized client endpoint", | ||
"invalid Property.Type: value length must be between 2 and 20 runes"), | ||
) | ||
|