@@ -13,116 +13,34 @@ namespace Tests.XPack.Security.ApiKey
1313 [ SkipVersion ( "<6.7.0" , "Security Api Keys are modelled against 6.7.0" ) ]
1414 public class SecurityApiKeyTests : CoordinatedIntegrationTestBase < XPackCluster >
1515 {
16- private const string PutRoleStep = nameof ( PutRoleStep ) ;
1716 private const string PutUserStep = nameof ( PutUserStep ) ;
18- private const string PutPrivilegesStep = nameof ( PutPrivilegesStep ) ;
1917 private const string CreateApiKeyWithRolesStep = nameof ( CreateApiKeyWithRolesStep ) ;
2018 private const string CreateApiKeyWithNoRolesStep = nameof ( CreateApiKeyWithNoRolesStep ) ;
2119 private const string GetApiKeyStep = nameof ( GetApiKeyStep ) ;
2220 private const string InvalidateApiKeyStep = nameof ( InvalidateApiKeyStep ) ;
2321
2422 public SecurityApiKeyTests ( XPackCluster cluster , EndpointUsage usage ) : base ( new CoordinatedUsage ( cluster , usage )
2523 {
26- {
27- PutRoleStep , u =>
28- u . Calls < PutRoleDescriptor , PutRoleRequest , IPutRoleRequest , PutRoleResponse > (
29- v => new PutRoleRequest ( $ "role-{ v } ")
30- {
31- Cluster = new [ ] { "all" } ,
32- Indices = new IIndicesPrivileges [ ]
33- {
34- new IndicesPrivileges
35- {
36- Names = "*" ,
37- Privileges = new [ ] { "all" }
38- }
39- } ,
40- Applications = new IApplicationPrivileges [ ]
41- {
42- new ApplicationPrivileges
43- {
44- Application = $ "app-{ v } ",
45- Privileges = new [ ] { "*" } ,
46- Resources = new [ ] { "*" }
47- }
48- }
49- } ,
50- ( v , d ) => d
51- . Cluster ( "all" )
52- // ReSharper disable once PossiblyMistakenUseOfParamsMethod
53- . Indices ( i => i . Add < object > ( p => p . Names ( "*" ) . Privileges ( "all" ) ) )
54- . Applications ( i => i . Add ( p => p . Application ( $ "app-{ v } ") . Privileges ( "*" ) . Resources ( "*" ) ) )
55- ,
56- ( v , c , f ) => c . Security . PutRole ( $ "role-{ v } ", f ) ,
57- ( v , c , f ) => c . Security . PutRoleAsync ( $ "role-{ v } ", f ) ,
58- ( v , c , r ) => c . Security . PutRole ( r ) ,
59- ( v , c , r ) => c . Security . PutRoleAsync ( r )
60- )
61- } ,
6224 {
6325 PutUserStep , u =>
6426 u . Calls < PutUserDescriptor , PutUserRequest , IPutUserRequest , PutUserResponse > (
6527 v => new PutUserRequest ( $ "user-{ v } ")
6628 {
6729 Password = "password" ,
68- Roles = new [ ] { $ "role- { v } " , "superuser" } ,
69- FullName = "API key user "
30+ Roles = new [ ] { "superuser" } ,
31+ FullName = "API key superuser "
7032 } ,
7133 ( v , d ) => d
7234 . Password ( "password" )
73- . Roles ( $ "role- { v } " , "superuser" )
74- . FullName ( "API key user " )
35+ . Roles ( "superuser" )
36+ . FullName ( "API key superuser " )
7537 ,
7638 ( v , c , f ) => c . Security . PutUser ( $ "user-{ v } ", f ) ,
7739 ( v , c , f ) => c . Security . PutUserAsync ( $ "user-{ v } ", f ) ,
7840 ( v , c , r ) => c . Security . PutUser ( r ) ,
7941 ( v , c , r ) => c . Security . PutUserAsync ( r )
8042 )
8143 } ,
82- {
83- PutPrivilegesStep , u =>
84- u . Calls < PutPrivilegesDescriptor , PutPrivilegesRequest , IPutPrivilegesRequest , PutPrivilegesResponse > (
85- v => new PutPrivilegesRequest
86- {
87- Applications = new AppPrivileges
88- {
89- {
90- $ "app-{ v } ", new Nest . 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 . Security . PutPrivileges ( f ) ,
121- ( v , c , f ) => c . Security . PutPrivilegesAsync ( f ) ,
122- ( v , c , r ) => c . Security . PutPrivileges ( r ) ,
123- ( v , c , r ) => c . Security . PutPrivilegesAsync ( r )
124- )
125- } ,
12644 {
12745 CreateApiKeyWithRolesStep , u =>
12846 u . Calls < CreateApiKeyDescriptor , CreateApiKeyRequest , ICreateApiKeyRequest , CreateApiKeyResponse > (
0 commit comments