@ -99,29 +99,7 @@ class RbacServiceConfigParsingTest : public ::testing::Test {
std : : map < absl : : string_view , std : : string > logger_configs_ ;
} ;
// Filter name is required in RBAC policy.
TEST_F ( RbacServiceConfigParsingTest , EmptyRbacPolicy ) {
const char * test_json =
" { \n "
" \" methodConfig \" : [ { \n "
" \" name \" : [ \n "
" {} \n "
" ], \n "
" \" rbacPolicy \" : [ { \n "
" } ] "
" } ] \n "
" } " ;
ChannelArgs args = ChannelArgs ( ) . Set ( GRPC_ARG_PARSE_RBAC_METHOD_CONFIG , 1 ) ;
auto service_config = ServiceConfigImpl : : Create ( args , test_json ) ;
EXPECT_EQ ( service_config . status ( ) . code ( ) , absl : : StatusCode : : kInvalidArgument ) ;
EXPECT_EQ ( service_config . status ( ) . message ( ) ,
" errors validating service config: [ "
" field:methodConfig[0].rbacPolicy[0].filter_name error:field not "
" present] " )
< < service_config . status ( ) ;
}
// Test basic parsing of RBAC policy
// Test parsing of an empty RBAC policy
TEST_F ( RbacServiceConfigParsingTest , RbacPolicyWithoutRules ) {
const char * test_json =
" { \n "
@ -129,7 +107,7 @@ TEST_F(RbacServiceConfigParsingTest, RbacPolicyWithoutRules) {
" \" name \" : [ \n "
" {} \n "
" ], \n "
" \" rbacPolicy \" : [ { \" filter_name \" : \" rbac \" } ] \n "
" \" rbacPolicy \" : [ {} ] \n "
" } ] \n "
" } " ;
ChannelArgs args = ChannelArgs ( ) . Set ( GRPC_ARG_PARSE_RBAC_METHOD_CONFIG , 1 ) ;
@ -201,9 +179,9 @@ TEST_F(RbacServiceConfigParsingTest, MultipleRbacPolicies) {
" {} \n "
" ], \n "
" \" rbacPolicy \" : [ \n "
" { \" filter_name \" : \" rbac-1 \" }, \n "
" { \" filter_name \" : \" rbac-2 \" }, \n "
" { \" filter_name \" : \" rbac-3 \" } \n "
" {}, \n "
" {}, \n "
" {} \n "
" ] "
" } ] \n "
" } " ;
@ -250,7 +228,7 @@ TEST_F(RbacServiceConfigParsingTest, BadRulesType) {
" \" name \" : [ \n "
" {} \n "
" ], \n "
" \" rbacPolicy \" : [{ \" filter_name \" : \" rbac \" , \" rules \" :1}] \n "
" \" rbacPolicy \" : [{ \" rules \" :1}] \n "
" } ] \n "
" } " ;
ChannelArgs args = ChannelArgs ( ) . Set ( GRPC_ARG_PARSE_RBAC_METHOD_CONFIG , 1 ) ;
@ -270,7 +248,6 @@ TEST_F(RbacServiceConfigParsingTest, BadActionAndPolicyType) {
" {} \n "
" ], \n "
" \" rbacPolicy \" : [{ \n "
" \" filter_name \" : \" rbac \" , \n "
" \" rules \" :{ \n "
" \" action \" :{}, \n "
" \" policies \" :123 \n "
@ -298,7 +275,6 @@ TEST_F(RbacServiceConfigParsingTest, MissingPermissionAndPrincipals) {
" {} \n "
" ], \n "
" \" rbacPolicy \" : [{ \n "
" \" filter_name \" : \" rbac \" , \n "
" \" rules \" :{ \n "
" \" action \" :1, \n "
" \" policies \" :{ \n "
@ -329,7 +305,6 @@ TEST_F(RbacServiceConfigParsingTest, EmptyPrincipalAndPermission) {
" {} \n "
" ], \n "
" \" rbacPolicy \" : [{ \n "
" \" filter_name \" : \" rbac \" , \n "
" \" rules \" :{ \n "
" \" action \" :1, \n "
" \" policies \" :{ \n "
@ -362,7 +337,6 @@ TEST_F(RbacServiceConfigParsingTest, VariousPermissionsAndPrincipalsTypes) {
" {} \n "
" ], \n "
" \" rbacPolicy \" : [{ \n "
" \" filter_name \" : \" rbac \" , \n "
" \" rules \" :{ \n "
" \" action \" :1, \n "
" \" policies \" :{ \n "
@ -420,7 +394,6 @@ TEST_F(RbacServiceConfigParsingTest, VariousPermissionsAndPrincipalsBadTypes) {
" {} \n "
" ], \n "
" \" rbacPolicy \" : [{ \n "
" \" filter_name \" : \" rbac \" , \n "
" \" rules \" :{ \n "
" \" action \" :1, \n "
" \" policies \" :{ \n "
@ -515,7 +488,6 @@ TEST_F(RbacServiceConfigParsingTest, HeaderMatcherVariousTypes) {
" {} \n "
" ], \n "
" \" rbacPolicy \" : [{ \n "
" \" filter_name \" : \" rbac \" , \n "
" \" rules \" :{ \n "
" \" action \" :1, \n "
" \" policies \" :{ \n "
@ -560,7 +532,6 @@ TEST_F(RbacServiceConfigParsingTest, HeaderMatcherBadTypes) {
" {} \n "
" ], \n "
" \" rbacPolicy \" : [{ \n "
" \" filter_name \" : \" rbac \" , \n "
" \" rules \" :{ \n "
" \" action \" :1, \n "
" \" policies \" :{ \n "
@ -617,7 +588,6 @@ TEST_F(RbacServiceConfigParsingTest, StringMatcherVariousTypes) {
" {} \n "
" ], \n "
" \" rbacPolicy \" : [{ \n "
" \" filter_name \" : \" rbac \" , \n "
" \" rules \" :{ \n "
" \" action \" :1, \n "
" \" policies \" :{ \n "
@ -659,7 +629,6 @@ TEST_F(RbacServiceConfigParsingTest, StringMatcherBadTypes) {
" {} \n "
" ], \n "
" \" rbacPolicy \" : [{ \n "
" \" filter_name \" : \" rbac \" , \n "
" \" rules \" :{ \n "
" \" action \" :1, \n "
" \" policies \" :{ \n "
@ -715,7 +684,6 @@ TEST_F(RbacServiceConfigParsingTest, AuditConditionOnDenyWithMultipleLoggers) {
" {} \n "
" ], \n "
" \" rbacPolicy \" : [ { \n "
" \" filter_name \" : \" rbac \" , \n "
" \" rules \" :{ \n "
" \" action \" :1, \n "
" \" audit_condition \" :1, \n "
@ -760,7 +728,6 @@ TEST_F(RbacServiceConfigParsingTest, BadAuditLoggerConfig) {
" {} \n "
" ], \n "
" \" rbacPolicy \" : [ { \n "
" \" filter_name \" : \" rbac \" , \n "
" \" rules \" :{ \n "
" \" action \" :1, \n "
" \" audit_condition \" :1, \n "
@ -791,7 +758,6 @@ TEST_F(RbacServiceConfigParsingTest, UnknownAuditLoggerConfig) {
" {} \n "
" ], \n "
" \" rbacPolicy \" : [ { \n "
" \" filter_name \" : \" rbac \" , \n "
" \" rules \" :{ \n "
" \" action \" :1, \n "
" \" audit_condition \" :1, \n "
@ -822,7 +788,6 @@ TEST_F(RbacServiceConfigParsingTest, BadAuditConditionAndLoggersTypes) {
" {} \n "
" ], \n "
" \" rbacPolicy \" : [ { \n "
" \" filter_name \" : \" rbac \" , \n "
" \" rules \" :{ \n "
" \" action \" :1, \n "
" \" audit_condition \" :{}, \n "
@ -851,7 +816,6 @@ TEST_F(RbacServiceConfigParsingTest, BadAuditConditionEnum) {
" {} \n "
" ], \n "
" \" rbacPolicy \" : [ { \n "
" \" filter_name \" : \" rbac \" , \n "
" \" rules \" :{ \n "
" \" action \" :1, \n "
" \" audit_condition \" :100 \n "