@@ -425,6 +425,50 @@ var _ = Describe("Sync", func() {
425
425
err := actionFilters (ac )
426
426
Ω (err ).ShouldNot (HaveOccurred ())
427
427
})
428
+ It ("should add a filter" , func () {
429
+ ac .origin .filters .Filters = utils .Ptr ([]model.Filter {{Name : "foo" , Url : "https://foo.bar" }})
430
+ cl .EXPECT ().Filtering ().Return (rf , nil )
431
+ cl .EXPECT ().AddFilter (false , model.Filter {Name : "foo" , Url : "https://foo.bar" })
432
+ cl .EXPECT ().RefreshFilters (gm .Any ())
433
+ err := actionFilters (ac )
434
+ Ω (err ).ShouldNot (HaveOccurred ())
435
+ })
436
+ It ("should delete a filter" , func () {
437
+ rf .Filters = utils .Ptr ([]model.Filter {{Name : "foo" , Url : "https://foo.bar" }})
438
+ cl .EXPECT ().Filtering ().Return (rf , nil )
439
+ cl .EXPECT ().DeleteFilter (false , model.Filter {Name : "foo" , Url : "https://foo.bar" })
440
+ err := actionFilters (ac )
441
+ Ω (err ).ShouldNot (HaveOccurred ())
442
+ })
443
+ It ("should update a filter" , func () {
444
+ ac .origin .filters .Filters = utils .Ptr ([]model.Filter {{Name : "foo" , Url : "https://foo.bar" , Enabled : true }})
445
+ rf .Filters = utils .Ptr ([]model.Filter {{Name : "foo" , Url : "https://foo.bar" }})
446
+ cl .EXPECT ().Filtering ().Return (rf , nil )
447
+ cl .EXPECT ().UpdateFilter (false , model.Filter {Name : "foo" , Url : "https://foo.bar" , Enabled : true })
448
+ cl .EXPECT ().RefreshFilters (gm .Any ())
449
+ err := actionFilters (ac )
450
+ Ω (err ).ShouldNot (HaveOccurred ())
451
+ })
452
+
453
+ It ("should abort after failed added filter" , func () {
454
+ ac .continueOnError = false
455
+ ac .origin .filters .Filters = utils .Ptr ([]model.Filter {{Name : "foo" , Url : "https://foo.bar" }})
456
+ cl .EXPECT ().Filtering ().Return (rf , nil )
457
+ cl .EXPECT ().AddFilter (false , model.Filter {Name : "foo" , Url : "https://foo.bar" }).Return (errors .New ("test failure" ))
458
+ err := actionFilters (ac )
459
+ Ω (err ).Should (HaveOccurred ())
460
+ })
461
+
462
+ It ("should continue after failed added filter" , func () {
463
+ ac .continueOnError = true
464
+ ac .origin .filters .Filters = utils .Ptr ([]model.Filter {{Name : "foo" , Url : "https://foo.bar" }, {Name : "bar" , Url : "https://bar.foo" }})
465
+ cl .EXPECT ().Filtering ().Return (rf , nil )
466
+ cl .EXPECT ().AddFilter (false , model.Filter {Name : "foo" , Url : "https://foo.bar" }).Return (errors .New ("test failure" ))
467
+ cl .EXPECT ().AddFilter (false , model.Filter {Name : "bar" , Url : "https://bar.foo" })
468
+ cl .EXPECT ().RefreshFilters (gm .Any ())
469
+ err := actionFilters (ac )
470
+ Ω (err ).ShouldNot (HaveOccurred ())
471
+ })
428
472
})
429
473
430
474
Context ("actionDNSAccessLists" , func () {
0 commit comments