Skip to content

[7.x] Added ability to simulate "withCredentials" in test requests - #33497

Merged
taylorotwell merged 1 commit into
laravel:7.xfrom
kohlerdominik:allow-withCredentials-for-json-in-tests
Jul 10, 2020
Merged

[7.x] Added ability to simulate "withCredentials" in test requests#33497
taylorotwell merged 1 commit into
laravel:7.xfrom
kohlerdominik:allow-withCredentials-for-json-in-tests

Conversation

@kohlerdominik

@kohlerdominik kohlerdominik commented Jul 10, 2020

Copy link
Copy Markdown
Contributor

Hi all

I stumbled over a missing functionality in the test cases. As stated here, XMLHttpRequests allow a flag which is named "withCredentials" to include cookies in the requests.

The XMLHttpRequest.withCredentials property is a Boolean that indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies, authorization headers or TLS client certificates. Setting withCredentials has no effect on same-site requests.

By default, all JSON-requests implicit use an empty cookies-array. But with the knowledge of this flag, in my opinion it makes sense to make it configurable whether json requests should include cookies or not.

This PR adds a method to test cases, which allow to use $this->withCredentials() in a test to make all json()-calls include the cookie-jars, which are available anyway.

@taylorotwell
taylorotwell merged commit 9053103 into laravel:7.x Jul 10, 2020
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.

2 participants