@Test
  public void testReadOnlyOperations()
      throws IOException, InstanceNotFoundException, ReflectionException, MBeanException {
    ManagementService service =
        ManagementService.getExistingManagementService(GemFireCacheImpl.getInstance());
    String accessFileName = createAccessFile();
    String passwordFileName = createPasswordFile();
    createConnector(accessFileName, passwordFileName);

    MBeanServerConnection server = connectToRmiConnector();
    DistributedMember member = cache.getMyId();

    assertNotNull(server.invoke(service.getMemberMBeanName(member), "listRegions", null, null));
    assertNotNull(
        server.invoke(service.getMemberMBeanName(member), "listGemFireProperties", null, null));
    assertNotNull(server.invoke(service.getMemberMBeanName(member), "listConnectedGatewayReceivers",
        null, null));
    assertNotNull(server.invoke(service.getMemberMBeanName(member), "listConnectedGatewaySenders",
        null, null));

    assertNotNull(server.invoke(service.getMemberMBeanName(member), "showJVMMetrics", null, null));
    assertNotNull(server.invoke(service.getMemberMBeanName(member), "showOSMetrics", null, null));

    assertNotNull(server.invoke(service.getMemberMBeanName(member), "fetchJvmThreads", null, null));

    assertNotNull(server.invoke(service.getMemberMBeanName(member), "viewLicense", null, null));

    // TODO QueryData : Start Manager fails due to #50280 : Can not start manager inside a loner
    try {
      server.invoke(service.getMemberMBeanName(member), "compactAllDiskStores", null, null);
      fail("Admin operation accessible to readonly user");
    } catch (SecurityException e) {
      // ok
    }

  }
Test ReadOnly operations are accesible from RMI Connector with readOnly user
geode-core/src/integrationTest/java/org/apache/geode/management/internal/unsafe/ReadOpFileAccessControllerJUnitTest.java