-
Notifications
You must be signed in to change notification settings - Fork 156
Expand file tree
/
Copy pathOpenStackTest.php
More file actions
147 lines (120 loc) · 5.02 KB
/
Copy pathOpenStackTest.php
File metadata and controls
147 lines (120 loc) · 5.02 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
namespace OpenStack\Test;
use GuzzleHttp\ClientInterface;
use OpenStack\Common\Service\Builder;
use OpenStack\Identity\v3\Api;
use OpenStack\OpenStack;
use OpenStack\Compute\v2\Service as ComputeServiceV2;
use OpenStack\Identity\v2\Service as IdentityServiceV2;
use OpenStack\Identity\v3\Service as IdentityServiceV3;
use OpenStack\Networking\v2\Service as NetworkingServiceV2;
use OpenStack\Networking\v2\Extensions\Layer3\Service as NetworkingServiceV2ExtLayer3;
use OpenStack\Networking\v2\Extensions\SecurityGroups\Service as NetworkingServiceV2ExtSecGroup;
use OpenStack\ObjectStore\v1\Service as ObjectStoreServiceV1;
use OpenStack\BlockStorage\v2\Service as BlockStorageServiceV2;
use OpenStack\BlockStorage\v3\Service as BlockStorageServiceV3;
use OpenStack\Images\v2\Service as ImageServiceV2;
use OpenStack\Metric\v1\Gnocchi\Service as MetricGnocchiV1;
class OpenStackTest extends TestCase
{
private $builder;
/** @var OpenStack */
private $openstack;
public function setUp(): void
{
$this->builder = $this->prophesize(Builder::class);
$this->openstack = new OpenStack(['authUrl' => ''], $this->builder->reveal());
}
public function test_it_supports_compute_v2()
{
$this->builder
->createService('Compute\\v2', ['catalogName' => 'nova', 'catalogType' => 'compute'])
->shouldBeCalled()
->willReturn($this->service(ComputeServiceV2::class));
$this->openstack->computeV2();
}
public function test_it_supports_identity_v2()
{
$this->builder
->createService('Identity\\v2', ['catalogName' => 'keystone', 'catalogType' => 'identity'])
->shouldBeCalled()
->willReturn($this->service(IdentityServiceV2::class));
$this->openstack->identityV2();
}
public function test_it_supports_identity_v3()
{
$this->builder
->createService('Identity\\v3', ['catalogName' => 'keystone', 'catalogType' => 'identity'])
->shouldBeCalled()
->willReturn($this->service(IdentityServiceV3::class));
$this->openstack->identityV3();
}
public function test_it_supports_networking_v2()
{
$this->builder
->createService('Networking\\v2', ['catalogName' => 'neutron', 'catalogType' => 'network'])
->shouldBeCalled()
->willReturn($this->service(NetworkingServiceV2::class));
$this->openstack->networkingV2();
}
public function test_it_supports_networking_v2_ext_layer3()
{
$this->builder
->createService('Networking\\v2\\Extensions\\Layer3', ['catalogName' => 'neutron', 'catalogType' => 'network'])
->shouldBeCalled()
->willReturn($this->service(NetworkingServiceV2ExtLayer3::class));
$this->openstack->networkingV2ExtLayer3();
}
public function test_it_supports_networking_v2_ext_security_group()
{
$this->builder
->createService('Networking\\v2\\Extensions\\SecurityGroups', ['catalogName' => 'neutron', 'catalogType' => 'network'])
->shouldBeCalled()
->willReturn($this->service(NetworkingServiceV2ExtSecGroup::class));
$this->openstack->networkingV2ExtSecGroups();
}
public function test_it_supports_object_store_v1()
{
$this->builder
->createService('ObjectStore\\v1', ['catalogName' => 'swift', 'catalogType' => 'object-store'])
->shouldBeCalled()
->willReturn($this->service(ObjectStoreServiceV1::class));
$this->openstack->objectStoreV1();
}
public function test_it_supports_block_storage_v2()
{
$this->builder
->createService('BlockStorage\\v2', ['catalogName' => 'cinderv2', 'catalogType' => 'volumev2'])
->shouldBeCalled()
->willReturn($this->service(BlockStorageServiceV2::class));
$this->openstack->blockStorageV2();
}
public function test_it_supports_block_storage_v3()
{
$this->builder
->createService('BlockStorage\\v3', ['catalogName' => 'cinderv3', 'catalogType' => 'volumev3'])
->shouldBeCalled()
->willReturn($this->service(BlockStorageServiceV3::class));
$this->openstack->blockStorageV3();
}
public function test_it_supports_images_v2()
{
$this->builder
->createService('Images\\v2', ['catalogName' => 'glance', 'catalogType' => 'image'])
->shouldBeCalled()
->willReturn($this->service(ImageServiceV2::class));
$this->openstack->imagesV2();
}
public function test_it_support_metrics_gnocchi_v1()
{
$this->builder
->createService('Metric\\v1\\Gnocchi', ['catalogName' => 'gnocchi', 'catalogType' => 'metric'])
->shouldBeCalled()
->willReturn($this->service(MetricGnocchiV1::class));
$this->openstack->metricGnocchiV1();
}
private function service($class)
{
return new $class($this->prophesize(ClientInterface::class)->reveal(), new Api());
}
}