Skip to content

Commit

Permalink
Merge pull request #20961 from owncloud/provis-api-group-special-char
Browse files Browse the repository at this point in the history
Remove unnecessary group name validation in provisioning_api
  • Loading branch information
DeepDiver1975 committed Jan 8, 2016
2 parents 1f21f0e + 3327857 commit ea227aa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apps/provisioning_api/lib/groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ public function getGroup($parameters) {
public function addGroup($parameters) {
// Validate name
$groupId = $this->request->getParam('groupid', '');
if( preg_match( '/[^a-zA-Z0-9 _\.@\-]/', $groupId ) || empty($groupId)){
\OCP\Util::writeLog('provisioning_api', 'Attempt made to create group using invalid characters.', \OCP\Util::ERROR);
if(empty($groupId)){
\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
Expand Down
21 changes: 21 additions & 0 deletions apps/provisioning_api/tests/groupstest.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,27 @@ public function testAddGroup() {
$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('Iñtërnâtiônàlizætiøn')
->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'
Expand Down

0 comments on commit ea227aa

Please sign in to comment.