Fix formatting of response

The elements are expected to be within a `service` array as per specification.
This commit is contained in:
Lukas Reschke 2016-02-25 19:05:05 +01:00
parent 3772a8acdb
commit 0e19c6a3a0
2 changed files with 62 additions and 54 deletions

View File

@ -40,7 +40,6 @@ class Provider extends \OCP\AppFramework\Controller {
*/ */
public function buildProviderList() { public function buildProviderList() {
$services = [ $services = [
'version' => 2,
'PRIVATE_DATA' => [ 'PRIVATE_DATA' => [
'version' => 1, 'version' => 1,
'endpoints' => [ 'endpoints' => [
@ -87,6 +86,9 @@ class Provider extends \OCP\AppFramework\Controller {
]; ];
} }
return new \OCP\AppFramework\Http\JSONResponse($services); return new \OCP\AppFramework\Http\JSONResponse([
'version' => 2,
'services' => $services,
]);
} }
} }

View File

@ -57,12 +57,14 @@ class OcsProviderTest extends \Test\TestCase {
$expected = new \OCP\AppFramework\Http\JSONResponse( $expected = new \OCP\AppFramework\Http\JSONResponse(
[ [
'version' => 2, 'version' => 2,
'PRIVATE_DATA' => [ 'services' => [
'version' => 1, 'PRIVATE_DATA' => [
'endpoints' => [ 'version' => 1,
'store' => '/ocs/v2.php/privatedata/setattribute', 'endpoints' => [
'read' => '/ocs/v2.php/privatedata/getattribute', 'store' => '/ocs/v2.php/privatedata/setattribute',
'delete' => '/ocs/v2.php/privatedata/deleteattribute', 'read' => '/ocs/v2.php/privatedata/getattribute',
'delete' => '/ocs/v2.php/privatedata/deleteattribute',
],
], ],
], ],
] ]
@ -91,25 +93,27 @@ class OcsProviderTest extends \Test\TestCase {
$expected = new \OCP\AppFramework\Http\JSONResponse( $expected = new \OCP\AppFramework\Http\JSONResponse(
[ [
'version' => 2, 'version' => 2,
'PRIVATE_DATA' => [ 'services' => [
'version' => 1, 'PRIVATE_DATA' => [
'endpoints' => [ 'version' => 1,
'store' => '/ocs/v2.php/privatedata/setattribute', 'endpoints' => [
'read' => '/ocs/v2.php/privatedata/getattribute', 'store' => '/ocs/v2.php/privatedata/setattribute',
'delete' => '/ocs/v2.php/privatedata/deleteattribute', 'read' => '/ocs/v2.php/privatedata/getattribute',
'delete' => '/ocs/v2.php/privatedata/deleteattribute',
],
], ],
], 'FEDERATED_SHARING' => [
'FEDERATED_SHARING' => [ 'version' => 1,
'version' => 1, 'endpoints' => [
'endpoints' => [ 'share' => '/ocs/v2.php/cloud/shares',
'share' => '/ocs/v2.php/cloud/shares', 'webdav' => '/public.php/webdav/',
'webdav' => '/public.php/webdav/', ],
], ],
], 'SHARING' => [
'SHARING' => [ 'version' => 1,
'version' => 1, 'endpoints' => [
'endpoints' => [ 'share' => '/ocs/v2.php/apps/files_sharing/api/v1/shares',
'share' => '/ocs/v2.php/apps/files_sharing/api/v1/shares', ],
], ],
], ],
] ]
@ -127,39 +131,41 @@ class OcsProviderTest extends \Test\TestCase {
$expected = new \OCP\AppFramework\Http\JSONResponse( $expected = new \OCP\AppFramework\Http\JSONResponse(
[ [
'version' => 2, 'version' => 2,
'PRIVATE_DATA' => [ 'services' => [
'version' => 1, 'PRIVATE_DATA' => [
'endpoints' => [ 'version' => 1,
'store' => '/ocs/v2.php/privatedata/setattribute', 'endpoints' => [
'read' => '/ocs/v2.php/privatedata/getattribute', 'store' => '/ocs/v2.php/privatedata/setattribute',
'delete' => '/ocs/v2.php/privatedata/deleteattribute', 'read' => '/ocs/v2.php/privatedata/getattribute',
'delete' => '/ocs/v2.php/privatedata/deleteattribute',
],
], ],
], 'FEDERATED_SHARING' => [
'FEDERATED_SHARING' => [ 'version' => 1,
'version' => 1, 'endpoints' => [
'endpoints' => [ 'share' => '/ocs/v2.php/cloud/shares',
'share' => '/ocs/v2.php/cloud/shares', 'webdav' => '/public.php/webdav/',
'webdav' => '/public.php/webdav/', ],
], ],
], 'SHARING' => [
'SHARING' => [ 'version' => 1,
'version' => 1, 'endpoints' => [
'endpoints' => [ 'share' => '/ocs/v2.php/apps/files_sharing/api/v1/shares',
'share' => '/ocs/v2.php/apps/files_sharing/api/v1/shares', ],
], ],
], 'ACTIVITY' => [
'ACTIVITY' => [ 'version' => 1,
'version' => 1, 'endpoints' => [
'endpoints' => [ 'list' => '/ocs/v2.php/cloud/activity',
'list' => '/ocs/v2.php/cloud/activity', ],
], ],
], 'PROVISIONING' => [
'PROVISIONING' => [ 'version' => 1,
'version' => 1, 'endpoints' => [
'endpoints' => [ 'user' => '/ocs/v2.php/cloud/users',
'user' => '/ocs/v2.php/cloud/users', 'groups' => '/ocs/v2.php/cloud/groups',
'groups' => '/ocs/v2.php/cloud/groups', 'apps' => '/ocs/v2.php/cloud/apps',
'apps' => '/ocs/v2.php/cloud/apps', ],
], ],
], ],
] ]