@@ -579,34 +579,49 @@ func TestConverter_AccessControl(t *testing.T) {
579
579
580
580
t .Run ("allow all, single root field" ,
581
581
f (`{"name":"John"}` , nil , filter .WithAllowAllColumns ()))
582
+
582
583
t .Run ("allow name, single allowed root field" ,
583
584
f (`{"name":"John"}` , nil , filter .WithAllowColumns ("name" )))
585
+
584
586
t .Run ("allow name, single disallowed root field" ,
585
587
f (`{"password":"hacks"}` , no ("password" ), filter .WithAllowColumns ("name" )))
588
+
586
589
t .Run ("allowed meta, single allowed nested field" ,
587
590
f (`{"map":"de_dust"}` , nil , filter .WithNestedJSONB ("meta" , "created_at" )))
591
+
588
592
t .Run ("allowed nested excemption, single allowed field" ,
589
593
f (`{"created_at":"de_dust"}` , nil , filter .WithNestedJSONB ("meta" , "created_at" )))
594
+
590
595
t .Run ("multi allow, single allowed root field" ,
591
596
f (`{"name":"John"}` , nil , filter .WithAllowColumns ("name" , "email" )))
597
+
592
598
t .Run ("multi allow, two allowed root fields" ,
593
599
f (
`{"name":"John", "email":"[email protected] "}` ,
nil ,
filter .
WithAllowColumns (
"name" ,
"email" )))
600
+
594
601
t .Run ("multi allow, mixes access" ,
595
602
f (`{"name":"John", "password":"hacks"}` , no ("password" ), filter .WithAllowColumns ("name" , "email" )))
603
+
596
604
t .Run ("multi allow, mixes access" ,
597
605
f (`{"name":"John", "password":"hacks"}` , no ("password" ), filter .WithAllowColumns ("name" , "email" )))
606
+
598
607
t .Run ("allowed basic $and" ,
599
608
f (`{"$and": [{"name": "John"}, {"version": 3}]}` , nil , filter .WithAllowColumns ("name" , "version" )))
609
+
600
610
t .Run ("disallowed basic $and" ,
601
611
f (`{"$and": [{"name": "John"}, {"version": 3}]}` , no ("version" ), filter .WithAllowColumns ("name" )))
612
+
602
613
t .Run ("allow all but one" ,
603
614
f (`{"name": "John"}` , nil , filter .WithAllowAllColumns (), filter .WithDisallowColumns ("password" )))
615
+
604
616
t .Run ("allow all but one, failing" ,
605
617
f (`{"$and": [{"name": "John"}, {"password": "hacks"}]}` , no ("password" ), filter .WithAllowAllColumns (), filter .WithDisallowColumns ("password" )))
618
+
606
619
t .Run ("nested but disallow password, allow exception" ,
607
620
f (`{"created_at": "1"}` , nil , filter .WithNestedJSONB ("meta" , "created_at" ), filter .WithDisallowColumns ("password" )))
621
+
608
622
t .Run ("nested but disallow password, allow nested" ,
609
623
f (`{"map": "de_dust"}` , nil , filter .WithNestedJSONB ("meta" , "created_at" ), filter .WithDisallowColumns ("password" )))
624
+
610
625
t .Run ("nested but disallow password, disallow" ,
611
626
f (`{"password": "hacks"}` , no ("password" ), filter .WithNestedJSONB ("meta" , "created_at" ), filter .WithDisallowColumns ("password" )))
612
627
}
0 commit comments