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

Hook more events into presign functionality #1340

Merged
merged 4 commits into from
Jan 25, 2018

Conversation

kyleknap
Copy link
Contributor

Specifically ensure the following:

  • The emission of provide-client-params event to hook in injection of parameters
  • The emission of before-parameter-build event event to hook in internal customizations related to parameters such as SSE-C MD5 injection.
  • Registering s3 accelerate handler to before-sign so s3 accelerate presigned url's can be created. It is important to note that I decided not to move the request-created event to the presigner because the signers are already hooked up to that event so re-emitting that event will cause the signers to get triggered again. Furthermore, putting it at before-sign is consistent with the handlers we use to change addressing style.

Fixes #978

Specifically ensure the following:

* The emission of provide-client-params event
* The emission of before-parameter-build event
* Registering s3 accelerate handler to before-sign so s3 accelerate
  presigned url's can be created
@codecov-io
Copy link

codecov-io commented Dec 18, 2017

Codecov Report

Merging #1340 into develop will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #1340      +/-   ##
===========================================
+ Coverage    98.17%   98.18%   +<.01%     
===========================================
  Files           46       46              
  Lines         7736     7748      +12     
===========================================
+ Hits          7595     7607      +12     
  Misses         141      141
Impacted Files Coverage Δ
botocore/signers.py 98.46% <100%> (+0.03%) ⬆️
botocore/stub.py 97.82% <100%> (+0.12%) ⬆️
botocore/client.py 99.74% <100%> (ø) ⬆️

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 bd2819a...27bc626. Read the comment docs.

@@ -23,9 +23,6 @@ class TestSTSPresignedUrl(BaseSessionTest):
def setUp(self):
super(TestSTSPresignedUrl, self).setUp()
self.client = self.session.create_client('sts', 'us-west-2')
# Makes sure that no requests will go through
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was removed because the stubber hooks into the parameter building related event for validating API/parameter calls, but since we did not previously add any expected API calls in test, the stubber will now complain about an unexpected API call.

It seems strange that a stubber would be used for presigned URL's in the first place, but I could see it potentially affect downstream tests though if someone used a stubber to stub out an API call and used the same stubbed client to generate a presigned url in their tests. What people's thoughts are on this?

Copy link
Contributor

@joguSD joguSD Dec 21, 2017

Choose a reason for hiding this comment

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

Is there another event the stubber could rely on?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I'd prefer if we could preserve this behavior somehow. The fact that we're changing a functional test suggests it's possible others will be impacted, especially given the stubber is a public API.

What are the other options here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@joguSD don't think there is another event the stubber could rely on. This PR is having the presigners emitprovide-client-params and before-parameter-build which are the events that would contain the unserialized parameters. Any of the other events down the stack use the serialized version of the parameters. So if we were to hook into another event, we would need to create a new one which we would not want to do.

@jamesls One idea initially that I have is to inject a value into the context object a flag like is_presign_request in the presigner logic and then in the Stubber class we can check for this flag and pass over asserting the request if the presign flag is present in the context. What's your thoughts on this? Not sure if there really any better options given the stubber currently does not have a way to disambiguate between a presign request and a normal client request.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry didn't see this until now. I'm not a huge fan on this because it unnecessarily couples the stubber and signers. Ideally the stubber shouldn't care about (or know) whether a request is presigned or not, it would just have better events it could hook into.

However, I'm not sure it's worth the trouble at this point to introduce new events so I think this is fine for now.

@@ -727,7 +728,7 @@ def test_generate_presigned_url(self):
'query_string': {},
'url_path': u'/mybucket/mykey',
'method': u'GET',
'context': {}}
'context': mock.ANY}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was switched to mock.ANY because we are now emitting the client parameter related events that inject values into the context. Thus using the context's exact value for these tests will be a maintenance burden if anymore customizations are added that inject into the context.

Copy link
Member

@jamesls jamesls Jan 15, 2018

Choose a reason for hiding this comment

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

I don't think review comments on your own PR are the best place for these type of contextual comments. Either a) A comment in the code or b) in the commit message.

@kyleknap
Copy link
Contributor Author

@jamesls @joguSD I updated the PR to add back the behavior to ignore presign requests for stubbing. Let me know what you think about that approach.

@kyleknap kyleknap added pr/needs-review This PR needs a review from a member of the team. and removed changes-requested labels Jan 17, 2018
@joguSD
Copy link
Contributor

joguSD commented Jan 19, 2018

I think this looks good now.

@kyleknap kyleknap merged commit 79a413d into boto:develop Jan 25, 2018
@kyleknap kyleknap deleted the presign-event branch January 25, 2018 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/needs-review This PR needs a review from a member of the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants