summaryrefslogtreecommitdiffstats
path: root/tests/settings
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2014-12-08 22:38:54 +0100
committerLukas Reschke <lukas@owncloud.com>2014-12-09 12:04:19 +0100
commit4c13918bd8b12ac4bd341c846a50accc1bf9704d (patch)
tree7b3a4e39511e401ef8b75b49a117d2a8fbe3ab7c /tests/settings
parent25a87d4058b3ec7f21649940949b6fc0237968dc (diff)
downloadnextcloud-server-4c13918bd8b12ac4bd341c846a50accc1bf9704d.tar.gz
nextcloud-server-4c13918bd8b12ac4bd341c846a50accc1bf9704d.zip
Expose backend type via REST API
This change will expose the user backend via the REST API which is a pre-requisite for https://github.com/owncloud/core/issues/12620. For example: ````json [{"name":"9707A09E-CA9A-4ABE-A66A-3F632F16C409","displayname":"Document Conversion User Account","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/9707A09E-CA9A-4ABE-A66A-3F632F16C409","lastLogin":0,"backend":"OCA\\user_ldap\\USER_LDAP"},{"name":"ED86733E-745C-4E4D-90CB-278A9737DB3C","displayname":"Hacker","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/ED86733E-745C-4E4D-90CB-278A9737DB3C","lastLogin":0,"backend":"OCA\\user_ldap\\USER_LDAP"},{"name":"71CDF45B-E125-450D-983C-D9192F36EC88","displayname":"admin","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/71CDF45B-E125-450D-983C-D9192F36EC88","lastLogin":0,"backend":"OCA\\user_ldap\\USER_LDAP"},{"name":"admin","displayname":"admin","groups":["admin"],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/admin","lastLogin":"1418057287","backend":"OC_User_Database"},{"name":"test","displayname":"test","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/test","lastLogin":0,"backend":"OC_User_Database"}] ```
Diffstat (limited to 'tests/settings')
-rw-r--r--tests/settings/controller/userscontrollertest.php115
1 files changed, 77 insertions, 38 deletions
diff --git a/tests/settings/controller/userscontrollertest.php b/tests/settings/controller/userscontrollertest.php
index 4b0683b6dae..eb48babadc8 100644
--- a/tests/settings/controller/userscontrollertest.php
+++ b/tests/settings/controller/userscontrollertest.php
@@ -54,30 +54,68 @@ class UsersControllerTest extends \Test\TestCase {
* to test for subadmins. Thus the test always assumes you have admin permissions...
*/
public function testIndex() {
- $admin = $this->getMockBuilder('\OC\User\User')
- ->disableOriginalConstructor()->getMock();
- $admin
- ->method('getLastLogin')
- ->will($this->returnValue(12));
- $admin
- ->method('getHome')
- ->will($this->returnValue('/home/admin'));
$foo = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$foo
+ ->expects($this->exactly(3))
+ ->method('getUID')
+ ->will($this->returnValue('foo'));
+ $foo
+ ->expects($this->once())
+ ->method('getDisplayName')
+ ->will($this->returnValue('M. Foo'));
+ $foo
->method('getLastLogin')
->will($this->returnValue(500));
$foo
->method('getHome')
->will($this->returnValue('/home/foo'));
+ $foo
+ ->expects($this->once())
+ ->method('getBackendClassName')
+ ->will($this->returnValue('OC_User_Database'));
+ $admin = $this->getMockBuilder('\OC\User\User')
+ ->disableOriginalConstructor()->getMock();
+ $admin
+ ->expects($this->exactly(3))
+ ->method('getUID')
+ ->will($this->returnValue('admin'));
+ $admin
+ ->expects($this->once())
+ ->method('getDisplayName')
+ ->will($this->returnValue('S. Admin'));
+ $admin
+ ->expects($this->once())
+ ->method('getLastLogin')
+ ->will($this->returnValue(12));
+ $admin
+ ->expects($this->once())
+ ->method('getHome')
+ ->will($this->returnValue('/home/admin'));
+ $admin
+ ->expects($this->once())
+ ->method('getBackendClassName')
+ ->will($this->returnValue('OC_User_Dummy'));
$bar = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$bar
+ ->expects($this->exactly(3))
+ ->method('getUID')
+ ->will($this->returnValue('bar'));
+ $bar
+ ->expects($this->once())
+ ->method('getDisplayName')
+ ->will($this->returnValue('B. Ar'));
+ $bar
->method('getLastLogin')
->will($this->returnValue(3999));
$bar
->method('getHome')
->will($this->returnValue('/home/bar'));
+ $bar
+ ->expects($this->once())
+ ->method('getBackendClassName')
+ ->will($this->returnValue('OC_User_Dummy'));
$this->container['GroupManager']
->expects($this->once())
@@ -98,36 +136,36 @@ class UsersControllerTest extends \Test\TestCase {
$expectedResponse = new DataResponse(
array(
- 'status' => 'success',
- 'data' => array(
- 0 => array(
- 'name' => 'foo',
- 'displayname' => 'M. Foo',
- 'groups' => array('Users', 'Support'),
- 'subadmin' => array(),
- 'quota' => 1024,
- 'storageLocation' => '/home/foo',
- 'lastLogin' => 500
- ),
- 1 => array(
- 'name' => 'admin',
- 'displayname' => 'S. Admin',
- 'groups' => array('admins', 'Support'),
- 'subadmin' => array(),
- 'quota' => 404,
- 'storageLocation' => '/home/admin',
- 'lastLogin' => 12
- ),
- 2 => array(
- 'name' => 'bar',
- 'displayname' => 'B. Ar',
- 'groups' => array('External Users'),
- 'subadmin' => array(),
- 'quota' => 2323,
- 'storageLocation' => '/home/bar',
- 'lastLogin' => 3999
- ),
- )
+ 0 => array(
+ 'name' => 'foo',
+ 'displayname' => 'M. Foo',
+ 'groups' => array('Users', 'Support'),
+ 'subadmin' => array(),
+ 'quota' => 1024,
+ 'storageLocation' => '/home/foo',
+ 'lastLogin' => 500,
+ 'backend' => 'OC_User_Database'
+ ),
+ 1 => array(
+ 'name' => 'admin',
+ 'displayname' => 'S. Admin',
+ 'groups' => array('admins', 'Support'),
+ 'subadmin' => array(),
+ 'quota' => 404,
+ 'storageLocation' => '/home/admin',
+ 'lastLogin' => 12,
+ 'backend' => 'OC_User_Dummy'
+ ),
+ 2 => array(
+ 'name' => 'bar',
+ 'displayname' => 'B. Ar',
+ 'groups' => array('External Users'),
+ 'subadmin' => array(),
+ 'quota' => 2323,
+ 'storageLocation' => '/home/bar',
+ 'lastLogin' => 3999,
+ 'backend' => 'OC_User_Dummy'
+ ),
)
);
$response = $this->usersController->index(0, 10, 'pattern');
@@ -341,4 +379,5 @@ class UsersControllerTest extends \Test\TestCase {
$response = $this->usersController->destroy('UserToDelete');
$this->assertEquals($expectedResponse, $response);
}
+
}