@@ -14,115 +14,34 @@ namespace Tests.XPack.ApiKey
1414 [SkipVersion("<6.7.0", "Security Api Keys are modelled against 6.7.0")]
1515 public class SecurityApiKeyTests : CoordinatedIntegrationTestBase<XPackCluster>
1616 {
17- private const string PutRoleStep = nameof(PutRoleStep);
1817 private const string PutUserStep = nameof(PutUserStep);
19- private const string PutPrivilegesStep = nameof(PutPrivilegesStep);
2018 private const string CreateApiKeyWithRolesStep = nameof(CreateApiKeyWithRolesStep);
2119 private const string CreateApiKeyWithNoRolesStep = nameof(CreateApiKeyWithNoRolesStep);
2220 private const string GetApiKeyStep = nameof(GetApiKeyStep);
2321 private const string InvalidateApiKeyStep = nameof(InvalidateApiKeyStep);
2422
2523 public SecurityApiKeyTests(XPackCluster cluster, EndpointUsage usage) : base(new CoordinatedUsage(cluster, usage)
2624 {
27- {
28- PutRoleStep, u =>
29- u.Calls<PutRoleDescriptor, PutRoleRequest, IPutRoleRequest, IPutRoleResponse>(
30- v => new PutRoleRequest($"role-{v}")
31- {
32- Cluster = new[] { "all" },
33- Indices = new IIndicesPrivileges[]
34- {
35- new IndicesPrivileges
36- {
37- Names = "*",
38- Privileges = new [] { "all" }
39- }
40- },
41- Applications = new IApplicationPrivileges[]
42- {
43- new ApplicationPrivileges
44- {
45- Application = $"app-{v}",
46- Privileges = new [] { "*" },
47- Resources = new [] { "*" }
48- }
49- }
50- },
51- (v, d) => d
52- .Cluster("all")
53- .Indices(i => i.Add<object>(p => p.Names("*").Privileges("all")))
54- .Applications(i => i.Add<object>(p => p.Application($"app-{v}").Privileges("*").Resources("*")))
55- ,
56- (v, c, f) => c.PutRole($"role-{v}", f),
57- (v, c, f) => c.PutRoleAsync($"role-{v}", f),
58- (v, c, r) => c.PutRole(r),
59- (v, c, r) => c.PutRoleAsync(r)
60- )
61- },
6225 {
6326 PutUserStep, u =>
6427 u.Calls<PutUserDescriptor, PutUserRequest, IPutUserRequest, IPutUserResponse>(
6528 v => new PutUserRequest($"user-{v}")
6629 {
6730 Password = "password",
68- Roles = new[] { $"role-{v}", "superuser" },
69- FullName = "API key user "
31+ Roles = new[] { "superuser" },
32+ FullName = "API key superuser "
7033 },
7134 (v, d) => d
7235 .Password("password")
73- .Roles($"role-{v}", "superuser")
74- .FullName("API key user ")
36+ .Roles("superuser")
37+ .FullName("API key superuser ")
7538 ,
7639 (v, c, f) => c.PutUser($"user-{v}", f),
7740 (v, c, f) => c.PutUserAsync($"user-{v}", f),
7841 (v, c, r) => c.PutUser(r),
7942 (v, c, r) => c.PutUserAsync(r)
8043 )
8144 },
82- {
83- PutPrivilegesStep, u =>
84- u.Calls<PutPrivilegesDescriptor, PutPrivilegesRequest, IPutPrivilegesRequest, IPutPrivilegesResponse>(
85- v => new PutPrivilegesRequest
86- {
87- Applications = new AppPrivileges
88- {
89- {
90- $"app-{v}", new Privileges
91- {
92- {
93- $"read", new PrivilegesActions
94- {
95- Actions = new[] { "data:read/*" }
96- }
97- },
98- {
99- $"write", new PrivilegesActions
100- {
101- Actions = new[] { "data:write/*" }
102- }
103- }
104- }
105- }
106- }
107- },
108- (v, d) => d
109- .Applications(a => a
110- .Application($"app-{v}", pr => pr
111- .Privilege($"read", ac => ac
112- .Actions("data:read/*")
113- )
114- .Privilege($"write", ac => ac
115- .Actions("data:write/*")
116- )
117- )
118- )
119- ,
120- (v, c, f) => c.PutPrivileges(f),
121- (v, c, f) => c.PutPrivilegesAsync(f),
122- (v, c, r) => c.PutPrivileges(r),
123- (v, c, r) => c.PutPrivilegesAsync(r)
124- )
125- },
12645 {
12746 CreateApiKeyWithRolesStep, u =>
12847 u.Calls<CreateApiKeyDescriptor, CreateApiKeyRequest, ICreateApiKeyRequest, ICreateApiKeyResponse>(
0 commit comments