@@ -117,6 +117,7 @@ func TestAuthDBColumns(t *testing.T) {
117
117
table .TextColumn ("mechanisms" ),
118
118
table .TextColumn ("modified" ),
119
119
table .TextColumn ("require_apple_signed" ),
120
+ table .TextColumn ("rule" ),
120
121
table .TextColumn ("session_owner" ),
121
122
table .TextColumn ("shared" ),
122
123
table .TextColumn ("timeout" ),
@@ -279,6 +280,7 @@ func TestBuildOutput(t *testing.T) {
279
280
"group" : "group" ,
280
281
"mechanisms" : "mechanism1,mechanism2" ,
281
282
"modified" : "2.000000" ,
283
+ "rule" : "" ,
282
284
"require_apple_signed" : "true" ,
283
285
"session_owner" : "false" ,
284
286
"shared" : "true" ,
@@ -292,3 +294,42 @@ func TestBuildOutput(t *testing.T) {
292
294
293
295
assert .Equal (t , expectedOutput , actualOutput , "Expected output to match" )
294
296
}
297
+
298
+ func TestGetRuleWithRules (t * testing.T ) {
299
+ runner := utils.MockCmdRunner {
300
+ Output : `<?xml version="1.0" encoding="UTF-8"?>
301
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
302
+ <plist version="1.0">
303
+ <dict>
304
+ <key>class</key>
305
+ <string>rule</string>
306
+ <key>created</key>
307
+ <real>730353220.36463201</real>
308
+ <key>modified</key>
309
+ <real>738604357.04363894</real>
310
+ <key>rule</key>
311
+ <array>
312
+ <string>allow</string>
313
+ </array>
314
+ <key>version</key>
315
+ <integer>0</integer>
316
+ </dict>
317
+ </plist>` ,
318
+ Err : nil ,
319
+ }
320
+
321
+ expected := AuthDBRight {
322
+ Name : "system.preferences.datetime" ,
323
+ Class : "rule" ,
324
+ Created : 730353220.36463201 ,
325
+ Modified : 738604357.04363894 ,
326
+ Rule : []string {"allow" },
327
+ Version : 0 ,
328
+ }
329
+
330
+ r := utils.Runner {}
331
+ r .Runner = runner
332
+ out , err := getRule (r , "system.preferences.datetime" )
333
+ assert .NoError (t , err )
334
+ assert .Equal (t , expected , out )
335
+ }
0 commit comments