Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/gallery.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests/api
diff options
context:
space:
mode:
authorOlivier Paroz <github@oparoz.com>2015-08-16 21:07:45 +0300
committerOlivier Paroz <github@oparoz.com>2015-08-16 21:07:45 +0300
commitc4285d5a438361f6255dd6e8d9b2438feb464029 (patch)
tree6794d7ba555d3498fad2859fdfbe821f3efa596c /tests/api
parent5ffaa3b439c68a04587f6219b340dfc97e065a29 (diff)
Introduce an API
Diffstat (limited to 'tests/api')
-rw-r--r--tests/api/CheckTestUsersCept.php32
-rw-r--r--tests/api/CheckTestUsersCest.php64
-rw-r--r--tests/api/GetFilesCest.php98
-rw-r--r--tests/api/OcsCreateUserCept.php (renamed from tests/api/CreateUserCept.php)0
4 files changed, 162 insertions, 32 deletions
diff --git a/tests/api/CheckTestUsersCept.php b/tests/api/CheckTestUsersCept.php
deleted file mode 100644
index e1b1988e..00000000
--- a/tests/api/CheckTestUsersCept.php
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-/**
- * ownCloud - gallery
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Olivier Paroz <owncloud@interfasys.ch>
- *
- * @copyright Olivier Paroz 2015
- */
-
-use Codeception\Util\Xml as XmlUtils;
-
-$I = new ApiTester($scenario);
-$I->wantTo('make sure my test users have been created');
-$baseUrl = '/ocs/v1.php/cloud';
-$I->amHttpAuthenticated('admin', 'admin');
-$I->sendGET($baseUrl . '/users/tester');
-$I->seeResponseCodeIs(200);
-$I->seeResponseIsXml();
-$I->seeXmlResponseIncludes(
- XmlUtils::toXml(
- ['status' => 'ok']
-));
-$I->sendGET($baseUrl . '/users/sharer');
-$I->seeResponseCodeIs(200);
-$I->seeResponseIsXml();
-$I->seeXmlResponseIncludes(
- XmlUtils::toXml(
- ['status' => 'ok']
-));
diff --git a/tests/api/CheckTestUsersCest.php b/tests/api/CheckTestUsersCest.php
new file mode 100644
index 00000000..f3212834
--- /dev/null
+++ b/tests/api/CheckTestUsersCest.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * ownCloud - gallery
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Olivier Paroz <owncloud@interfasys.ch>
+ *
+ * @copyright Olivier Paroz 2015
+ */
+
+use Helper\DataSetup;
+use Codeception\Util\Xml as XmlUtils;
+
+/**
+ * Class CheckTestUsersCest
+ */
+class CheckTestUsersCest {
+
+ private $setupData;
+ private $userId;
+ private $sharerUserId;
+ private $baseUrl = '/ocs/v1.php/cloud';
+
+
+ /**
+ * Injects objects we need
+ *
+ * @param DataSetup $setupData
+ */
+ protected function _inject(DataSetup $setupData) {
+ $this->setupData = $setupData;
+ }
+
+ public function _before(ApiTester $I) {
+ $this->userId = $this->setupData->userId;
+ $this->sharerUserId = $this->setupData->sharerUserId;
+ }
+
+ public function _after(ApiTester $I) {
+ }
+
+ public function testTestUsersCreation(ApiTester $I) {
+ $I->wantTo('make sure my test users have been created');
+ $I->amHttpAuthenticated('admin', 'admin');
+ $I->sendGET($this->baseUrl . '/users/' . $this->userId);
+ $I->seeResponseCodeIs(200);
+ $I->seeResponseIsXml();
+ $I->seeXmlResponseIncludes(
+ XmlUtils::toXml(
+ ['status' => 'ok']
+ )
+ );
+ $I->sendGET($this->baseUrl . '/users/' . $this->sharerUserId);
+ $I->seeResponseCodeIs(200);
+ $I->seeResponseIsXml();
+ $I->seeXmlResponseIncludes(
+ XmlUtils::toXml(
+ ['status' => 'ok']
+ )
+ );
+ }
+}
diff --git a/tests/api/GetFilesCest.php b/tests/api/GetFilesCest.php
new file mode 100644
index 00000000..23e79249
--- /dev/null
+++ b/tests/api/GetFilesCest.php
@@ -0,0 +1,98 @@
+<?php
+/**
+ * ownCloud - gallery
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Olivier Paroz <owncloud@interfasys.ch>
+ *
+ * @copyright Olivier Paroz 2015
+ */
+
+use Page\Gallery as GalleryApp;
+use Helper\DataSetup;
+
+/**
+ * Class GetFilesCest
+ *
+ * @todo Match the original structure
+ */
+class GetFilesCest {
+
+ private $setupData;
+ private $userId;
+ private $password;
+ private $filesApi;
+ private $params = [
+ 'mediatypes' => 'image/png;image/jpeg;image/gif;application/postscript'
+ ];
+
+ /**
+ * Injects objects we need
+ *
+ * @param DataSetup $setupData
+ */
+ protected function _inject(DataSetup $setupData) {
+ $this->setupData = $setupData;
+ }
+
+ public function _before(ApiTester $I) {
+ $this->filesApi = GalleryApp::$URL . 'api/files/list';
+ $this->userId = $this->setupData->userId;
+ $this->password = $this->setupData->userPassword;
+ }
+
+ public function _after(ApiTester $I) {
+ }
+
+ public function unauthorizedAccess(ApiTester $I) {
+ $I->am('an app');
+ $I->wantTo('connect to the Files API without credentials');
+ $I->sendGET($this->filesApi, $this->params);
+ $I->seeResponseCodeIs(401);
+ $I->seeResponseIsJson();
+ }
+
+ public function getStandardList(ApiTester $I) {
+ $I->am('an app');
+ $I->wantTo(
+ 'get the list of available media files'
+ );
+
+ $I->amHttpAuthenticated($this->userId, $this->password);
+ $I->sendGET($this->filesApi, $this->params);
+ $I->seeResponseCodeIs(200);
+ $I->seeResponseIsJson();
+
+ $I->seeResponseJsonMatchesXpath('//files');
+ $I->seeResponseJsonMatchesXpath('//albuminfo');
+ $I->seeResponseJsonMatchesXpath('//locationhaschanged');
+
+
+ $I->seeResponseJsonMatchesXpath('//files/path');
+ $I->dontSeeResponseContainsJson(['path' => 'folder2/testimagelarge.svg']);
+
+ $I->seeResponseJsonMatchesXpath('//albuminfo/path', '');
+ }
+
+ /**
+ * @after getStandardList
+ *
+ * @param ApiTester $I
+ */
+ public function getListWithNativeSvgEnabled(ApiTester $I) {
+ $mediaTypes = $this->params['mediatypes'];
+ $params = ['mediatypes' => $mediaTypes . ';image/svg+xml'];
+
+ $I->am('an app');
+ $I->wantTo('get the list of available media files which should include SVGs');
+
+ $I->amHttpAuthenticated($this->userId, $this->password);
+ $I->sendGET($this->filesApi, $params);
+ $I->seeResponseCodeIs(200);
+ $I->seeResponseIsJson();
+ $I->seeResponseContainsJson(['path' => 'folder2/testimagelarge.svg']);
+ }
+
+}
diff --git a/tests/api/CreateUserCept.php b/tests/api/OcsCreateUserCept.php
index 96983eae..96983eae 100644
--- a/tests/api/CreateUserCept.php
+++ b/tests/api/OcsCreateUserCept.php