Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Raise exception if provided Auth.Authorizers.Identity isn't a dict #2273

Merged
merged 4 commits into from Jan 17, 2022

Conversation

mildaniel
Copy link
Contributor

Issue #, if available:

Description of changes:

Description of how you validated changes:

Checklist:

  • Add/update tests using:
  • make pr passes
  • Update documentation
  • Verify transformed template deploys and application functions as expected

Examples?

Please reach out in the comments, if you want to add an example. Examples will be
added to sam init through https://github.com/awslabs/aws-sam-cli-app-templates/

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@codecov-commenter
Copy link

codecov-commenter commented Dec 20, 2021

Codecov Report

Merging #2273 (a79d3bb) into develop (e7a1496) will increase coverage by 0.81%.
The diff coverage is 98.04%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2273      +/-   ##
===========================================
+ Coverage    93.58%   94.39%   +0.81%     
===========================================
  Files           90       97       +7     
  Lines         6124     7086     +962     
  Branches      1260     1434     +174     
===========================================
+ Hits          5731     6689     +958     
+ Misses         183      181       -2     
- Partials       210      216       +6     
Impacted Files Coverage Δ
samtranslator/model/lambda_.py 93.10% <ø> (ø)
samtranslator/model/api/http_api_generator.py 91.21% <75.00%> (+0.02%) ⬆️
samtranslator/model/api/api_generator.py 93.69% <86.11%> (-0.67%) ⬇️
samtranslator/model/eventsources/push.py 92.39% <95.65%> (+1.47%) ⬆️
samtranslator/__init__.py 100.00% <100.00%> (ø)
samtranslator/feature_toggle/dialup.py 100.00% <100.00%> (ø)
samtranslator/feature_toggle/feature_toggle.py 100.00% <100.00%> (+12.16%) ⬆️
samtranslator/intrinsics/actions.py 98.79% <100.00%> (+0.07%) ⬆️
samtranslator/metrics/method_decorator.py 100.00% <100.00%> (ø)
samtranslator/metrics/metrics.py 100.00% <100.00%> (ø)
... and 39 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6daf706...a79d3bb. Read the comment docs.

Comment on lines 398 to 406
try:
if not self.identity or not self.identity.get("Header"):
return "Authorization"
except AttributeError:
raise InvalidResourceException(
self.api_logical_id,
"Auth.Authorizers.<Authorizer>.Identity must be a dict (LambdaTokenAuthorizationIdentity "
"or LambdaRequestAuthorizationIdentity).",
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of try/except block, shouldn't we check if the property is an expected type (dict in this case)?

@mildaniel mildaniel merged commit 85177ef into aws:develop Jan 17, 2022
@mildaniel mildaniel deleted the check-auth-identity-type branch January 17, 2022 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants