Skip to content

Fix add/delete user to group 0 via provisioning API - #29994

Merged
phil-davis merged 2 commits into
masterfrom
add-user-to-group-0
Jan 2, 2018
Merged

phil-davis merged 2 commits into
masterfrom
add-user-to-group-0

Conversation

@phil-davis

Copy link
Copy Markdown
Contributor

Description

  1. Add scenarios for adding users to group 0.
  2. Add scenarios for deleting users from group 0.
    Those scenarios fail, so fix the code:
  3. When checking the group id, do not test with the empty() function - test explicitly for the things that are "empty" apart from 0.

Related Issue

#29990

Motivation and Context

Remove more uses of empty() that cause problems for data that has the valid value "0".

How Has This Been Tested?

Run the API tests locally.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

$groupId = !empty($_POST['groupid']) ? $_POST['groupid'] : null;
if($groupId === null) {
$groupId = $_POST['groupid'];
if (($groupId === '') || ($groupId === null) || ($groupId === false)) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note: this uses the same style of check that was done in Groups.php addGroup a while ago.

@codecov

codecov Bot commented Dec 29, 2017 •

Copy link
Copy Markdown

Codecov Report

Merging #29994 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master   #29994   +/-   ##
=========================================
  Coverage     58.21%   58.21%           
- Complexity    18508    18512    +4     
=========================================
  Files          1093     1093           
  Lines         63693    63693           
=========================================
  Hits          37082    37082           
  Misses        26611    26611

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 4222b7c...a344314. Read the comment docs.

@phil-davis

Copy link
Copy Markdown
Contributor Author

Note: the 2nd commit is needed because the test scenarios are not independent. The scenarios do not seem to clean up their state (in this case which users are in which groups) at the end of each scenario.

As a separate issue, that should all be sorted out some day.

@individual-it

Copy link
Copy Markdown
Member

Looks good, should we add tests that test really empty group names?

@phil-davis

Copy link
Copy Markdown
Contributor Author

This scenario seems to send an empty groupid:

Scenario: adding user to a group without sending the group

@phil-davis
phil-davis merged commit 4700637 into master Jan 2, 2018
@phil-davis
phil-davis deleted the add-user-to-group-0 branch January 2, 2018 05:00
@phil-davis

Copy link
Copy Markdown
Contributor Author

Backport stable10 #30004

@lock

lock Bot commented Aug 1, 2019

Copy link
Copy Markdown

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.

@lock lock Bot locked as resolved and limited conversation to collaborators Aug 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants