-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2982050
commit 961701d
Showing
3 changed files
with
10 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -470,7 +470,6 @@ def main(): | |
is_authorized_property_parser = subparsers.add_parser("is_authorized_property") | ||
is_authorized_property_parser.add_argument("property_type", help="Digital Twin Identity Property") | ||
is_authorized_property_parser.add_argument("property_value", help="Digital Twin Identity Property value") | ||
is_authorized_property_parser.add_argument("tenant_id", help="Tenant id (gid)") | ||
|
||
args = parser.parse_args() | ||
local = args.local | ||
|
@@ -1669,10 +1668,9 @@ def main(): | |
elif command == "is_authorized_property": | ||
property_type = args.property_type #e.g "email" | ||
property_value = args.property_value #e.g [email protected] | ||
tenant_id = args.tenant_id | ||
resources = [IsAuthorizedResource("resourceID", "LabelName"), IsAuthorizedResource("resource2ID", "LabelName")] | ||
actions = ["ACTION"] | ||
is_authorized = client_authorization.is_authorized_property_filter(property_type, property_value, tenant_id, | ||
is_authorized = client_authorization.is_authorized_property_filter(property_type, property_value, | ||
resources=resources, actions=actions) | ||
if is_authorized: | ||
print_response(is_authorized) | ||
|
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 |
---|---|---|
|
@@ -139,12 +139,11 @@ def test_is_authorized_property_wrong_property(): | |
client = AuthorizationClient() | ||
assert client is not None | ||
|
||
type_filter = "email" | ||
type_filter = "phone" | ||
email_value = "[email protected]" | ||
tenant_id = data.get_tenant() | ||
resources = [IsAuthorizedResource("resourceID", "LabelName"), IsAuthorizedResource("resource2ID", "LabelName")] | ||
actions = ["ACTION"] | ||
response = client.is_authorized_property_filter(type_filter, email_value, tenant_id, resources, actions) | ||
response = client.is_authorized_property_filter(type_filter, email_value, resources, actions) | ||
assert response is None | ||
|
||
|
||
|
@@ -154,10 +153,9 @@ def test_is_authorized_property_wrong_resources(): | |
|
||
type_filter = "email" | ||
email_value = "[email protected]" | ||
tenant_id = data.get_tenant() | ||
actions = ["ACTION"] | ||
resources = [{"resourceID", "LabelName"}] | ||
response = client.is_authorized_property_filter(type_filter, email_value, tenant_id, resources, actions) | ||
response = client.is_authorized_property_filter(type_filter, email_value, resources, actions) | ||
assert response is None | ||
|
||
|
||
|
@@ -167,14 +165,12 @@ def test_is_authorized_property_success(): | |
|
||
type_filter = "email" | ||
email_value = "[email protected]" | ||
tenant_id = data.get_tenant() | ||
resources = [IsAuthorizedResource("resourceID", "LabelName"), IsAuthorizedResource("resource2ID", "LabelName")] | ||
actions = ["ACTION"] | ||
digital_twin_identifier = pb2_ident.DigitalTwinIdentifier( | ||
property_filter=pb2_ident.PropertyFilter( | ||
type=str(type_filter), | ||
value=pb2_struct.Value(string_value=email_value), | ||
tenant_id=str(tenant_id) | ||
value=pb2_struct.Value(string_value=email_value) | ||
) | ||
) | ||
|
||
|
@@ -183,7 +179,7 @@ def mocked_is_authorized(request: pb2.IsAuthorizedRequest): | |
return pb2.IsAuthorizedResponse() | ||
|
||
client.stub.IsAuthorized = mocked_is_authorized | ||
response = client.is_authorized_property_filter(type_filter, email_value, tenant_id, resources, actions) | ||
response = client.is_authorized_property_filter(type_filter, email_value, resources, actions) | ||
assert response is not None | ||
|
||
|
||
|
@@ -193,14 +189,12 @@ def test_is_authorized_property_empty(): | |
|
||
type_filter = "email" | ||
email_value = "[email protected]" | ||
tenant_id = data.get_tenant() | ||
resources = [IsAuthorizedResource("resourceID", "LabelName"), IsAuthorizedResource("resource2ID", "LabelName")] | ||
actions = ["ACTION"] | ||
digital_twin_identifier = pb2_ident.DigitalTwinIdentifier( | ||
property_filter=pb2_ident.PropertyFilter( | ||
type=str(type_filter), | ||
value=pb2_struct.Value(string_value=email_value), | ||
tenant_id=str(tenant_id) | ||
value=pb2_struct.Value(string_value=email_value) | ||
) | ||
) | ||
|
||
|
@@ -209,5 +203,5 @@ def mocked_is_authorized(request: pb2.IsAuthorizedRequest): | |
return None | ||
|
||
client.stub.IsAuthorized = mocked_is_authorized | ||
response = client.is_authorized_property_filter(type_filter, email_value, tenant_id, resources, actions) | ||
response = client.is_authorized_property_filter(type_filter, email_value, resources, actions) | ||
assert response is None |