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

[10.x] Remove config repository dependency from webhook middleware #793

Merged

Conversation

sebdesign
Copy link
Contributor

Similarly to #791, we can remove the \Illuminate\Contracts\Config\Repository in the VerifyWebhookSignature's constructor. For consistency, the configuration is accessed with the config() helper like the rest of the code.

Since we don't need to mock the configuration repository anymore, the test has been moved to the integration suite, because we need to bootstrap the framework.

As a bonus, I have added tests for checking replay attacks against the tolerance configuration setting.

Similarly to laravel#791, we can remove the `\Illuminate\Contracts\Config\Repository` in the `VerifyWebhookSignature`'s constructor. For consistency, the configuration is accessed with the `config()` helper like the rest of the code.

Since we don't need to mock the configuration repository anymore, the test has been moved to the integration suite, because we need to bootstrap the framework.

As a bonus, I have added tests for checking [replay attacks](https://stripe.com/docs/webhooks/signatures#replay-attacks) against the tolerance configuration setting.
@driesvints
Copy link
Member

@sebdesign I think I now realize why this was a unit test. Because we're now using the container to resolve config dependencies we can't unit test the middleware anymore. The reply attack tests are nice though. Can you maybe send in a new PR with the old implementation? Thanks!

@driesvints driesvints closed this Sep 30, 2019
@sebdesign
Copy link
Contributor Author

But do we really need to unit test the middleware? Isn't an integration test as much as valuable?

I'll send an other PR with the timing tests though, but I don't believe it's worth injecting the config repository just to be able to isolate this middleware, while the config is resolved with the helper in all the other places.

What do you think?

@driesvints
Copy link
Member

Okay, I agree after consideration.

@driesvints driesvints reopened this Sep 30, 2019
@driesvints driesvints changed the title Remove config repository dependency from webhook middleware [10.x] Remove config repository dependency from webhook middleware Sep 30, 2019
@taylorotwell taylorotwell merged commit 3ad5907 into laravel:10.0 Oct 1, 2019
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.

3 participants