blob: 1950f7b39135ba31ec89dade921818354e57efa1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
<?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;
/**
* Class OcsCreateUserCest
*
* A sample test in cest format to compare it to Gherkin scenarios
*
* You would normally avoid the duplication seen in the methods by placing common elements in Steps
* or the Actor class
*/
class OcsCreateUserCest {
private $apiUrl;
private $userId = 'BlueDragon';
public function _before(ApiTester $I) {
$this->apiUrl = '/ocs/v1.php/cloud';
}
public function _after(ApiTester $I) {
}
public function createUser(ApiTester $I, \Codeception\Scenario $scenario) {
//$scenario->skip('ownCloud master is broken');
$I->wantTo('create a user via the provisioning API');
$I->amHttpAuthenticated('admin', 'admin');
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
$I->sendPOST(
$this->apiUrl . '/users',
['userid' => $this->userId, 'password' => 'test' . $this->userId]
);
$I->seeResponseCodeIs(200);
$I->seeResponseIsXml();
$I->seeXmlResponseIncludes(
XmlUtils::toXml(
['status' => 'ok']
)
);
}
public function checkUserExists(ApiTester $I, \Codeception\Scenario $scenario) {
//$scenario->skip('ownCloud master is broken');
$I->wantTo('make sure the user exists');
$I->amHttpAuthenticated('admin', 'admin');
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
$I->sendGET($this->apiUrl . '/users/' . $this->userId);
$I->seeResponseCodeIs(200);
$I->seeResponseIsXml();
$I->seeXmlResponseIncludes(
XmlUtils::toXml(
['status' => 'ok']
)
);
}
public function deleteUser(ApiTester $I, \Codeception\Scenario $scenario) {
//$scenario->skip('ownCloud master is broken');
$I->wantTo('delete the user');
$I->amHttpAuthenticated('admin', 'admin');
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
$I->sendDELETE($this->apiUrl . '/users/' . $this->userId);
$I->seeResponseCodeIs(200);
$I->seeResponseIsXml();
$I->seeXmlResponseIncludes(
XmlUtils::toXml(
['status' => 'ok']
)
);
}
}
|