Repository navigation
Allow group 0 to be created by provisioning API - #29712
Conversation
e37b857 to
46c5610
Compare
Codecov Report
@@ Coverage Diff @@
## master #29712 +/- ##
=========================================
Coverage 62.49% 62.49%
- Complexity 17619 17621 +2
=========================================
Files 1045 1045
Lines 58070 58070
=========================================
Hits 36288 36288
Misses 21782 21782
Continue to review full report at Codecov.
|
| // Validate name | ||
| $groupId = $this->request->getParam('groupid', ''); | ||
| if(empty($groupId)){ | ||
| if($groupId == ''){ |
There was a problem hiding this comment.
can you make that === ? because == might also match null values. If we also want to check for nulll values, also add is_null($groupId)
There was a problem hiding this comment.
I wanted to match all of:
if ($group === "")
if (is_null($group))
if ($group === false)
and those 3 things all are done in 1 statement by:
if ($group == "")
There was a problem hiding this comment.
In theory the return value of getParam is always a string - it "should" never be null or false, but who knows.
There was a problem hiding this comment.
you could check if $group is a string and if not also show the same error. Or even throw an exception because if the the group name is not a string something went terrible wrong.
There was a problem hiding this comment.
Way too much time spent on a 1-line fix. Somebody tell me what code will be accepted for review and then I can write that. Otherwise I will just be guessing what is wanted and going round-and-round the long CI process.
|
Why is Jenkins failing? Do the Scenarios depend on each other? |
|
Yes, it does not look ideal - groups that are created by (creating users has the same issue) |
46c5610 to
e69a50a
Compare
|
|
||
| Scenario: Getting all groups | ||
| Given as an "admin" | ||
| And group "0" exists |
There was a problem hiding this comment.
I "fixed up" this test so that at least it explicitly specifies each group to exists then checks that they are returned by the /cloud/groups endpoint.
Actually each group (except admin) is created in one of the previous scenarios by code that does:
When sending "POST" to "/cloud/groups" with
That step does not "remember" that it created a group, because that is a generic step for "driving the API". So in those kind of scenarios, the created group is not deleted by the AfterScenario code.
Thus this scenario would actually pass without specifically needing to mention that the 4 groups "exist".
Creating users has the same problem - various scenarios create users that are not deleted in the AfterScenario code. But all that sort of thing needs to be looked at separately, otherwise this "little" PR will become "bigger than Ben Hur" if it starts rectifying existing "features" of the test infrastructure.
Changes since original review - please review again.
e69a50a to
6b7b87c
Compare
| // Validate name | ||
| $groupId = $this->request->getParam('groupid', ''); | ||
| if(empty($groupId)){ | ||
| if(($groupId === '') || is_null($groupId) || ($groupId === false)){ |
There was a problem hiding this comment.
@PVince81 I went for the full list here - empty() essentially means "blank or null or false or 0 or '0'". We want 0 or '0' to be allowed and the others can continue to be banned as a group name.
|
Backport stable10 #29734 |
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
Only the empty string should be rejected as a group name (or things that
==the empty string such asnullandfalse). This lets "0" be created as a group name.Related Issue
#29698
Motivation and Context
Zero and empty must not live in the same house.
How Has This Been Tested?
The new integration test fails before and passes after this fix.
Types of changes
Checklist: