### Question:
ProxyUserService extends BaseService implements ProxyUser { private void validateGroup(String proxyUser, String user, Set<String> validGroups) throws IOException, AccessControlException { if (validGroups != null) { List<String> userGroups = getServer().get(Groups.class).getGroups(user); for (String g : validGroups) { if (userGroups.contains(g)) { return; } } throw new AccessControlException( MessageFormat.format("Unauthorized proxyuser [{0}] for user [{1}], not in proxyuser groups", proxyUser, user)); } } ProxyUserService(); @Override Class getInterface(); @Override Class[] getServiceDependencies(); @Override void validate(String proxyUser, String proxyHost, String doAsUser);  }### Answer:
@Test @TestDir public void validateGroup() throws Exception { String dir = TestDirHelper.getTestDir().getAbsolutePath(); Configuration conf = new Configuration(false); conf.set("server.services", StringUtils.join(",", Arrays.asList(GroupsService.class.getName(), ProxyUserService.class.getName()))); conf.set("server.proxyuser.foo.hosts", "*"); conf.set("server.proxyuser.foo.groups", getGroup()); Server server = new Server("server", dir, dir, dir, dir, conf); server.init(); ProxyUser proxyUser = server.get(ProxyUser.class); assertNotNull(proxyUser); proxyUser.validate("foo", "localhost", System.getProperty("user.name")); server.destroy(); }