-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathoverview-test.js
250 lines (233 loc) · 9.06 KB
/
overview-test.js
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { module, test } from 'qunit';
import { setupRenderingTest } from 'vault/tests/helpers';
import { render } from '@ember/test-helpers';
import { hbs } from 'ember-cli-htmlbars';
import { setupMirage } from 'ember-cli-mirage/test-support';
import { DASHBOARD } from 'vault/tests/helpers/components/dashboard/dashboard-selectors';
module('Integration | Component | dashboard/overview', function (hooks) {
setupRenderingTest(hooks);
setupMirage(hooks);
hooks.beforeEach(function () {
this.store = this.owner.lookup('service:store');
this.permissions = this.owner.lookup('service:permissions');
this.version = this.owner.lookup('service:version');
this.version.version = '1.13.1+ent';
this.version.type = 'enterprise';
this.isRootNamespace = true;
this.replication = {
dr: {
clusterId: '123',
state: 'running',
},
performance: {
clusterId: 'abc-1',
state: 'running',
isPrimary: true,
},
};
this.store.pushPayload('secret-engine', {
modelName: 'secret-engine',
data: {
accessor: 'kv_f3400dee',
path: 'kv-test/',
type: 'kv',
},
});
this.store.pushPayload('secret-engine', {
modelName: 'secret-engine',
data: {
accessor: 'kv_f3300dee',
path: 'kv-1/',
type: 'kv',
},
});
this.secretsEngines = this.store.peekAll('secret-engine', {});
this.vaultConfiguration = {
api_addr: 'http://127.0.0.1:8200',
default_lease_ttl: 0,
max_lease_ttl: 0,
listeners: [
{
config: {
address: '127.0.0.1:8200',
tls_disable: 1,
},
type: 'tcp',
},
],
};
this.refreshModel = () => {};
this.renderComponent = async () => {
return await render(
hbs`
<Dashboard::Overview
@secretsEngines={{this.secretsEngines}}
@vaultConfiguration={{this.vaultConfiguration}}
@replication={{this.replication}}
@version={{this.version}}
@isRootNamespace={{this.isRootNamespace}}
@refreshModel={{this.refreshModel}}
@replicationUpdatedAt={{this.replicationUpdatedAt}}
/>
`
);
};
});
test('it should show dashboard empty states in root namespace', async function (assert) {
this.version.version = '1.13.1';
this.secretsEngines = null;
this.replication = null;
this.vaultConfiguration = null;
await this.renderComponent();
assert.dom(DASHBOARD.cardHeader('Vault version')).exists();
assert.dom(DASHBOARD.cardName('secrets-engines')).exists();
assert.dom(DASHBOARD.emptyState('secrets-engines')).exists();
assert.dom(DASHBOARD.cardName('learn-more')).exists();
assert.dom(DASHBOARD.cardName('quick-actions')).exists();
assert.dom(DASHBOARD.emptyState('quick-actions')).exists();
assert.dom(DASHBOARD.cardName('configuration-details')).doesNotExist();
assert.dom(DASHBOARD.cardName('replication')).doesNotExist();
assert.dom(DASHBOARD.cardName('client-count')).doesNotExist();
});
module('client count and replication card', function () {
test('it should hide cards on community in root namespace', async function (assert) {
this.version.version = '1.13.1';
this.version.type = 'community';
this.server.get(
'sys/internal/counters/activity',
() => new Error('uh oh! a request was made to sys/internal/counters/activity')
);
await this.renderComponent();
assert.dom(DASHBOARD.cardHeader('Vault version')).exists();
assert.dom(DASHBOARD.cardName('secrets-engines')).exists();
assert.dom(DASHBOARD.cardName('learn-more')).exists();
assert.dom(DASHBOARD.cardName('quick-actions')).exists();
assert.dom(DASHBOARD.cardName('configuration-details')).exists();
assert.dom(DASHBOARD.cardName('replication')).doesNotExist();
assert.dom(DASHBOARD.cardName('client-count')).doesNotExist();
});
test('it should hide cards on enterprise if permission but not in root namespace', async function (assert) {
this.permissions.exactPaths = {
'sys/internal/counters/activity': {
capabilities: ['read'],
},
'sys/replication/status': {
capabilities: ['read'],
},
};
this.isRootNamespace = false;
await this.renderComponent();
assert.dom(DASHBOARD.cardName('client-count')).doesNotExist();
assert.dom(DASHBOARD.cardName('replication')).doesNotExist();
});
test('it should show cards on enterprise if has permission and in root namespace', async function (assert) {
this.permissions.exactPaths = {
'sys/internal/counters/activity': {
capabilities: ['read'],
},
'sys/replication/status': {
capabilities: ['read'],
},
};
await this.renderComponent();
assert.dom(DASHBOARD.cardHeader('Vault version')).exists();
assert.dom(DASHBOARD.cardName('secrets-engines')).exists();
assert.dom(DASHBOARD.cardName('learn-more')).exists();
assert.dom(DASHBOARD.cardName('quick-actions')).exists();
assert.dom(DASHBOARD.cardName('configuration-details')).exists();
assert.dom(DASHBOARD.cardName('client-count')).exists();
assert.dom(DASHBOARD.cardName('replication')).exists();
});
test('it should hide cards on enterprise in root namespace but no permission', async function (assert) {
await this.renderComponent();
assert.dom(DASHBOARD.cardName('client-count')).doesNotExist();
assert.dom(DASHBOARD.cardName('replication')).doesNotExist();
});
test('it should hide cards on enterprise if no permission and not in root namespace', async function (assert) {
this.isRootNamespace = false;
await this.renderComponent();
assert.dom(DASHBOARD.cardName('client-count')).doesNotExist();
assert.dom(DASHBOARD.cardName('replication')).doesNotExist();
});
test('it should hide client count on enterprise in root namespace if no activity permission', async function (assert) {
this.permissions.exactPaths = {
'sys/internal/counters/activity': {
capabilities: ['deny'],
},
'sys/replication/status': {
capabilities: ['read'],
},
};
await this.renderComponent();
assert.dom(DASHBOARD.cardName('client-count')).doesNotExist();
assert.dom(DASHBOARD.cardName('replication')).exists();
});
test('it should hide replication on enterprise in root namespace if no replication status permission', async function (assert) {
this.permissions.exactPaths = {
'sys/internal/counters/activity': {
capabilities: ['read'],
},
'sys/replication/status': {
capabilities: ['deny'],
},
};
await this.renderComponent();
assert.dom(DASHBOARD.cardName('client-count')).exists();
assert.dom(DASHBOARD.cardName('replication')).doesNotExist();
});
test('it should hide replication on enterprise if has permission and in root namespace but is empty', async function (assert) {
this.permissions.exactPaths = {
'sys/internal/counters/activity': {
capabilities: ['read'],
},
'sys/replication/status': {
capabilities: ['read'],
},
};
this.replication = {};
await this.renderComponent();
assert.dom(DASHBOARD.cardName('client-count')).exists();
assert.dom(DASHBOARD.cardName('replication')).doesNotExist();
});
});
module('learn more card', function () {
test('shows the learn more card on community', async function (assert) {
this.version.version = '1.13.1';
this.version.type = 'community';
await this.renderComponent();
assert.dom('[data-test-learn-more-title]').hasText('Learn more');
assert
.dom('[data-test-learn-more-subtext]')
.hasText(
'Explore the features of Vault and learn advance practices with the following tutorials and documentation.'
);
assert.dom('[data-test-learn-more-links] a').exists({ count: 3 });
assert
.dom('[data-test-feedback-form]')
.hasText("Don't see what you're looking for on this page? Let us know via our feedback form .");
});
test('shows the learn more card on enterprise', async function (assert) {
this.version.features = [
'Performance Replication',
'DR Replication',
'Namespaces',
'Transform Secrets Engine',
];
await this.renderComponent();
assert.dom('[data-test-learn-more-title]').hasText('Learn more');
assert
.dom('[data-test-learn-more-subtext]')
.hasText(
'Explore the features of Vault and learn advance practices with the following tutorials and documentation.'
);
assert.dom('[data-test-learn-more-links] a').exists({ count: 4 });
assert
.dom('[data-test-feedback-form]')
.hasText("Don't see what you're looking for on this page? Let us know via our feedback form .");
});
});
});