@@ -311,7 +311,6 @@ public void evaluate8() {
311311 Acl acl = AuthTestHelper .buildAcl ("User:test" , "Topic:test*" , "Pub" , "192.168.0.0/24" , Decision .DENY );
312312 this .authorizationMetadataManager .createAcl (acl ).join ();
313313
314-
315314 Assert .assertThrows (AuthorizationException .class , () -> {
316315 Subject subject = Subject .of ("User:test" );
317316 Resource resource = Resource .ofTopic ("test" );
@@ -345,6 +344,46 @@ public void evaluate8() {
345344 }
346345 }
347346
347+ @ Test
348+ public void evaluate9 () {
349+ if (MixAll .isMac ()) {
350+ return ;
351+ }
352+ User user = User .of ("test" , "test" );
353+ this .authenticationMetadataManager .createUser (user ).join ();
354+
355+ Acl acl0 = AuthTestHelper .buildAcl ("User:test" , "*" , "Pub" , "192.168.0.0/24" , Decision .ALLOW );
356+ this .authorizationMetadataManager .createAcl (acl0 ).join ();
357+ Acl acl1 = AuthTestHelper .buildAcl ("User:test" , "Topic:*" , "Pub" , "192.168.0.0/24" , Decision .ALLOW );
358+ this .authorizationMetadataManager .createAcl (acl1 ).join ();
359+ Acl acl2 = AuthTestHelper .buildAcl ("User:test" , "Topic:test*" , "Pub" , "192.168.0.0/24" , Decision .ALLOW );
360+ this .authorizationMetadataManager .createAcl (acl2 ).join ();
361+ Acl acl3 = AuthTestHelper .buildAcl ("User:test" , "Topic:test_*" , "Pub" , "192.168.0.0/24" , Decision .DENY );
362+ this .authorizationMetadataManager .createAcl (acl3 ).join ();
363+ Acl acl4 = AuthTestHelper .buildAcl ("User:test" , "Topic:test_001" , "Pub" , "192.168.0.0/24" , Decision .DENY );
364+ this .authorizationMetadataManager .createAcl (acl4 ).join ();
365+
366+ Assert .assertThrows (AuthorizationException .class , () -> {
367+ Subject subject = Subject .of ("User:test" );
368+ Resource resource = Resource .ofTopic ("test_001" );
369+ Action action = Action .PUB ;
370+ String sourceIp = "192.168.0.1" ;
371+ DefaultAuthorizationContext context = DefaultAuthorizationContext .of (subject , resource , action , sourceIp );
372+ context .setRpcCode ("10" );
373+ this .evaluator .evaluate (Collections .singletonList (context ));
374+ });
375+
376+ Assert .assertThrows (AuthorizationException .class , () -> {
377+ Subject subject = Subject .of ("User:test" );
378+ Resource resource = Resource .ofTopic ("test_002" );
379+ Action action = Action .PUB ;
380+ String sourceIp = "192.168.0.1" ;
381+ DefaultAuthorizationContext context = DefaultAuthorizationContext .of (subject , resource , action , sourceIp );
382+ context .setRpcCode ("10" );
383+ this .evaluator .evaluate (Collections .singletonList (context ));
384+ });
385+ }
386+
348387 private void clearAllUsers () {
349388 List <User > users = this .authenticationMetadataManager .listUser (null ).join ();
350389 if (CollectionUtils .isEmpty (users )) {
0 commit comments