|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Server module for HiPanel |
|
4
|
|
|
* |
|
5
|
|
|
* @link https://github.com/hiqdev/hipanel-module-server |
|
6
|
|
|
* @package hipanel-module-server |
|
7
|
|
|
* @license BSD-3-Clause |
|
8
|
|
|
* @copyright Copyright (c) 2015-2019, HiQDev (http://hiqdev.com/) |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace hipanel\modules\server\tests\acceptance\admin; |
|
12
|
|
|
|
|
13
|
|
|
use Codeception\Example; |
|
|
|
|
|
|
14
|
|
|
use hipanel\helpers\Url; |
|
15
|
|
|
use hipanel\modules\server\tests\_support\Page\Hub\AssignHubs; |
|
16
|
|
|
use hipanel\modules\server\tests\_support\Page\Hub\Create; |
|
17
|
|
|
use hipanel\modules\server\tests\_support\Page\Hub\Options; |
|
18
|
|
|
use hipanel\modules\server\tests\_support\Page\Hub\Update; |
|
19
|
|
|
use hipanel\modules\server\tests\_support\Page\Hub\View; |
|
20
|
|
|
use hipanel\tests\_support\Page\IndexPage; |
|
21
|
|
|
use hipanel\tests\_support\Page\Widget\Input\Input; |
|
22
|
|
|
use hipanel\tests\_support\Step\Acceptance\Admin; |
|
23
|
|
|
|
|
24
|
|
|
class HubCest |
|
25
|
|
|
{ |
|
26
|
|
|
/** @var IndexPage */ |
|
27
|
|
|
private $indexPage; |
|
28
|
|
|
|
|
29
|
|
|
/** @var View */ |
|
30
|
|
|
private $viewPage; |
|
31
|
|
|
|
|
32
|
|
|
/** @var Example */ |
|
33
|
|
|
private $hubData; |
|
34
|
|
|
|
|
35
|
|
|
public function _before(Admin $I) |
|
36
|
|
|
{ |
|
37
|
|
|
$this->indexPage = new IndexPage($I); |
|
38
|
|
|
$this->viewPage = new View($I); |
|
39
|
|
|
|
|
40
|
|
|
$this->hubData = $this->createProvider()[0]; |
|
|
|
|
|
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @dataProvider createProvider |
|
45
|
|
|
* @param Admin $I |
|
46
|
|
|
* @param Example $data |
|
47
|
|
|
* @throws \Exception |
|
48
|
|
|
*/ |
|
49
|
|
|
public function ensureICanCreateHub(Admin $I, Example $data): void |
|
50
|
|
|
{ |
|
51
|
|
|
$createPage = new Create($I); |
|
52
|
|
|
$this->hubData = $data; |
|
53
|
|
|
$I->needPage(Url::to(['@hub/create'])); |
|
54
|
|
|
$createPage->fillForm($data) |
|
55
|
|
|
->hasNotErrors() |
|
56
|
|
|
->submitForm(); |
|
57
|
|
|
$I->closeNotification('Switch was created'); |
|
58
|
|
|
$I->seeInCurrentUrl(Url::to(['@hub/view'])); |
|
59
|
|
|
$this->viewPage->check($data); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @dataProvider assignHubsProvider |
|
64
|
|
|
* @param Admin $I |
|
65
|
|
|
* @param Example $data |
|
66
|
|
|
* @throws \Codeception\Exception\ModuleException |
|
67
|
|
|
*/ |
|
68
|
|
|
public function ensureICanAssignHubs(Admin $I, Example $data): void |
|
69
|
|
|
{ |
|
70
|
|
|
$assignPage = new AssignHubs($I); |
|
71
|
|
|
|
|
72
|
|
|
$I->needPage(Url::to(['@hub/index'])); |
|
73
|
|
|
|
|
74
|
|
|
$this->indexPage->filterBy( |
|
75
|
|
|
Input::asTableFilter($I, 'Name'), $this->hubData['name'] |
|
76
|
|
|
); |
|
77
|
|
|
$this->indexPage->openRowMenuByColumnValue('Name', $this->hubData['name']); |
|
|
|
|
|
|
78
|
|
|
$this->indexPage->chooseRowMenuOption('Switches'); |
|
79
|
|
|
|
|
80
|
|
|
$assignPage->fillForm($data) |
|
81
|
|
|
->hasNotErrors() |
|
82
|
|
|
->submitForm(); |
|
83
|
|
|
$I->closeNotification('Switches have been edited'); |
|
84
|
|
|
$I->seeInCurrentUrl(Url::to(['@hub/view'])); |
|
85
|
|
|
$this->viewPage->check($data); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* @dataProvider optionsDataProvider |
|
90
|
|
|
* @param Admin $I |
|
91
|
|
|
* @param Example $data |
|
92
|
|
|
* @throws \Codeception\Exception\ModuleException |
|
93
|
|
|
*/ |
|
94
|
|
|
public function ensureICanSetHubOptions(Admin $I, Example $data): void |
|
95
|
|
|
{ |
|
96
|
|
|
$optionsPage = new Options($I); |
|
97
|
|
|
|
|
98
|
|
|
$I->needPage(Url::to(['@hub/index'])); |
|
99
|
|
|
|
|
100
|
|
|
$this->indexPage->filterBy( |
|
101
|
|
|
Input::asTableFilter($I, 'Name'), $this->hubData['name'] |
|
102
|
|
|
); |
|
103
|
|
|
$this->indexPage->openRowMenuByColumnValue('Name', $this->hubData['name']); |
|
104
|
|
|
$this->indexPage->chooseRowMenuOption('Options'); |
|
105
|
|
|
|
|
106
|
|
|
$optionsPage->fillForm($data) |
|
107
|
|
|
->hasNotErrors() |
|
108
|
|
|
->submitForm(); |
|
109
|
|
|
$I->closeNotification('Options was updated'); |
|
110
|
|
|
$I->seeInCurrentUrl(Url::to(['@hub/view'])); |
|
111
|
|
|
$this->viewPage->check($data); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @param Admin $I |
|
116
|
|
|
* @throws \Codeception\Exception\ModuleException |
|
117
|
|
|
*/ |
|
118
|
|
|
public function ensureICanUpdateHub(Admin $I): void |
|
119
|
|
|
{ |
|
120
|
|
|
$updatePage = new Update($I); |
|
121
|
|
|
|
|
122
|
|
|
$I->needPage(Url::to(['@hub/index'])); |
|
123
|
|
|
$this->indexPage->filterBy( |
|
124
|
|
|
Input::asTableFilter($I, 'Name'), $this->hubData['name'] |
|
125
|
|
|
); |
|
126
|
|
|
$this->indexPage->openRowMenuByColumnValue('Name', $this->hubData['name']); |
|
127
|
|
|
$this->indexPage->chooseRowMenuOption('Update'); |
|
128
|
|
|
$this->updateHubData(); |
|
129
|
|
|
|
|
130
|
|
|
$updatePage->fillForm($this->hubData) |
|
131
|
|
|
->hasNotErrors() |
|
132
|
|
|
->submitForm(); |
|
133
|
|
|
$I->closeNotification('Switch was updated'); |
|
134
|
|
|
$I->seeInCurrentUrl(Url::to(['@hub/view'])); |
|
135
|
|
|
$this->viewPage->check($this->hubData); |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* @dataProvider createProvider |
|
140
|
|
|
* @param Admin $I |
|
141
|
|
|
* @throws \Codeception\Exception\ModuleException |
|
142
|
|
|
*/ |
|
143
|
|
|
public function ensureICanDeleteHub(Admin $I): void |
|
144
|
|
|
{ |
|
145
|
|
|
$viewPage = new View($I); |
|
146
|
|
|
|
|
147
|
|
|
$I->needPage(Url::to(['@hub/index'])); |
|
148
|
|
|
$this->indexPage->filterBy( |
|
149
|
|
|
Input::asTableFilter($I, 'Name'), $this->hubData['name'] |
|
150
|
|
|
); |
|
151
|
|
|
$this->indexPage->openRowMenuByColumnValue('Name', $this->hubData['name']); |
|
152
|
|
|
$this->indexPage->chooseRowMenuOption('View'); |
|
153
|
|
|
$viewPage->clickAction('Delete'); |
|
154
|
|
|
$I->acceptPopup(); |
|
155
|
|
|
$I->closeNotification('Switches have been deleted'); |
|
156
|
|
|
} |
|
157
|
|
|
|
|
158
|
|
|
/** |
|
159
|
|
|
* @return array |
|
160
|
|
|
*/ |
|
161
|
|
|
protected function createProvider(): array |
|
162
|
|
|
{ |
|
163
|
|
|
return [ |
|
164
|
|
|
[ |
|
165
|
|
|
'name' => 'test_switch', |
|
166
|
|
|
'type_id' => 'Switch', |
|
167
|
|
|
'inn' => 'test_inn', |
|
168
|
|
|
'model' => 'test_model', |
|
169
|
|
|
'note' => 'test_note', |
|
170
|
|
|
], |
|
171
|
|
|
]; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
protected function updateHubData(): void |
|
175
|
|
|
{ |
|
176
|
|
|
foreach ($this->hubData as $field => $value) { |
|
177
|
|
|
if (!in_array($field, ['type_id', 'ip', 'mac', 'name'])) { |
|
178
|
|
|
$this->hubData[$field] = $value . '_updated'; |
|
179
|
|
|
} |
|
180
|
|
|
} |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
/** |
|
184
|
|
|
* @return array |
|
185
|
|
|
*/ |
|
186
|
|
|
protected function assignHubsProvider(): array |
|
187
|
|
|
{ |
|
188
|
|
|
return [ |
|
189
|
|
|
[ |
|
190
|
|
|
'net_id' => 'TEST-SW-05', |
|
191
|
|
|
'net_port' => 'port5', |
|
192
|
|
|
'kvm_id' => 'TEST-SW-04', |
|
193
|
|
|
'kvm_port' => 'port4', |
|
194
|
|
|
'pdu_id' => 'TEST-SW-06', |
|
195
|
|
|
'pdu_port' => 'port6', |
|
196
|
|
|
'rack_id' => 'TEST-SW-02', |
|
197
|
|
|
'rack_port' => 'port2', |
|
198
|
|
|
'console_id' => null, |
|
199
|
|
|
'console_port' => null, |
|
200
|
|
|
'location_id' => 'TEST-SW-03', |
|
201
|
|
|
'location_port' => '', |
|
202
|
|
|
], |
|
203
|
|
|
]; |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
/** |
|
207
|
|
|
* @return array |
|
208
|
|
|
*/ |
|
209
|
|
|
protected function optionsDataProvider(): array |
|
210
|
|
|
{ |
|
211
|
|
|
return [ |
|
212
|
|
|
[ |
|
213
|
|
|
'inn' => 'test_inn_option', |
|
214
|
|
|
'model' => 'test_model_option', |
|
215
|
|
|
'ports_num' => 42, |
|
216
|
|
|
'community' => 'hiqdev', |
|
217
|
|
|
'nic_media' => '100 Gbit/s', |
|
218
|
|
|
'digit_capacity_id' => 'vds2', |
|
219
|
|
|
'base_port_no' => 21, |
|
220
|
|
|
'oob_key' => 'gnu/gpl', |
|
221
|
|
|
], |
|
222
|
|
|
]; |
|
223
|
|
|
} |
|
224
|
|
|
} |
|
225
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths