-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path60_api_key_update.yml
122 lines (117 loc) · 2.66 KB
/
60_api_key_update.yml
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
---
requires:
stack: true
serverless: false
---
setup:
- do:
security.put_role:
name: "user_role"
body: >
{
"cluster": ["manage_own_api_key"],
"indices": [
{
"names": "*",
"privileges": ["all"]
}
]
}
- do:
security.put_user:
username: "api_key_user_1"
body: >
{
"password" : "x-pack-test-password",
"roles" : [ "user_role" ],
"full_name" : "API key user"
}
---
teardown:
- do:
security.delete_role:
name: "user_role"
ignore: 404
- do:
security.delete_user:
username: "api_key_user_1"
ignore: 404
---
"Test update api key":
- do:
security.create_api_key:
body: >
{
"name": "user1-api-key",
"role_descriptors": {
"role-a": {
"cluster": ["none"],
"index": [
{
"names": ["index-a"],
"privileges": ["read"]
}
]
}
}
}
- match: { name: "user1-api-key" }
- is_true: id
- is_true: api_key
- set: { id: user_key_id }
- do:
security.update_api_key:
id: "$user_key_id"
body: >
{
"role_descriptors": {
"role-a": {
"cluster": ["all"],
"index": [
{
"names": ["index-a"],
"privileges": ["write"]
},
{
"names": ["index-b"],
"privileges": ["read"]
}
]
}
},
"metadata": {
"letter": "a",
"number": 42
}
}
- match: { updated: true }
- do:
security.bulk_update_api_keys:
body: >
{
"ids": ["$user_key_id"],
"role_descriptors": {
"role-a": {
"cluster": ["all"],
"index": [
{
"names": ["index-a"],
"privileges": ["write"]
},
{
"names": ["index-b"],
"privileges": ["read"]
}
]
}
},
"metadata": {
"letter": "a",
"number": 43
}
}
- length: { "noops": 0 }
- length: { "updated": 1 }
- match: {
"updated.0": "$user_key_id"
}