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

[tests-only] Acceptance test changes pending for master #39514

Closed
wants to merge 18 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
07ed350
Improve checks in tests for disabling a user
phil-davis Nov 22, 2021
3e2e8df
Reduce use of range download in acceptance tests
phil-davis Nov 22, 2021
9a61739
Fix SetupHelper runOcc to use strings only in exception messages
phil-davis Nov 25, 2021
03c840f
Add tests to demonstrate group names with leading and trailing spaces
phil-davis Nov 25, 2021
8d0377d
Adjust group tests for issue-39533
phil-davis Nov 26, 2021
c152987
Refactor getGroups tests to not depend on the starting groups
phil-davis Nov 26, 2021
5905554
Fix missing HTTP status code in createPublicLinkShare test scenarios
phil-davis Nov 26, 2021
d2c9f69
Use when step for the test scenario with only Then.
kiranparajuli589 Dec 3, 2021
ee2b770
[tests-only]Fixed order dependent flaky test detected in files_classi…
Talank Dec 3, 2021
fcec0eb
add tests for db-convert occ command
saw-jan Oct 22, 2021
2987544
Do not allow white space at the start or end of a group name
phil-davis Nov 25, 2021
38ee68e
Add bug demonstration test for sending PUT request to other user's we…
SwikritiT Dec 15, 2021
4092397
refactor test helpers and contexts for parallel deployment tests
saw-jan Dec 15, 2021
112f2f2
Add spaces as a new webdav url type
kiranparajuli589 Dec 15, 2021
7a450af
skipOnEncryption dbConversion.feature as it needs special CI setup
phil-davis Dec 19, 2021
cf3e5a3
added tests for files_external occ command
sakshamgurung Nov 19, 2021
62511ca
Merge pull request #39599 from owncloud/space-as-new-webdav
phil-davis Dec 20, 2021
6080353
Add extra checks to getPersonalSpaceIdForUser
phil-davis Dec 21, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Do not allow white space at the start or end of a group name
phil-davis committed Dec 14, 2021
commit 2987544bfd6f6823df68f6ea392ba41c1ea4f07c
4 changes: 4 additions & 0 deletions apps/provisioning_api/lib/Groups.php
Original file line number Diff line number Diff line change
@@ -136,6 +136,10 @@ public function addGroup($parameters) {
\OCP\Util::writeLog('provisioning_api', 'Group name not supplied', \OCP\Util::ERROR);
return new OC_OCS_Result(null, 101, 'Invalid group name');
}
if (\trim($groupId) !== $groupId) {
\OCP\Util::writeLog('provisioning_api', 'Group name must not start or end with white space', \OCP\Util::ERROR);
return new OC_OCS_Result(null, 101, 'Invalid group name');
}
// Check if it exists
if ($this->groupManager->groupExists($groupId)) {
return new OC_OCS_Result(null, 102);
19 changes: 17 additions & 2 deletions apps/provisioning_api/tests/GroupsTest.php
Original file line number Diff line number Diff line change
@@ -333,11 +333,26 @@ public function testGetSubAdminsOfGroupEmptyList() {
$this->assertEquals([], $result->getData());
}

public function testAddGroupEmptyGroup() {
public function dataAddGroupWithInvalidName() {
return [
[''],
[' '],
[' white-space-at-start'],
['white-space-at-end '],
[' white-space-at-both-ends '],
];
}

/**
* @dataProvider dataAddGroupWithInvalidName
*
* @param string $groupName
*/
public function testAddGroupWithInvalidName($groupName) {
$this->request
->method('getParam')
->with('groupid')
->willReturn('');
->willReturn($groupName);

$result = $this->api->addGroup([]);

3 changes: 3 additions & 0 deletions changelog/unreleased/39540
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Bugfix: Prevent group names starting or ending with white space

https://github.com/owncloud/core/pull/39540
2 changes: 1 addition & 1 deletion lib/private/Group/Manager.php
Original file line number Diff line number Diff line change
@@ -210,7 +210,7 @@ public function groupExists($gid) {
* @return \OC\Group\Group
*/
public function createGroup($gid) {
if ($gid === '' || $gid === null) {
if ($gid === '' || $gid === null || \trim($gid) !== $gid) {
return false;
} elseif ($group = $this->get($gid)) {
return $group;
20 changes: 10 additions & 10 deletions tests/acceptance/features/apiProvisioningGroups-v1/addGroup.feature
Original file line number Diff line number Diff line change
@@ -154,28 +154,28 @@ Feature: add groups
And the HTTP status code should be "401"
And group "another-new-group" should not exist

@issue-39533 @skipOnOcV10
Scenario: admin creates a group that has white space at the end of the name

Scenario: admin tries to create a group that has white space at the end of the name
When the administrator sends a group creation request for group "white-space-at-end " using the provisioning API
Then the OCS status code should be "100"
Then the OCS status code should be "101"
And the HTTP status code should be "200"
And group "white-space-at-end " should exist
And group "white-space-at-end " should not exist
And group "white-space-at-end" should not exist


Scenario: admin creates a group that has white space at the start of the name
Scenario: admin tries to create a group that has white space at the start of the name
When the administrator sends a group creation request for group " white-space-at-start" using the provisioning API
Then the OCS status code should be "100"
Then the OCS status code should be "101"
And the HTTP status code should be "200"
And group " white-space-at-start" should exist
And group " white-space-at-start" should not exist
But group "white-space-at-start" should not exist


Scenario: admin creates a group that is a single space
Scenario: admin tries to create a group that is a single space
When the administrator sends a group creation request for group " " using the provisioning API
Then the OCS status code should be "100"
Then the OCS status code should be "101"
And the HTTP status code should be "200"
And group " " should exist
And group " " should not exist


Scenario: admin tries to create a group that is the empty string

This file was deleted.

28 changes: 14 additions & 14 deletions tests/acceptance/features/apiProvisioningGroups-v2/addGroup.feature
Original file line number Diff line number Diff line change
@@ -150,28 +150,28 @@ Feature: add groups
And the HTTP status code should be "401"
And group "another-new-group" should not exist

@issue-39533 @skipOnOcV10
Scenario: admin creates a group that has white space at the end of the name

Scenario: admin tries to create a group that has white space at the end of the name
When the administrator sends a group creation request for group "white-space-at-end " using the provisioning API
Then the OCS status code should be "200"
And the HTTP status code should be "200"
And group "white-space-at-end " should exist
Then the OCS status code should be "400"
And the HTTP status code should be "400"
And group "white-space-at-end " should not exist
And group "white-space-at-end" should not exist


Scenario: admin creates a group that has white space at the start of the name
Scenario: admin tries to create a group that has white space at the start of the name
When the administrator sends a group creation request for group " white-space-at-start" using the provisioning API
Then the OCS status code should be "200"
And the HTTP status code should be "200"
And group " white-space-at-start" should exist
But group "white-space-at-start" should not exist
Then the OCS status code should be "400"
And the HTTP status code should be "400"
And group " white-space-at-start" should not exist
And group "white-space-at-start" should not exist


Scenario: admin creates a group that is a single space
Scenario: admin tries to create a group that is a single space
When the administrator sends a group creation request for group " " using the provisioning API
Then the OCS status code should be "200"
And the HTTP status code should be "200"
And group " " should exist
Then the OCS status code should be "400"
And the HTTP status code should be "400"
And group " " should not exist


Scenario: admin tries to create a group that is the empty string

This file was deleted.

6 changes: 6 additions & 0 deletions tests/acceptance/features/bootstrap/OccUsersGroupsContext.php
Original file line number Diff line number Diff line change
@@ -422,6 +422,12 @@ public function theAdministratorRetrievesTheUserReportUsingTheOccCommand():void
* @throws Exception
*/
public function theAdministratorCreatesGroupUsingTheOccCommand(string $group):void {
if (($group === '') || (\trim($group) !== $group)) {
// The group name is empty or has white space at the start or end.
// Quote the group name so that the white space is really sent to the
// occ command as part of the requested group name.
$group = "'$group'";
}
$this->occContext->invokingTheCommand(
"group:add $group"
);
27 changes: 26 additions & 1 deletion tests/acceptance/features/cliProvisioning/addGroup.feature
Original file line number Diff line number Diff line change
@@ -32,4 +32,29 @@ Feature: add group
Given group "brand-new-group" has been created
When the administrator creates group "brand-new-group" using the occ command
Then the command should have failed with exit code 1
And the command output should contain the text 'The group "brand-new-group" already exists'
And the command output should contain the text 'The group "brand-new-group" already exists'

Scenario: admin tries to create a group that has white space at the end of the name
When the administrator creates group "white-space-at-end " using the occ command
Then the command should have failed with exit code 1
And the command output should contain the text 'Group "white-space-at-end " could not be created'
And group "white-space-at-end " should not exist
And group "white-space-at-end" should not exist

Scenario: admin tries to create a group that has white space at the start of the name
When the administrator creates group " white-space-at-start" using the occ command
Then the command should have failed with exit code 1
And the command output should contain the text 'Group " white-space-at-start" could not be created'
And group " white-space-at-start" should not exist
And group "white-space-at-start" should not exist

Scenario: admin tries to create a group that is a single space
When the administrator creates group " " using the occ command
Then the command should have failed with exit code 1
And the command output should contain the text 'Group " " could not be created'
And group " " should not exist

Scenario: admin tries to create a group that is the empty string
When the administrator creates group "" using the occ command
Then the command should have failed with exit code 1
And the command output should contain the text 'Group "" could not be created'
20 changes: 20 additions & 0 deletions tests/lib/Group/ManagerTest.php
Original file line number Diff line number Diff line change
@@ -243,6 +243,26 @@ public function testCreate() {
$this->assertEquals('group1', $group->getGID());
}

public function dataCreateGroupWithInvalidName() {
return [
[''],
[' '],
[' white-space-at-start'],
['white-space-at-end '],
[' white-space-at-both-ends '],
];
}

/**
* @dataProvider dataCreateGroupWithInvalidName
*
* @param string $groupName
*/
public function testCreateInvalidGroupName(string $groupName) {
$group = $this->manager->createGroup($groupName);
$this->assertFalse($group);
}

public function testCreateWithDispatcher() {
/**
* @var \PHPUnit\Framework\MockObject\MockObject | \OC\Group\Backend $backend