-
Notifications
You must be signed in to change notification settings - Fork 157
Expand file tree
/
Copy pathCredentialTest.php
More file actions
107 lines (91 loc) · 2.94 KB
/
CredentialTest.php
File metadata and controls
107 lines (91 loc) · 2.94 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
namespace OpenStack\Sample\Identity\v3;
use OpenStack\Common\Error\BadResponseError;
use OpenStack\Identity\v3\Models\Credential;
class CredentialTest extends TestCase
{
public function testCreate(): Credential
{
/** @var $credential \OpenStack\Identity\v3\Models\Role */
require_once $this->sampleFile('credentials/create.php', [
'{blob}' => '{"access":"181920","secret":"secretKey"}',
'{type}' => 'ec2',
]);
$this->assertInstanceOf(Credential::class, $credential);
return $credential;
}
/**
* @depends testCreate
*/
public function testList(Credential $createdCredential): void
{
$found = false;
require_once $this->sampleFile(
'credentials/list.php',
[
'/** @var $credential \OpenStack\Identity\v3\Models\Credential */' => <<<'PHP'
/** @var $credential \OpenStack\Identity\v3\Models\Credential */
if ($credential->id === $createdCredential->id) {
$found = true;
}
PHP
,
]
);
$this->assertTrue($found);
}
/**
* @depends testCreate
*/
public function testRead(Credential $createdCredential)
{
/** @var $credential \OpenStack\Identity\v3\Models\Credential */
require_once $this->sampleFile(
'credentials/read.php',
['{credentialId}' => $createdCredential->id]
);
$this->assertInstanceOf(Credential::class, $credential);
$this->assertEquals($createdCredential->blob, $credential->blob);
$this->assertEquals($createdCredential->type, $credential->type);
}
/**
* @depends testCreate
*/
public function testUpdate(Credential $createdCredential)
{
$newBlob = '{"access":"181920","secret":"newSecretKey"}';
/** @var $credential \OpenStack\Identity\v3\Models\Credential */
require_once $this->sampleFile(
'credentials/update.php',
[
'{credentialId}' => $createdCredential->id,
'{blob}' => $newBlob,
'{type}' => 'ec3',
]
);
$this->assertInstanceOf(Credential::class, $credential);
$this->assertEquals($newBlob, $credential->blob);
$this->assertEquals('ec3', $credential->type);
}
/**
* @depends testCreate
*/
public function testDelete(Credential $createdCredential): void
{
require_once $this->sampleFile(
'credentials/delete.php',
[
'{credentialId}' => $createdCredential->id,
]
);
$found = false;
foreach ($this->getService()->listCredentials() as $credential) {
if ($credential->id === $createdCredential->id) {
$found = true;
}
}
$this->assertFalse($found);
$this->expectException(BadResponseError::class);
$createdCredential->retrieve();
}
}