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"));
}
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));
}
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"));
}
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));
}
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));
}
Aggregations