use of org.apache.servicecomb.authentication.provider.AccessController in project incubator-servicecomb-java-chassis by apache.
the class TestAccessController method testIsValidOfBlackByServiceName.
@Test
public void testIsValidOfBlackByServiceName() {
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.black.list1.propertyName", "serviceName");
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.black.list1.category", "property");
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.black.list1.rule", "trust*");
AccessController controller = new AccessController();
Microservice service = new Microservice();
service.setServiceName("trustCustomer");
Assert.assertTrue(!controller.isAllowed(service));
service.setServiceName("nottrustCustomer");
Assert.assertTrue(controller.isAllowed(service));
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.black.list1.rule", "*trust");
service.setServiceName("Customer_trust");
Assert.assertTrue(!controller.isAllowed(service));
service.setServiceName("Customer_trust_not");
Assert.assertTrue(controller.isAllowed(service));
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.black.list1.rule", "trust");
service.setServiceName("trust");
Assert.assertTrue(!controller.isAllowed(service));
service.setServiceName("Customer_trust");
Assert.assertTrue(controller.isAllowed(service));
}
use of org.apache.servicecomb.authentication.provider.AccessController in project incubator-servicecomb-java-chassis by apache.
the class TestAccessController method testIsValidOfBlackByProperties.
@Test
public void testIsValidOfBlackByProperties() {
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.black.list1.propertyName", "tag");
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.black.list1.category", "property");
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.black.list1.rule", "test");
AccessController controller = new AccessController();
Microservice service = new Microservice();
Map<String, String> map = new HashMap<>();
map.put("tag", "test");
service.setProperties(map);
Assert.assertTrue(!controller.isAllowed(service));
map.put("tag", "testa");
service.setProperties(map);
Assert.assertTrue(controller.isAllowed(service));
}
Aggregations