From 673a8a1e4a15edb3e6199432fc7e53714a651bb3 Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Fri, 4 Dec 2015 13:21:24 +0000 Subject: Remove unnecessary group name validation --- apps/provisioning_api/lib/groups.php | 2 +- apps/provisioning_api/tests/groupstest.php | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/provisioning_api/lib/groups.php b/apps/provisioning_api/lib/groups.php index 7a6e6150782..633e35357dd 100644 --- a/apps/provisioning_api/lib/groups.php +++ b/apps/provisioning_api/lib/groups.php @@ -130,7 +130,7 @@ class Groups{ public function addGroup($parameters) { // Validate name $groupId = $this->request->getParam('groupid', ''); - if( preg_match( '/[^a-zA-Z0-9 _\.@\-]/', $groupId ) || empty($groupId)){ + if(empty($groupId)){ \OCP\Util::writeLog('provisioning_api', 'Attempt made to create group using invalid characters.', \OCP\Util::ERROR); return new OC_OCS_Result(null, 101, 'Invalid group name'); } diff --git a/apps/provisioning_api/tests/groupstest.php b/apps/provisioning_api/tests/groupstest.php index f4f3b194944..84950d923e4 100644 --- a/apps/provisioning_api/tests/groupstest.php +++ b/apps/provisioning_api/tests/groupstest.php @@ -373,6 +373,27 @@ class GroupsTest extends \Test\TestCase { $this->assertTrue($result->succeeded()); } + public function testAddGroupWithSpecialChar() { + $this->request + ->method('getParam') + ->with('groupid') + ->willReturn('Iñtërnâtiônàlizætiøn'); + + $this->groupManager + ->method('groupExists') + ->with('NewGroup') + ->willReturn(false); + + $this->groupManager + ->expects($this->once()) + ->method('createGroup') + ->with('Iñtërnâtiônàlizætiøn'); + + $result = $this->api->addGroup([]); + $this->assertInstanceOf('OC_OCS_Result', $result); + $this->assertTrue($result->succeeded()); + } + public function testDeleteGroupNonExisting() { $result = $this->api->deleteGroup([ 'groupid' => 'NonExistingGroup' -- cgit v1.2.3 From 1af3bca720bab552528da26ba010f0d2c6ab9aa1 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Wed, 23 Dec 2015 08:31:20 +0100 Subject: Fix provisioning API unit test --- apps/provisioning_api/tests/groupstest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/provisioning_api/tests/groupstest.php b/apps/provisioning_api/tests/groupstest.php index 84950d923e4..7f84b3015ff 100644 --- a/apps/provisioning_api/tests/groupstest.php +++ b/apps/provisioning_api/tests/groupstest.php @@ -381,7 +381,7 @@ class GroupsTest extends \Test\TestCase { $this->groupManager ->method('groupExists') - ->with('NewGroup') + ->with('Iñtërnâtiônàlizætiøn') ->willReturn(false); $this->groupManager -- cgit v1.2.3 From 3327857c1ad21b022a1c35a01bee798328139ed8 Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Fri, 8 Jan 2016 10:42:55 +0000 Subject: Update log message when error occurs during addGroup --- apps/provisioning_api/lib/groups.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps') diff --git a/apps/provisioning_api/lib/groups.php b/apps/provisioning_api/lib/groups.php index 633e35357dd..b54041ac0f2 100644 --- a/apps/provisioning_api/lib/groups.php +++ b/apps/provisioning_api/lib/groups.php @@ -131,7 +131,7 @@ class Groups{ // Validate name $groupId = $this->request->getParam('groupid', ''); if(empty($groupId)){ - \OCP\Util::writeLog('provisioning_api', 'Attempt made to create group using invalid characters.', \OCP\Util::ERROR); + \OCP\Util::writeLog('provisioning_api', 'Group name not supplied', \OCP\Util::ERROR); return new OC_OCS_Result(null, 101, 'Invalid group name'); } // Check if it exists -- cgit v1.2.3