Skip to content

Commit 2582847

Browse files
committed
Expand assertions when viewing the Policy Rules for a given role
Signed-off-by: Timur Sultanov <timur.sultanov@yahooinc.com>
1 parent aebec2c commit 2582847

File tree

8 files changed

+201
-27
lines changed

8 files changed

+201
-27
lines changed

ui/src/__tests__/components/role-policy/RolePolicyRow.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('RolePolicyRow', () => {
3030
</tbody>
3131
</table>
3232
);
33-
const rolePolicyRow = getByTestId('role-policy-row');
33+
const rolePolicyRow = getByTestId('policy-row');
3434
expect(rolePolicyRow).toMatchSnapshot();
3535
});
3636
});

ui/src/__tests__/components/role-policy/__snapshots__/RolePolicyRow.test.js.snap

Lines changed: 174 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,47 +19,198 @@ exports[`RolePolicyRow should render 1`] = `
1919
}
2020
2121
.emotion-4 {
22+
padding: 10px 0 10px 0;
23+
width: 100%;
24+
}
25+
26+
.emotion-6 {
2227
margin-right: 10px;
2328
vertical-align: bottom;
2429
}
2530
26-
.emotion-6 {
31+
.emotion-8 {
2732
fill: #188fff;
2833
cursor: pointer;
2934
vertical-align: text-bottom;
3035
}
3136
37+
.emotion-11 {
38+
width: 100%;
39+
border-spacing: 0;
40+
display: table;
41+
border-collapse: separate;
42+
}
43+
44+
.emotion-13 {
45+
text-align: left;
46+
border-bottom: 2px solid #d5d5d5;
47+
color: #303030;
48+
font-weight: 600;
49+
font-size: 16px;
50+
padding-bottom: 2px;
51+
vertical-align: top;
52+
padding: 10px 10px 0px 15px;
53+
word-break: break-all;
54+
}
55+
56+
.emotion-15 {
57+
text-align: right;
58+
border-bottom: 2px solid #d5d5d5;
59+
color: #3570F4;
60+
font-weight: 300;
61+
font-size: 14px;
62+
padding-bottom: 2px;
63+
vertical-align: top;
64+
padding: 10px 10px 0px 15px;
65+
word-break: break-all;
66+
}
67+
68+
.emotion-17 {
69+
color: #3570f4;
70+
-webkit-text-decoration: none;
71+
text-decoration: none;
72+
cursor: pointer;
73+
}
74+
75+
.emotion-19 {
76+
margin: 15px 0 0 0;
77+
}
78+
79+
.emotion-23 {
80+
border-bottom: 2px solid #d5d5d5;
81+
color: #9a9a9a;
82+
font-weight: 600;
83+
font-size: 1.2rem;
84+
padding-bottom: 5px;
85+
vertical-align: top;
86+
text-transform: uppercase;
87+
padding: 5px 0 5px 15px;
88+
text-align: left;
89+
background-color: white;
90+
}
91+
92+
.emotion-31 {
93+
border-bottom: 2px solid #d5d5d5;
94+
color: #9a9a9a;
95+
font-weight: 600;
96+
padding-bottom: 5px;
97+
vertical-align: top;
98+
text-transform: uppercase;
99+
width: 120px;
100+
text-align: center;
101+
background-color: white;
102+
}
103+
32104
<tr
33105
class="emotion-0 emotion-1"
34-
data-testid="role-policy-row"
106+
data-testid="policy-row"
35107
>
36108
<td
37109
class="emotion-2 emotion-3"
38110
>
39-
<span
111+
<div
112+
class="emotion-4 emotion-5"
113+
>
114+
<span
115+
class="emotion-6 emotion-7"
116+
>
117+
<svg
118+
class="emotion-8"
119+
data-testid="icon"
120+
data-wdio=""
121+
height="1.25em"
122+
id=""
123+
viewBox="0 0 1024 1024"
124+
width="1.25em"
125+
>
126+
<title>
127+
arrowhead-up-circle-solid
128+
</title>
129+
<path
130+
d="M512 42.667c-259.206 0-469.333 210.128-469.333 469.333s210.128 469.333 469.333 469.333c259.206 0 469.333-210.128 469.333-469.333v0c0.003-0.635 0.005-1.387 0.005-2.138 0-258.027-209.173-467.2-467.2-467.2-0.752 0-1.504 0.002-2.255 0.005l0.117-0zM718.933 601.6c-9.129 9.862-21.88 16.257-36.127 17.060l-0.14 0.006h-341.333c-14.386-0.81-27.138-7.205-36.235-17.032l-0.032-0.035c-4.299-6.754-6.851-14.984-6.851-23.81 0-13.46 5.936-25.533 15.332-33.745l0.053-0.045 168.533-168.533c7.434-8.083 18.061-13.13 29.867-13.13s22.432 5.047 29.84 13.101l0.026 0.029 168.533 168.533c9.449 8.257 15.384 20.33 15.384 33.79 0 8.826-2.552 17.056-6.959 23.992l0.108-0.182z"
131+
/>
132+
</svg>
133+
</span>
134+
sections
135+
</div>
136+
<div
40137
class="emotion-4 emotion-5"
41138
>
42-
<svg
43-
class="emotion-6"
44-
data-testid="icon"
45-
data-wdio=""
46-
height="1.25em"
47-
id=""
48-
viewBox="0 0 1024 1024"
49-
width="1.25em"
139+
<table
140+
class="emotion-11 emotion-12"
141+
data-testid="role-policy-rule-table"
50142
>
51-
<title>
52-
arrowhead-down-circle
53-
</title>
54-
<path
55-
d="M512 896c-212.077 0-384-171.923-384-384s171.923-384 384-384c212.077 0 384 171.923 384 384v0c-1.203 211.592-172.408 382.797-383.885 383.999l-0.115 0.001zM512 981.333c259.206 0 469.333-210.128 469.333-469.333s-210.128-469.333-469.333-469.333c-259.206 0-469.333 210.128-469.333 469.333v0c-0.003 0.635-0.005 1.387-0.005 2.138 0 258.027 209.173 467.2 467.2 467.2 0.752 0 1.504-0.002 2.255-0.005l-0.117 0z"
56-
/>
57-
<path
58-
d="M512 558.933l-140.8-140.8c-7.461-8.401-18.291-13.668-30.351-13.668-13.957 0-26.267 7.055-33.558 17.793l-0.091 0.142c-5.319 7.276-8.51 16.4-8.51 26.27 0 12.199 4.876 23.259 12.785 31.338l-0.008-0.008 170.667 168.533c7.434 8.083 18.061 13.13 29.867 13.13s22.432-5.047 29.84-13.101l0.026-0.029 170.667-168.533c7.901-8.071 12.777-19.131 12.777-31.33 0-9.87-3.192-18.994-8.599-26.397l0.088 0.127c-7.382-10.88-19.691-17.934-33.649-17.934-12.060 0-22.89 5.267-30.315 13.626l-0.036 0.042z"
59-
/>
60-
</svg>
61-
</span>
62-
sections
143+
<tbody>
144+
<tr>
145+
<th
146+
class="emotion-13 emotion-14"
147+
color="#303030"
148+
>
149+
Rule Details(
150+
0
151+
)
152+
</th>
153+
<th
154+
class="emotion-15 emotion-14"
155+
color="#3570F4"
156+
>
157+
<a
158+
class="emotion-17 emotion-18"
159+
>
160+
Add rule
161+
</a>
162+
</th>
163+
</tr>
164+
<tr>
165+
<td
166+
colspan="4"
167+
/>
168+
</tr>
169+
<tr>
170+
<td
171+
colspan="4"
172+
>
173+
<div
174+
class="emotion-19 emotion-20"
175+
>
176+
<table
177+
class="emotion-11 emotion-12"
178+
>
179+
<thead>
180+
<tr>
181+
<th
182+
class="emotion-23 emotion-24"
183+
>
184+
Effect
185+
</th>
186+
<th
187+
class="emotion-23 emotion-24"
188+
>
189+
Action
190+
</th>
191+
<th
192+
class="emotion-23 emotion-24"
193+
>
194+
Role
195+
</th>
196+
<th
197+
class="emotion-23 emotion-24"
198+
>
199+
Resource
200+
</th>
201+
<th
202+
class="emotion-31 emotion-32"
203+
/>
204+
</tr>
205+
</thead>
206+
<tbody />
207+
</table>
208+
</div>
209+
</td>
210+
</tr>
211+
</tbody>
212+
</table>
213+
</div>
63214
</td>
64215
</tr>
65216
`;

