use of org.apache.servicecomb.authentication.provider.AccessController in project java-chassis by ServiceComb.
the class TestAccessController method testIsValidOfBlackAndWhiteByServiceName.
@Test
public void testIsValidOfBlackAndWhiteByServiceName() {
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.white.list1.propertyName", "serviceName");
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.white.list1.category", "property");
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.white.list1.rule", "trust*");
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", "*hacker");
AccessController controller = new AccessController();
Microservice service = new Microservice();
service.setServiceName("trustCustomer");
Assert.assertTrue(controller.isAllowed(service));
service.setServiceName("trustCustomerhacker");
Assert.assertTrue(!controller.isAllowed(service));
}
use of org.apache.servicecomb.authentication.provider.AccessController in project java-chassis by ServiceComb.
the class TestAccessController method testIsValidOfBlackAndWhiteByServiceNameAndVersion.
@Test
public void testIsValidOfBlackAndWhiteByServiceNameAndVersion() {
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.white.list1.propertyName", "serviceName");
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.white.list1.category", "property");
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.white.list1.rule", "trust*");
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.black.list1.propertyName", "version");
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.black.list1.category", "property");
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.black.list1.rule", "0.0.1");
AccessController controller = new AccessController();
Microservice service = new Microservice();
service.setServiceName("trustCustomer");
service.setVersion("0.0.1");
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 testIsValidOfBlackAndWhiteByServiceName.
@Test
public void testIsValidOfBlackAndWhiteByServiceName() {
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.white.list1.propertyName", "serviceName");
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.white.list1.category", "property");
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.white.list1.rule", "trust*");
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", "*hacker");
AccessController controller = new AccessController();
Microservice service = new Microservice();
service.setServiceName("trustCustomer");
Assert.assertTrue(controller.isAllowed(service));
service.setServiceName("trustCustomerhacker");
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 testIsValidOfWhiteByProperties.
@Test
public void testIsValidOfWhiteByProperties() {
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.white.list1.propertyName", "tag");
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.white.list1.category", "property");
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.white.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));
}
use of org.apache.servicecomb.authentication.provider.AccessController in project incubator-servicecomb-java-chassis by apache.
the class TestAccessController method testIsValidOfWhiteByServiceName.
@Test
public void testIsValidOfWhiteByServiceName() {
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.white.list1.propertyName", "serviceName");
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.white.list1.category", "property");
ArchaiusUtils.setProperty("servicecomb.publicKey.accessControl.white.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.white.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.white.list1.rule", "trust");
service.setServiceName("trust");
Assert.assertTrue(controller.isAllowed(service));
service.setServiceName("Customer_trust");
Assert.assertTrue(!controller.isAllowed(service));
}
Aggregations