Github user saandrews commented on a diff in the pull request:
https://github.com/apache/incubator-pulsar/pull/530#discussion_r124101111
--- Diff:
pulsar-broker/src/test/java/org/apache/pulsar/broker/auth/AuthorizationTest.java
---
@@ -94,6 +96,46 @@ void simple() throws Exception {
assertEquals(auth.canProduce(DestinationName.get("persistent://p1/c1/ns1/ds1"),
"my-role"), true);
assertEquals(auth.canConsume(DestinationName.get("persistent://p1/c1/ns1/ds1"),
"my-role"), true);
+ // test for wildcard
+
assertEquals(auth.canLookup(DestinationName.get("persistent://p1/c1/ns1/ds1"),
"my.role.1"), false);
+
assertEquals(auth.canLookup(DestinationName.get("persistent://p1/c1/ns1/ds1"),
"my.role.2"), false);
+
assertEquals(auth.canProduce(DestinationName.get("persistent://p1/c1/ns1/ds1"),
"my.role.1"), false);
+
assertEquals(auth.canConsume(DestinationName.get("persistent://p1/c1/ns1/ds1"),
"my.role.1"), false);
+
assertEquals(auth.canLookup(DestinationName.get("persistent://p1/c1/ns1/ds1"),
"other.role.1"), false);
+
assertEquals(auth.canLookup(DestinationName.get("persistent://p1/c1/ns1/ds1"),
"other.role.2"), false);
+
+ admin.namespaces().grantPermissionOnNamespace("p1/c1/ns1",
"my.role.*", EnumSet.of(AuthAction.produce));
+ waitForChange();
+
+
assertEquals(auth.canLookup(DestinationName.get("persistent://p1/c1/ns1/ds1"),
"my.role.1"), true);
+
assertEquals(auth.canLookup(DestinationName.get("persistent://p1/c1/ns1/ds1"),
"my.role.2"), true);
+
assertEquals(auth.canProduce(DestinationName.get("persistent://p1/c1/ns1/ds1"),
"my.role.1"), true);
+
assertEquals(auth.canConsume(DestinationName.get("persistent://p1/c1/ns1/ds1"),
"my.role.1"), false);
+
assertEquals(auth.canLookup(DestinationName.get("persistent://p1/c1/ns1/ds1"),
"other.role.1"), false);
+
assertEquals(auth.canLookup(DestinationName.get("persistent://p1/c1/ns1/ds1"),
"other.role.2"), false);
+
+
assertEquals(auth.canLookup(DestinationName.get("persistent://p1/c1/ns1/ds1"),
"1.role.my"), false);
+
assertEquals(auth.canLookup(DestinationName.get("persistent://p1/c1/ns1/ds1"),
"2.role.my"), false);
+
assertEquals(auth.canProduce(DestinationName.get("persistent://p1/c1/ns1/ds1"),
"1.role.my"), false);
+
assertEquals(auth.canConsume(DestinationName.get("persistent://p1/c1/ns1/ds1"),
"1.role.my"), false);
+
assertEquals(auth.canLookup(DestinationName.get("persistent://p1/c1/ns1/ds1"),
"2.role.other"), false);
+
assertEquals(auth.canLookup(DestinationName.get("persistent://p1/c1/ns1/ds1"),
"2.role.other"), false);
+
assertEquals(auth.canLookup(DestinationName.get("persistent://p1/c1/ns1/ds2"),
"1.role.my"), false);
+
assertEquals(auth.canLookup(DestinationName.get("persistent://p1/c1/ns1/ds2"),
"2.role.my"), false);
+
+
admin.persistentTopics().grantPermission("persistent://p1/c1/ns1/ds1", "*.my",
--- End diff --
We need to add a case to cover prefix match as well?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---