Search in sources :

Example 36 with Authorizations

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));
    }
}
Also used : Authorizations(org.apache.accumulo.core.security.Authorizations) ByteArraySet(org.apache.accumulo.core.util.ByteArraySet) Test(org.junit.Test)

Example 37 with Authorizations

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);
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) CommandLine(org.apache.commons.cli.CommandLine) Shell(org.apache.accumulo.shell.Shell) Authorizations(org.apache.accumulo.core.security.Authorizations) LineReader(org.jline.reader.LineReader) SecurityOperations(org.apache.accumulo.core.client.admin.SecurityOperations) Test(org.junit.Test)

Example 38 with Authorizations

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);
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) CommandLine(org.apache.commons.cli.CommandLine) Shell(org.apache.accumulo.shell.Shell) Authorizations(org.apache.accumulo.core.security.Authorizations) LineReader(org.jline.reader.LineReader) SecurityOperations(org.apache.accumulo.core.client.admin.SecurityOperations) Test(org.junit.Test)

Example 39 with Authorizations

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);
}
Also used : AccumuloClient(org.apache.accumulo.core.client.AccumuloClient) CommandLine(org.apache.commons.cli.CommandLine) Shell(org.apache.accumulo.shell.Shell) Authorizations(org.apache.accumulo.core.security.Authorizations) LineReader(org.jline.reader.LineReader) SecurityOperations(org.apache.accumulo.core.client.admin.SecurityOperations) Test(org.junit.Test)

Example 40 with Authorizations

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");
}
Also used : Authorizations(org.apache.accumulo.core.security.Authorizations) Test(org.junit.Test)

Aggregations

Authorizations (org.apache.accumulo.core.security.Authorizations)242 Test (org.junit.Test)118 Scanner (org.apache.accumulo.core.client.Scanner)117 Key (org.apache.accumulo.core.data.Key)113 Value (org.apache.accumulo.core.data.Value)112 Text (org.apache.hadoop.io.Text)97 Mutation (org.apache.accumulo.core.data.Mutation)74 BatchWriter (org.apache.accumulo.core.client.BatchWriter)70 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)68 Range (org.apache.accumulo.core.data.Range)59 Map (java.util.Map)53 Entry (java.util.Map.Entry)47 PasswordToken (org.apache.accumulo.core.client.security.tokens.PasswordToken)39 Connector (org.apache.accumulo.core.client.Connector)34 ArrayList (java.util.ArrayList)31 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)30 AccumuloClient (org.apache.accumulo.core.client.AccumuloClient)29 AccumuloException (org.apache.accumulo.core.client.AccumuloException)28 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)26 Configuration (org.apache.hadoop.conf.Configuration)24