use of org.apache.accumulo.server.security.UserImpersonation.UsersWithHosts in project accumulo by apache.
the class UserImpersonationTest method testSingleUserNewConfig.
@Test
public void testSingleUserNewConfig() throws Exception {
final String server = "server/hostname@EXAMPLE.COM", client = "client@EXAMPLE.COM";
cc.set(Property.INSTANCE_RPC_SASL_ALLOWED_USER_IMPERSONATION, server + ":" + client);
cc.set(Property.INSTANCE_RPC_SASL_ALLOWED_HOST_IMPERSONATION, "*");
UserImpersonation impersonation = new UserImpersonation(conf);
UsersWithHosts uwh = impersonation.get(server);
assertNotNull(uwh);
assertTrue(uwh.acceptsAllHosts());
assertFalse(uwh.acceptsAllUsers());
assertTrue(uwh.getUsers().contains(client));
}
use of org.apache.accumulo.server.security.UserImpersonation.UsersWithHosts in project accumulo by apache.
the class UserImpersonationTest method testNoUsersByDefaultNewConfig.
@Test
public void testNoUsersByDefaultNewConfig() {
String server = "server";
setValidHostsNewConfig(server, "*");
UserImpersonation impersonation = new UserImpersonation(conf);
UsersWithHosts uwh = impersonation.get(server);
assertNull("Impersonation config should be drive by user element, not host", uwh);
}
use of org.apache.accumulo.server.security.UserImpersonation.UsersWithHosts in project accumulo by apache.
the class UserImpersonationTest method testNoUsersByDefault.
@Test
public void testNoUsersByDefault() {
String server = "server";
setValidHosts(server, "*");
UserImpersonation impersonation = new UserImpersonation(conf);
UsersWithHosts uwh = impersonation.get(server);
assertNotNull(uwh);
assertTrue(uwh.acceptsAllHosts());
assertFalse(uwh.acceptsAllUsers());
assertEquals(AlwaysTrueSet.class, uwh.getHosts().getClass());
assertNotEquals(AlwaysTrueSet.class, uwh.getUsers().getClass());
}
use of org.apache.accumulo.server.security.UserImpersonation.UsersWithHosts in project accumulo by apache.
the class UserImpersonationTest method testSingleUserAndHostNewConfig.
@Test
public void testSingleUserAndHostNewConfig() {
String server = "server", host = "single_host.domain.com", client = "single_client";
setValidHostsNewConfig(server, host);
setValidUsersNewConfig(ImmutableMap.of(server, client));
UserImpersonation impersonation = new UserImpersonation(conf);
UsersWithHosts uwh = impersonation.get(server);
assertNotNull(uwh);
assertFalse(uwh.acceptsAllHosts());
assertFalse(uwh.acceptsAllUsers());
assertNotEquals(AlwaysTrueSet.class, uwh.getHosts().getClass());
assertNotEquals(AlwaysTrueSet.class, uwh.getUsers().getClass());
assertTrue(uwh.getUsers().contains(client));
assertTrue(uwh.getHosts().contains(host));
assertFalse(uwh.getUsers().contains("some_other_user"));
assertFalse(uwh.getHosts().contains("other_host.domain.com"));
}
use of org.apache.accumulo.server.security.UserImpersonation.UsersWithHosts in project accumulo by apache.
the class UserImpersonationTest method testMultipleExplicitUsersHostsNewConfig.
@Test
public void testMultipleExplicitUsersHostsNewConfig() {
String server = "server", host1 = "host1", host2 = "host2", host3 = "host3", client1 = "client1", client2 = "client2", client3 = "client3";
setValidHostsNewConfig(server, Joiner.on(',').join(host1, host2, host3));
setValidUsersNewConfig(ImmutableMap.of(server, Joiner.on(',').join(client1, client2, client3)));
UserImpersonation impersonation = new UserImpersonation(conf);
UsersWithHosts uwh = impersonation.get(server);
assertNotNull(uwh);
assertFalse(uwh.acceptsAllHosts());
assertFalse(uwh.acceptsAllUsers());
assertNotEquals(AlwaysTrueSet.class, uwh.getHosts().getClass());
assertNotEquals(AlwaysTrueSet.class, uwh.getUsers().getClass());
assertTrue(uwh.getUsers().contains(client1));
assertTrue(uwh.getUsers().contains(client2));
assertTrue(uwh.getUsers().contains(client3));
assertFalse(uwh.getUsers().contains("other_client"));
assertTrue(uwh.getHosts().contains(host1));
assertTrue(uwh.getHosts().contains(host2));
assertTrue(uwh.getHosts().contains(host3));
assertFalse(uwh.getHosts().contains("other_host"));
}
Aggregations