use of org.apache.geode.test.dunit.rules.ConnectionConfiguration in project geode by apache.
the class MBeanSecurityJUnitTest method testNoAccessWithWhoever.
/**
* No user can call createBean or unregisterBean of GemFire Domain
*/
@Test
@ConnectionConfiguration(user = "super-user", password = "1234567")
public void testNoAccessWithWhoever() throws Exception {
MBeanServerConnection con = connectionRule.getMBeanServerConnection();
assertThatThrownBy(() -> con.createMBean("FakeClassName", new ObjectName("GemFire", "name", "foo"))).isInstanceOf(SecurityException.class);
assertThatThrownBy(() -> con.unregisterMBean(new ObjectName("GemFire", "name", "foo"))).isInstanceOf(SecurityException.class);
// user is allowed to create beans of other domains
assertThatThrownBy(() -> con.createMBean("FakeClassName", new ObjectName("OtherDomain", "name", "foo"))).isInstanceOf(ReflectionException.class);
}
use of org.apache.geode.test.dunit.rules.ConnectionConfiguration in project geode by apache.
the class MBeanSecurityJUnitTest method testQueryBean.
/**
* looks like everyone can query for beans, but the AccessControlMXBean is filtered from the
* result
*/
@Test
@ConnectionConfiguration(user = "stranger", password = "1234567")
public void testQueryBean() throws MalformedObjectNameException, IOException {
MBeanServerConnection con = connectionRule.getMBeanServerConnection();
Set<ObjectInstance> objects = con.queryMBeans(ObjectName.getInstance(ResourceConstants.OBJECT_NAME_ACCESSCONTROL), null);
// no AccessControlMBean in the query result
assertThat(objects.size()).isEqualTo(0);
objects = con.queryMBeans(ObjectName.getInstance("GemFire:service=CacheServer,*"), null);
assertThat(objects.size()).isEqualTo(1);
}
use of org.apache.geode.test.dunit.rules.ConnectionConfiguration in project geode by apache.
the class MBeanSecurityJUnitTest method testServerSideCalls.
@Test
@ConnectionConfiguration(user = "stranger", password = "1234567")
public void testServerSideCalls() {
// calls through ManagementService is not going through authorization checks
ManagementService service = ManagementService.getManagementService(server.getCache());
MemberMXBean bean = service.getMemberMXBean();
bean.compactAllDiskStores();
}
Aggregations