Merge pull request #20961 from owncloud/provis-api-group-special-char

Remove unnecessary group name validation in provisioning_api
This commit is contained in:
Thomas Müller 2016-01-08 20:11:20 +01:00
commit ea227aadf2
2 changed files with 23 additions and 2 deletions

View file

@ -130,8 +130,8 @@ class Groups{
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

View file

@ -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('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'