Skip to content

Commit a012507

Browse files
Update credentials() function to provide expected resource via CEL expr
1 parent e13d79e commit a012507

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎src/celpy/c7nlib.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ def subst(jmes_path: celtypes.StringType,) -> celtypes.StringType:
985985
return celtypes.StringType(jmes_path.format(**config_args))
986986

987987

988-
def credentials(vpc_id: celtypes.Value,) -> celtypes.Value:
988+
def credentials(resource: celtypes.MapType) -> celtypes.Value:
989989
"""
990990
Reach into C7N and make a get_related() request using the current C7N filter to get
991991
the IAM-role credential details.
@@ -999,7 +999,7 @@ def credentials(vpc_id: celtypes.Value,) -> celtypes.Value:
999999
``CredentialReportMixin`` mixin to the :py:class:`CELFilter` class.
10001000
The ``get_credential_report()`` function does what we need.
10011001
"""
1002-
return json_to_cel(C7N.filter.get_credential_report())
1002+
return json_to_cel(C7N.filter.get_credential_report(resource))
10031003

10041004

10051005
def kms_alias(vpc_id: celtypes.Value,) -> celtypes.Value:

‎tests/test_c7nlib.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,9 @@ def test_C7N_CELFilter_credentials(celfilter_instance):
11131113
with celpy.c7nlib.C7NContext(filter=mock_filter):
11141114
credentials = celpy.c7nlib.credentials(ec2_doc)
11151115
assert credentials == str(sentinel.credential)
1116-
assert mock_filter.get_credential_report.mock_calls == [call()]
1116+
assert mock_filter.get_credential_report.mock_calls == [call(
1117+
{'ResourceType': 'ec2', 'InstanceId': 'i-123456789'}
1118+
)]
11171119

11181120

11191121
def test_C7N_CELFilter_kms_alias(celfilter_instance):

0 commit comments

Comments
 (0)