Search in sources :

Example 11 with UsersWithHosts

use of org.apache.accumulo.server.security.UserImpersonation.UsersWithHosts in project accumulo by apache.

the class UserImpersonationTest method testMultipleExplicitUsersHosts.

@Test
public void testMultipleExplicitUsersHosts() {
    String server = "server", host1 = "host1", host2 = "host2", host3 = "host3", client1 = "client1", client2 = "client2", client3 = "client3";
    setValidHosts(server, Joiner.on(',').join(host1, host2, host3));
    setValidUsers(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"));
}
Also used : UsersWithHosts(org.apache.accumulo.server.security.UserImpersonation.UsersWithHosts) Test(org.junit.Test)

Example 12 with UsersWithHosts

use of org.apache.accumulo.server.security.UserImpersonation.UsersWithHosts in project accumulo by apache.

the class UserImpersonationTest method testNoHostByDefaultNewConfig.

@Test
public void testNoHostByDefaultNewConfig() {
    String server = "server";
    setValidUsersNewConfig(ImmutableMap.of(server, "*"));
    UserImpersonation impersonation = new UserImpersonation(conf);
    UsersWithHosts uwh = impersonation.get(server);
    assertNotNull(uwh);
    assertFalse(uwh.acceptsAllHosts());
    assertTrue(uwh.acceptsAllUsers());
    assertNotEquals(AlwaysTrueSet.class, uwh.getHosts().getClass());
    assertEquals(AlwaysTrueSet.class, uwh.getUsers().getClass());
}
Also used : UsersWithHosts(org.apache.accumulo.server.security.UserImpersonation.UsersWithHosts) Test(org.junit.Test)

Example 13 with UsersWithHosts

use of org.apache.accumulo.server.security.UserImpersonation.UsersWithHosts in project accumulo by apache.

the class UserImpersonationTest method testMultipleExplicitUsersNewConfig.

@Test
public void testMultipleExplicitUsersNewConfig() {
    String server = "server", client1 = "client1", client2 = "client2", client3 = "client3";
    setValidHostsNewConfig(server, "*");
    setValidUsersNewConfig(ImmutableMap.of(server, Joiner.on(',').join(client1, client2, client3)));
    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());
    assertTrue(uwh.getUsers().contains(client1));
    assertTrue(uwh.getUsers().contains(client2));
    assertTrue(uwh.getUsers().contains(client3));
    assertFalse(uwh.getUsers().contains("other_client"));
}
Also used : UsersWithHosts(org.apache.accumulo.server.security.UserImpersonation.UsersWithHosts) Test(org.junit.Test)

Example 14 with UsersWithHosts

use of org.apache.accumulo.server.security.UserImpersonation.UsersWithHosts in project accumulo by apache.

the class UserImpersonationTest method testAnyUserAndHosts.

@Test
public void testAnyUserAndHosts() {
    String server = "server";
    setValidHosts(server, "*");
    setValidUsers(server, "*");
    UserImpersonation impersonation = new UserImpersonation(conf);
    UsersWithHosts uwh = impersonation.get(server);
    assertNotNull(uwh);
    assertTrue(uwh.acceptsAllHosts());
    assertTrue(uwh.acceptsAllUsers());
    assertEquals(AlwaysTrueSet.class, uwh.getHosts().getClass());
    assertEquals(AlwaysTrueSet.class, uwh.getUsers().getClass());
}
Also used : UsersWithHosts(org.apache.accumulo.server.security.UserImpersonation.UsersWithHosts) Test(org.junit.Test)

Example 15 with UsersWithHosts

use of org.apache.accumulo.server.security.UserImpersonation.UsersWithHosts in project accumulo by apache.

the class UserImpersonationTest method testAnyUserAndHostsNewConfig.

@Test
public void testAnyUserAndHostsNewConfig() {
    String server = "server";
    setValidHostsNewConfig(server, "*");
    setValidUsersNewConfig(ImmutableMap.of(server, "*"));
    UserImpersonation impersonation = new UserImpersonation(conf);
    UsersWithHosts uwh = impersonation.get(server);
    assertNotNull(uwh);
    assertTrue(uwh.acceptsAllHosts());
    assertTrue(uwh.acceptsAllUsers());
    assertEquals(AlwaysTrueSet.class, uwh.getHosts().getClass());
    assertEquals(AlwaysTrueSet.class, uwh.getUsers().getClass());
}
Also used : UsersWithHosts(org.apache.accumulo.server.security.UserImpersonation.UsersWithHosts) Test(org.junit.Test)

Aggregations

UsersWithHosts (org.apache.accumulo.server.security.UserImpersonation.UsersWithHosts)20 Test (org.junit.Test)18 DelegationTokenImpl (org.apache.accumulo.core.client.impl.DelegationTokenImpl)2 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)1 ThriftSecurityException (org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException)1 KerberosToken (org.apache.accumulo.core.client.security.tokens.KerberosToken)1 TCredentials (org.apache.accumulo.core.security.thrift.TCredentials)1