Search in sources :

Example 6 with UsersMetadata

use of io.crate.user.metadata.UsersMetadata in project crate by crate.

the class TransportUserActionTest method testCreateUser.

@Test
public void testCreateUser() throws Exception {
    Metadata.Builder mdBuilder = new Metadata.Builder().putCustom(UsersMetadata.TYPE, new UsersMetadata(UserDefinitions.SINGLE_USER_ONLY));
    TransportCreateUserAction.putUser(mdBuilder, "Trillian", null);
    UsersMetadata newMetadata = (UsersMetadata) mdBuilder.getCustom(UsersMetadata.TYPE);
    assertThat(newMetadata.userNames(), containsInAnyOrder("Trillian", "Arthur"));
}
Also used : UsersMetadata(io.crate.user.metadata.UsersMetadata) Metadata(org.elasticsearch.cluster.metadata.Metadata) UsersMetadata(io.crate.user.metadata.UsersMetadata) UsersPrivilegesMetadata(io.crate.user.metadata.UsersPrivilegesMetadata) Test(org.junit.Test)

Example 7 with UsersMetadata

use of io.crate.user.metadata.UsersMetadata in project crate by crate.

the class TransportUserActionTest method testCreateUserAlreadyExists.

@Test
public void testCreateUserAlreadyExists() throws Exception {
    Metadata.Builder mdBuilder = new Metadata.Builder().putCustom(UsersMetadata.TYPE, new UsersMetadata(UserDefinitions.SINGLE_USER_ONLY));
    assertThat(TransportCreateUserAction.putUser(mdBuilder, "Arthur", null), is(true));
}
Also used : UsersMetadata(io.crate.user.metadata.UsersMetadata) Metadata(org.elasticsearch.cluster.metadata.Metadata) UsersMetadata(io.crate.user.metadata.UsersMetadata) UsersPrivilegesMetadata(io.crate.user.metadata.UsersPrivilegesMetadata) Test(org.junit.Test)

Example 8 with UsersMetadata

use of io.crate.user.metadata.UsersMetadata in project crate by crate.

the class TransportUserActionTest method testCreateFirstUser.

@Test
public void testCreateFirstUser() throws Exception {
    Metadata.Builder mdBuilder = new Metadata.Builder();
    TransportCreateUserAction.putUser(mdBuilder, "root", null);
    UsersMetadata metadata = (UsersMetadata) mdBuilder.getCustom(UsersMetadata.TYPE);
    assertThat(metadata.userNames().size(), is(1));
    assertThat(metadata.userNames().get(0), is("root"));
}
Also used : UsersMetadata(io.crate.user.metadata.UsersMetadata) Metadata(org.elasticsearch.cluster.metadata.Metadata) UsersMetadata(io.crate.user.metadata.UsersMetadata) UsersPrivilegesMetadata(io.crate.user.metadata.UsersPrivilegesMetadata) Test(org.junit.Test)

Example 9 with UsersMetadata

use of io.crate.user.metadata.UsersMetadata in project crate by crate.

the class TransportUserActionTest method testDropNonExistingUser.

@Test
public void testDropNonExistingUser() throws Exception {
    boolean res = TransportDropUserAction.dropUser(Metadata.builder(), new UsersMetadata(UserDefinitions.SINGLE_USER_ONLY), "trillian");
    assertThat(res, is(false));
}
Also used : UsersMetadata(io.crate.user.metadata.UsersMetadata) Test(org.junit.Test)

Example 10 with UsersMetadata

use of io.crate.user.metadata.UsersMetadata in project crate by crate.

the class UserLookupServiceTest method testNewUser.

@Test
public void testNewUser() {
    Set<User> users = UserLookupService.getUsers(new UsersMetadata(UserDefinitions.SINGLE_USER_ONLY), new UsersPrivilegesMetadata());
    assertThat(users, containsInAnyOrder(User.of("Arthur"), CRATE_USER));
}
Also used : UsersPrivilegesMetadata(io.crate.user.metadata.UsersPrivilegesMetadata) UsersMetadata(io.crate.user.metadata.UsersMetadata) Test(org.junit.Test) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest)

Aggregations

UsersMetadata (io.crate.user.metadata.UsersMetadata)13 UsersPrivilegesMetadata (io.crate.user.metadata.UsersPrivilegesMetadata)10 Test (org.junit.Test)8 Metadata (org.elasticsearch.cluster.metadata.Metadata)7 VisibleForTesting (io.crate.common.annotations.VisibleForTesting)4 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)1 ArrayList (java.util.ArrayList)1