use of io.crate.user.UserLookupService in project crate by crate.
the class AccessControlMayExecuteTest method setUpSQLExecutor.
@Before
public void setUpSQLExecutor() throws Exception {
validationCallArguments = new ArrayList<>();
RepositoriesMetadata repositoriesMetadata = new RepositoriesMetadata(singletonList(new RepositoryMetadata("my_repo", "fs", Settings.builder().put("location", "/tmp/my_repo").build())));
ClusterState clusterState = ClusterState.builder(clusterService.state()).metadata(Metadata.builder(clusterService.state().metadata()).putCustom(RepositoriesMetadata.TYPE, repositoriesMetadata)).build();
ClusterServiceUtils.setState(clusterService, clusterState);
user = new User("normal", Set.of(), Set.of(), null) {
@Override
public boolean hasPrivilege(Privilege.Type type, Privilege.Clazz clazz, String ident, String defaultSchema) {
validationCallArguments.add(CollectionUtils.arrayAsArrayList(type, clazz, ident, user.name()));
return true;
}
};
superUser = new User("crate", EnumSet.of(User.Role.SUPERUSER), Set.of(), null) {
@Override
public boolean hasPrivilege(Privilege.Type type, Privilege.Clazz clazz, @Nullable String ident, String defaultSchema) {
validationCallArguments.add(CollectionUtils.arrayAsArrayList(type, clazz, ident, superUser.name()));
return true;
}
};
UserLookupService userLookupService = new UserLookupService(clusterService) {
@Nullable
@Override
public User findUser(String userName) {
if ("crate".equals(userName)) {
return superUser;
}
return super.findUser(userName);
}
};
userManager = new UserManagerService(null, null, null, null, mock(SysTableRegistry.class), clusterService, userLookupService, new DDLClusterStateService());
e = SQLExecutor.builder(clusterService).addBlobTable("create blob table blobs").enableDefaultTables().setUser(superUser).addView(new RelationName("doc", "v1"), "select * from users").setUserManager(userManager).build();
}
Aggregations