use of org.apache.accumulo.core.security.Authorizations in project accumulo by apache.
the class ZKAuthenticatorTest method testAuthorizationConversion.
@Test
public void testAuthorizationConversion() {
ByteArraySet auths = new ByteArraySet();
for (int i = 0; i < 300; i += 3) auths.add(Integer.toString(i).getBytes());
Authorizations converted = new Authorizations(auths);
byte[] test = ZKSecurityTool.convertAuthorizations(converted);
Authorizations test2 = ZKSecurityTool.convertAuthorizations(test);
assertEquals(auths.size(), test2.size());
for (byte[] s : auths) {
assertTrue(test2.contains(s));
}
}
use of org.apache.accumulo.core.security.Authorizations in project accumulo by apache.
the class DeleteAuthsCommandTest method deleteNonExistingAuth.
@Test
public void deleteNonExistingAuth() throws Exception {
AccumuloClient client = EasyMock.createMock(AccumuloClient.class);
CommandLine cli = EasyMock.createMock(CommandLine.class);
Shell shellState = EasyMock.createMock(Shell.class);
LineReader reader = EasyMock.createMock(LineReader.class);
SecurityOperations secOps = EasyMock.createMock(SecurityOperations.class);
EasyMock.expect(shellState.getAccumuloClient()).andReturn(client);
// We're the root user
EasyMock.expect(client.whoami()).andReturn("root");
EasyMock.expect(cli.getOptionValue("u", "root")).andReturn("foo");
EasyMock.expect(cli.getOptionValue("s")).andReturn("def");
EasyMock.expect(client.securityOperations()).andReturn(secOps);
EasyMock.expect(client.securityOperations()).andReturn(secOps);
EasyMock.expect(secOps.getUserAuthorizations("foo")).andReturn(new Authorizations("abc", "123"));
secOps.changeUserAuthorizations("foo", new Authorizations("abc", "123"));
EasyMock.expectLastCall();
EasyMock.replay(client, cli, shellState, reader, secOps);
cmd.execute("deleteauths -u foo -s def", cli, shellState);
EasyMock.verify(client, cli, shellState, reader, secOps);
}
use of org.apache.accumulo.core.security.Authorizations in project accumulo by apache.
the class DeleteAuthsCommandTest method deleteAllAuth.
@Test
public void deleteAllAuth() throws Exception {
AccumuloClient client = EasyMock.createMock(AccumuloClient.class);
CommandLine cli = EasyMock.createMock(CommandLine.class);
Shell shellState = EasyMock.createMock(Shell.class);
LineReader reader = EasyMock.createMock(LineReader.class);
SecurityOperations secOps = EasyMock.createMock(SecurityOperations.class);
EasyMock.expect(shellState.getAccumuloClient()).andReturn(client);
// We're the root user
EasyMock.expect(client.whoami()).andReturn("root");
EasyMock.expect(cli.getOptionValue("u", "root")).andReturn("foo");
EasyMock.expect(cli.getOptionValue("s")).andReturn("abc,123");
EasyMock.expect(client.securityOperations()).andReturn(secOps);
EasyMock.expect(client.securityOperations()).andReturn(secOps);
EasyMock.expect(secOps.getUserAuthorizations("foo")).andReturn(new Authorizations("abc", "123"));
secOps.changeUserAuthorizations("foo", new Authorizations());
EasyMock.expectLastCall();
EasyMock.replay(client, cli, shellState, reader, secOps);
cmd.execute("deleteauths -u foo -s abc,123", cli, shellState);
EasyMock.verify(client, cli, shellState, reader, secOps);
}
use of org.apache.accumulo.core.security.Authorizations in project accumulo by apache.
the class DeleteAuthsCommandTest method deleteExistingAuth.
@Test
public void deleteExistingAuth() throws Exception {
AccumuloClient client = EasyMock.createMock(AccumuloClient.class);
CommandLine cli = EasyMock.createMock(CommandLine.class);
Shell shellState = EasyMock.createMock(Shell.class);
LineReader reader = EasyMock.createMock(LineReader.class);
SecurityOperations secOps = EasyMock.createMock(SecurityOperations.class);
EasyMock.expect(shellState.getAccumuloClient()).andReturn(client);
// We're the root user
EasyMock.expect(client.whoami()).andReturn("root");
EasyMock.expect(cli.getOptionValue("u", "root")).andReturn("foo");
EasyMock.expect(cli.getOptionValue("s")).andReturn("abc");
EasyMock.expect(client.securityOperations()).andReturn(secOps);
EasyMock.expect(client.securityOperations()).andReturn(secOps);
EasyMock.expect(secOps.getUserAuthorizations("foo")).andReturn(new Authorizations("abc", "123"));
secOps.changeUserAuthorizations("foo", new Authorizations("123"));
EasyMock.expectLastCall();
EasyMock.replay(client, cli, shellState, reader, secOps);
cmd.execute("deleteauths -u foo -s abc", cli, shellState);
EasyMock.verify(client, cli, shellState, reader, secOps);
}
use of org.apache.accumulo.core.security.Authorizations in project accumulo by apache.
the class GetAuthsCommandTest method removeAccumuloNamespaceTables.
@Test
public void removeAccumuloNamespaceTables() {
Authorizations auths = new Authorizations("AAA", "aaa", "bbb", "BBB");
GetAuthsCommand cmd = new GetAuthsCommand();
List<String> sorted = cmd.sortAuthorizations(auths);
assertNotNull(sorted);
assertEquals(sorted.size(), 4);
assertEquals(sorted.get(0), "AAA");
assertEquals(sorted.get(1), "aaa");
assertEquals(sorted.get(2), "BBB");
assertEquals(sorted.get(3), "bbb");
}
Aggregations