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

Allow integration testing of secure post requests with a query string. #9103

Merged
merged 2 commits into from
Jul 13, 2016

Conversation

dakota
Copy link
Member

@dakota dakota commented Jul 12, 2016

The current integration test secure token generation does not take query strings into account, while the security component does. This address that inconsistency.

The current integration test secure token generation does not take query strings into account, while the security component does. This address that inconsistency.
@dakota dakota added the defect label Jul 12, 2016
@dakota dakota added this to the 3.2.13 milestone Jul 12, 2016
@codecov-io
Copy link

codecov-io commented Jul 12, 2016

Current coverage is 94.94%

Merging #9103 into master will increase coverage by <.01%

@@             master      #9103   diff @@
==========================================
  Files           368        368          
  Lines         26988      26991     +3   
  Methods        3232       3232          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          25623      25626     +3   
  Misses         1365       1365          
  Partials          0          0          

Powered by Codecov. Last updated by 029f0c5...11f7c3d

@@ -434,10 +434,15 @@ protected function _buildRequest($url, $method, $data)
$session = Session::create($sessionConfig);
$session->write($this->_session);
list ($url, $query) = $this->_url($url);
$tokenUrl = $url;

if (!empty($query)) {
Copy link
Member

Choose a reason for hiding this comment

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

If ($query)

Copy link
Member

Choose a reason for hiding this comment

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

why? empty reads a lot better

Copy link
Member

@dereuromark dereuromark Jul 12, 2016

Choose a reason for hiding this comment

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

As per our guidelines to not cloak variable checks.
Prevents bugs in the future and reads exactly the same.
=> http://book.cakephp.org/3.0/en/contributing/cakephp-coding-conventions.html#careful-when-using-empty-isset

Copy link
Member Author

Choose a reason for hiding this comment

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

If that's what the guidelines say 👍

Copy link
Member

Choose a reason for hiding this comment

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

That's a weird guideline... why trigger a type conversion for no reason?

Copy link
Member

@dereuromark dereuromark Jul 12, 2016

Choose a reason for hiding this comment

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

Check the discussion a while back where not doing this actually led to existing bugs in the core framework.
E.g. refactoring to

if (!empty($guery)) { // now dead code }

by accident - note the almost invisible guery vs query.

The alternative would be to use if (count(...) > 0).

@markstory markstory merged commit e6e3ca7 into cakephp:master Jul 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants