diff options
author | Olivier Paroz <github@oparoz.com> | 2015-08-17 05:22:57 +0300 |
---|---|---|
committer | Olivier Paroz <github@oparoz.com> | 2015-08-17 05:22:57 +0300 |
commit | 083aa7ecfa671ea054a0a1bc84c93b185f56d1c6 (patch) | |
tree | 35cbe7835922a3ccbdd36f4f4b1042f9750fabba /tests/api | |
parent | 82443c07147301ebf015bbb948935b7518ff487d (diff) |
Add Config API
Diffstat (limited to 'tests/api')
-rw-r--r-- | tests/api/GetConfigCest.php | 111 | ||||
-rw-r--r-- | tests/api/GetFilesCest.php | 26 |
2 files changed, 123 insertions, 14 deletions
diff --git a/tests/api/GetConfigCest.php b/tests/api/GetConfigCest.php new file mode 100644 index 00000000..41647060 --- /dev/null +++ b/tests/api/GetConfigCest.php @@ -0,0 +1,111 @@ +<?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; + +/** + * Class GetConfigCest + * + * @todo Inject config items and compare the result + */ +class GetConfigCest { + + private $userId; + private $password; + private $configApi; + + public function _before(ApiTester $I) { + $this->configApi = GalleryApp::$URL . 'api/config'; + list ($this->userId, $this->password) = $I->getUserCredentials(); + } + + public function _after(ApiTester $I) { + } + + public function unauthorizedAccess(ApiTester $I) { + $I->am('an app'); + $I->wantTo('connect to the Config API without credentials'); + $I->sendGET($this->configApi); + $I->seeResponseCodeIs(401); + $I->seeResponseIsJson(); + } + + /** + * Retrieves the configuration + * + * @todo figure out why seeResponseJsonMatchesXpath returns + * [DOMException] Invalid Character Error + * + * @param ApiTester $I + */ + public function getConfig(ApiTester $I) { + $I->am('an app'); + $I->wantTo('get the current Gallery configuration'); + + $I->amHttpAuthenticated($this->userId, $this->password); + $params = ['extramediatypes' => false]; + $I->sendGET($this->configApi, $params); + $I->seeResponseCodeIs(200); + $I->seeResponseIsJson(); + + + $I->seeResponseContainsJson(['features' => []]); + + /** + * TODO Replace with JSONPath once the library is fixed + */ + $I->seeResponseContainsJson( + [ + "mediatypes" => [ + "image/png" => "/core/img/filetypes/image.png", + "image/jpeg" => "/core/img/filetypes/image.png", + "image/gif" => "/core/img/filetypes/image.png", + "application/postscript" => "/core/img/filetypes/image-vector.png" + ] + ] + ); + } + + /** + * @depends getConfig + * + * @param ApiTester $I + * @param $scenario + */ + public function getConfigWithExtraMediaTypes(ApiTester $I, \Codeception\Scenario $scenario) { + $I->am('an app'); + $I->wantTo('get the current Gallery configuration which should include extra media types'); + + $I->amHttpAuthenticated($this->userId, $this->password); + $params = ['extramediatypes' => true]; + $I->sendGET($this->configApi, $params); + $I->seeResponseCodeIs(200); + $I->seeResponseIsJson(); + + /** + * TODO Replace with JSONPath once the library is fixed + */ + $I->seeResponseContainsJson( + [ + "mediatypes" => [ + "image/png" => "/core/img/filetypes/image.png", + "image/jpeg" => "/core/img/filetypes/image.png", + "image/gif" => "/core/img/filetypes/image.png", + "application/postscript" => "/core/img/filetypes/image-vector.png", + "application/font-sfnt" => "/core/img/filetypes/font.png", + "application/x-font" => "/core/img/filetypes/font.png" + ] + ] + ); + } + +} diff --git a/tests/api/GetFilesCest.php b/tests/api/GetFilesCest.php index 23e79249..5c69409e 100644 --- a/tests/api/GetFilesCest.php +++ b/tests/api/GetFilesCest.php @@ -11,7 +11,6 @@ */ use Page\Gallery as GalleryApp; -use Helper\DataSetup; /** * Class GetFilesCest @@ -20,27 +19,26 @@ use Helper\DataSetup; */ class GetFilesCest { - private $setupData; private $userId; private $password; private $filesApi; - private $params = [ - 'mediatypes' => 'image/png;image/jpeg;image/gif;application/postscript' - ]; + private $params; /** - * Injects objects we need + * Sets up the environment for this series of tests * - * @param DataSetup $setupData + * We use custom methods defined in _support/Helper/Api + * If these are re-usable across suites, they may move to _support/Step + * + * @param ApiTester $I */ - 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; + list ($this->userId, $this->password) = $I->getUserCredentials(); + list($mediaTypes) = $I->getMediaTypes(); + $this->params = [ + 'mediatypes' => implode(';', $mediaTypes) + ]; } public function _after(ApiTester $I) { @@ -77,7 +75,7 @@ class GetFilesCest { } /** - * @after getStandardList + * @depends getStandardList * * @param ApiTester $I */ |