Skip to content

Commit

Permalink
Add permissions to tagging schema (#1003)
Browse files Browse the repository at this point in the history
  • Loading branch information
yueful27 authored Jun 2, 2023
1 parent c45eec2 commit 3740564
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/rpdk/core/contract/resource_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,9 @@ def metadata_contains_tag_property(self):
except KeyError:
return False

def get_tagging_permissions(self):
return self._schema.get("tagging", {}).get("permissions", [])

def validate_model_contain_tags(self, inputs):
assertion_error_message = "Contract test inputs does not contain tags property."
try:
Expand Down
7 changes: 7 additions & 0 deletions src/rpdk/core/data/schema/provider.definition.schema.v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@
"description": "A reference to the Tags property in the schema.",
"$ref": "http://json-schema.org/draft-07/schema#/properties/$ref",
"default": "/properties/Tags"
},
"permissions": {
"type": "array",
"items": {
"type": "string"
},
"additionalItems": false
}
},
"required": [
Expand Down
12 changes: 12 additions & 0 deletions tests/contract/test_resource_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,18 @@ def test_metadata_contains_tag_property(resource_client):
assert resource_client.metadata_contains_tag_property()


@pytest.mark.parametrize(
"schema,result",
[
({"tagging": {"permissions": ["test:permission"]}}, ["test:permission"]),
({}, []),
],
)
def test_get_tagging_permission(resource_client, schema, result):
resource_client._update_schema(schema)
assert resource_client.get_tagging_permissions() == result


def test_validate_model_contain_tags(resource_client):
schema = {"tagging": {"taggable": True, "tagProperty": "/properties/Tags"}}
resource_client._update_schema(schema)
Expand Down

0 comments on commit 3740564

Please sign in to comment.