Skip to content

Commit b5669c8

Browse files
TEST yml REST test for the profile has privileges API (elastic#87387) (elastic#87477)
yml REST test for the profile has privilege API from elastic#85898.
1 parent 5e8862c commit b5669c8

File tree

1 file changed

+176
-0
lines changed

1 file changed

+176
-0
lines changed
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
---
2+
setup:
3+
- skip:
4+
features:
5+
- headers
6+
- stash_in_key
7+
8+
- do:
9+
cluster.health:
10+
wait_for_status: yellow
11+
12+
- do:
13+
security.put_user:
14+
username: "super"
15+
body: >
16+
{
17+
"password" : "s3krit-password",
18+
"roles" : [ "superuser" ]
19+
}
20+
21+
- do:
22+
security.put_user:
23+
username: "user1"
24+
body: >
25+
{
26+
"password": "s3krit-password",
27+
"roles" : [ "role1" ]
28+
}
29+
30+
- do:
31+
security.put_role:
32+
name: "role1"
33+
body: >
34+
{
35+
"indices": [
36+
{
37+
"names": "index1*",
38+
"privileges": ["all"]
39+
},
40+
{
41+
"names": "index2*",
42+
"privileges": ["read"]
43+
}
44+
]
45+
}
46+
47+
- do:
48+
security.put_user:
49+
username: "user2"
50+
body: >
51+
{
52+
"password": "s3krit-password",
53+
"roles" : [ "role2" ]
54+
}
55+
56+
- do:
57+
security.put_role:
58+
name: "role2"
59+
body: >
60+
{
61+
"indices": [
62+
{
63+
"names": "index2*",
64+
"privileges": ["all"]
65+
},
66+
{
67+
"names": "index1*",
68+
"privileges": ["read"]
69+
}
70+
]
71+
}
72+
73+
---
74+
teardown:
75+
- do:
76+
security.delete_user:
77+
username: "super"
78+
ignore: 404
79+
- do:
80+
security.delete_user:
81+
username: "user1"
82+
ignore: 404
83+
- do:
84+
security.delete_user:
85+
username: "user2"
86+
ignore: 404
87+
- do:
88+
security.delete_role:
89+
name: "role1"
90+
ignore: 404
91+
- do:
92+
security.delete_role:
93+
name: "role2"
94+
ignore: 404
95+
96+
---
97+
"Test profile has privileges api":
98+
99+
- do:
100+
security.activate_user_profile:
101+
body: >
102+
{
103+
"grant_type": "password",
104+
"username": "user1",
105+
"password" : "s3krit-password"
106+
}
107+
- match: { "user.username" : "user1" }
108+
- is_true: uid
109+
- set: { uid: profile_uid1 }
110+
111+
- do:
112+
security.activate_user_profile:
113+
body: >
114+
{
115+
"grant_type": "password",
116+
"username": "user2",
117+
"password" : "s3krit-password"
118+
}
119+
- match: { "user.username" : "user2" }
120+
- is_true: uid
121+
- set: { uid: profile_uid2 }
122+
123+
- do:
124+
security.has_privileges_user_profile:
125+
body:
126+
uids:
127+
- $profile_uid1
128+
- $profile_uid2
129+
- dummy_missing
130+
privileges:
131+
index:
132+
- names:
133+
- index1*
134+
- index2*
135+
privileges:
136+
- read
137+
- length: { has_privilege_uids: 2 }
138+
- match: { has_privilege_uids.0 : "/^(${profile_uid1}|${profile_uid2})$/" }
139+
- match: { has_privilege_uids.1 : "/^(${profile_uid1}|${profile_uid2})$/" }
140+
141+
- do:
142+
security.has_privileges_user_profile:
143+
body:
144+
uids:
145+
- $profile_uid1
146+
- $profile_uid2
147+
privileges:
148+
index:
149+
- names:
150+
- index1*
151+
- index2*
152+
privileges:
153+
- all
154+
- read
155+
- length: { "has_privilege_uids": 0 }
156+
157+
- do:
158+
security.has_privileges_user_profile:
159+
body:
160+
uids:
161+
- $profile_uid1
162+
- dummy
163+
privileges:
164+
index:
165+
- names:
166+
- index1*
167+
privileges:
168+
- all
169+
- read
170+
- names:
171+
- index1*
172+
- index2*
173+
privileges:
174+
- read
175+
- length: { "has_privilege_uids": 1 }
176+
- match: { "has_privilege_uids.0" : $profile_uid1 }

0 commit comments

Comments
 (0)