@@ -20,20 +20,29 @@ func TestBackend_basic(t *testing.T) {
20
20
t .Fatal (err )
21
21
}
22
22
23
- roleConfig := roleConfig {
24
- Connection : "testconn" ,
25
- Roles : []string {"admin" },
26
- UserPrefix : defaultUserPrefix ,
23
+ schemes := []string {
24
+ userIDSchemeUUID4_v0_5_0 ,
25
+ userIDSchemeUUID4 ,
26
+ userIDSchemeBase58_64 ,
27
+ userIDSchemeBase58_128 ,
27
28
}
29
+ for _ , scheme := range schemes {
30
+ roleConfig := roleConfig {
31
+ Connection : "testconn" ,
32
+ Roles : []string {"admin" },
33
+ UserPrefix : defaultUserPrefix ,
34
+ UserIDScheme : scheme ,
35
+ }
28
36
29
- logicaltest .Test (t , logicaltest.TestCase {
30
- LogicalBackend : b ,
31
- Steps : []logicaltest.TestStep {
32
- testAccStepConfig (t ),
33
- testAccStepRole (t , "test" , roleConfig ),
34
- testAccStepCredsRead (t , "test" ),
35
- },
36
- })
37
+ logicaltest .Test (t , logicaltest.TestCase {
38
+ LogicalBackend : b ,
39
+ Steps : []logicaltest.TestStep {
40
+ testAccStepConfig (t ),
41
+ testAccStepRole (t , "test" , roleConfig ),
42
+ testAccStepCredsRead (t , "test" ),
43
+ },
44
+ })
45
+ }
37
46
}
38
47
39
48
func TestBackend_RotateRoot (t * testing.T ) {
@@ -92,6 +101,7 @@ func TestBackend_RoleCRUD(t *testing.T) {
92
101
AllowedServerRoles : []string {"*" },
93
102
PasswordSpec : DefaultPasswordSpec (),
94
103
UserPrefix : "my-custom-prefix" ,
104
+ UserIDScheme : userIDSchemeUUID4 ,
95
105
}
96
106
97
107
logicaltest .Test (t , logicaltest.TestCase {
@@ -105,17 +115,23 @@ func TestBackend_RoleCRUD(t *testing.T) {
105
115
testAccStepRoleDelete (t , "test" ),
106
116
},
107
117
})
108
- emptyUserPrefixConfig := roleConfig {
109
- Connection : "testconn" ,
110
- Roles : []string {"admin" },
111
- UserPrefix : "" ,
112
- }
118
+ emptyUserPrefixConfig := testRoleConfig
119
+ emptyUserPrefixConfig .UserPrefix = ""
113
120
logicaltest .Test (t , logicaltest.TestCase {
114
121
LogicalBackend : b ,
115
122
Steps : []logicaltest.TestStep {
116
123
testEmptyUserPrefix (t , "test" , emptyUserPrefixConfig ),
117
124
},
118
125
})
126
+
127
+ userIDSchemeConfig := testRoleConfig
128
+ userIDSchemeConfig .UserIDScheme = "-invalid-"
129
+ logicaltest .Test (t , logicaltest.TestCase {
130
+ LogicalBackend : b ,
131
+ Steps : []logicaltest.TestStep {
132
+ testUserIDScheme (t , "test" , "-invalid-" , userIDSchemeConfig ),
133
+ },
134
+ })
119
135
}
120
136
121
137
// Test steps
@@ -219,6 +235,22 @@ func testEmptyUserPrefix(t *testing.T, role string, config roleConfig) logicalte
219
235
}
220
236
}
221
237
238
+ func testUserIDScheme (t * testing.T , role , idScheme string , config roleConfig ) logicaltest.TestStep {
239
+ return logicaltest.TestStep {
240
+ Operation : logical .CreateOperation ,
241
+ Path : rolesPrefix + role ,
242
+ Data : config .toResponseData (),
243
+ ErrorOk : true ,
244
+ Check : func (resp * logical.Response ) error {
245
+ if resp == nil {
246
+ return fmt .Errorf ("response is nil" )
247
+ }
248
+ assert .Error (t , resp .Error (), fmt .Sprintf ("invalid user_id_scheme: %q" , idScheme ))
249
+ return nil
250
+ },
251
+ }
252
+ }
253
+
222
254
func testAccStepCredsRead (t * testing.T , role string ) logicaltest.TestStep {
223
255
return logicaltest.TestStep {
224
256
Operation : logical .ReadOperation ,
@@ -235,8 +267,11 @@ func testAccStepCredsRead(t *testing.T, role string) logicaltest.TestStep {
235
267
if err := mapstructure .Decode (resp .Data , & d ); err != nil {
236
268
return err
237
269
}
238
- t .Logf ("[WARN] Generated credentials: %+v" , d )
239
- // XXXX check that generated user can login
270
+ // check that generated user can login
271
+ conn := splunk .NewTestSplunkClient (d .URL , d .Username , d .Password )
272
+ _ , _ , err := conn .Introspection .ServerInfo ()
273
+ assert .NilError (t , err )
274
+
240
275
// XXXX check that generated user is deleted if lease expires
241
276
return nil
242
277
},
0 commit comments