ui/src/__tests__/components/role/__snapshots__/RoleRow.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ exports[`RoleRow should render 1`] = `
140140
<svg
141141
class="emotion-12"
142142
data-testid="icon"
143-
data-wdio=""
143+
data-wdio="ztssia_cert_rotate-policy-rules"
144144
height="1.25em"
145145
id=""
146146
viewBox="0 0 1024 1024"

ui/src/__tests__/components/role/__snapshots__/RoleTable.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ exports[`RoleTable should render 1`] = `
222222
<svg
223223
class="emotion-36"
224224
data-testid="icon"
225-
data-wdio=""
225+
data-wdio="a-policy-rules"
226226
height="1.25em"
227227
id=""
228228
viewBox="0 0 1024 1024"
@@ -423,7 +423,7 @@ exports[`RoleTable should render 1`] = `
423423
<svg
424424
class="emotion-36"
425425
data-testid="icon"
426-
data-wdio=""
426+
data-wdio="b-policy-rules"
427427
height="1.25em"
428428
id=""
429429
viewBox="0 0 1024 1024"

ui/src/__tests__/spec/tests/roles.spec.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const TEST_NAME_ROLE_REVIEW_EXTEND_DISABLED =
3232
const TEST_NAME_DOMAIN_FILTER =
3333
'Domain Filter - only principals matching specific domain(s) can be added to a role';
3434
const TEST_ADD_ROLE_WITH_MULTIPLE_MEMBERS = 'Add role with multiple members';
35+
const TEST_ROLE_RULE_POLICY_EXPANDED = "Rule policy for a role is expanded by default when opened";
3536

3637
async function deleteRoleIfExists(roleName) {
3738
await browser.newUser();
@@ -696,6 +697,25 @@ describe('role screen tests', () => {
696697
await expect(memberRow2).toHaveText(expect.stringContaining(user2));
697698
});
698699

700+
it(TEST_ROLE_RULE_POLICY_EXPANDED, async () => {
701+
const adminRole = 'admin';
702+
703+
// open browser
704+
await browser.newUser();
705+
await browser.url(`/domain/athenz.dev.functional-test/role`);
706+
707+
// verify rule policy is expanded by default for role
708+
await $(
709+
`.//*[local-name()="svg" and @data-wdio="${adminRole}-policy-rules"]`
710+
).click();
711+
712+
const roleRow = await $(`tr[data-wdio='${adminRole}-policy-rule-row']`).$(
713+
`td*=${adminRole}`
714+
);
715+
716+
await expect(roleRow).toHaveText(expect.stringContaining(`athenz.dev.functional-test:role.${adminRole}`));
717+
});
718+
699719
afterEach(async () => {
700720
if (currentTest === TEST_NAME_HISTORY_VISIBLE_AFTER_PAGE_REFRESH) {
701721
await deleteRoleIfExists(historyTestRole);

ui/src/components/role-policy/RolePolicyRow.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class RolePolicyRow extends React.Component {
8888
name: this.props.name,
8989
errorMessage: null,
9090
newPolicy: this.props.newPolicy,
91+
assertions: true,
9192
};
9293
this.localDate = new DateUtils();
9394
}

ui/src/components/role-policy/RolePolicyRuleTable.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ class RolePolicyRuleTable extends React.Component {
239239
this.state.successMessage;
240240
rows.push(
241241
<TrStyled
242+
data-wdio={`${this.props.role}-policy-rule-row`}
242243
key={this.props.name + id + i + '-assertion'}
243244
isSuccess={newAssertion}
244245
>

ui/src/components/role/RoleRow.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ class RoleRow extends React.Component {
382382
trigger={
383383
<span>
384384
<Icon
385+
dataWdio={`${this.state.name}-policy-rules`}
385386
icon={'list-check'}
386387
onClick={clickPolicy}
387388
color={colors.icons}

0 commit comments

Comments
 (0)