Search in sources :

Example 31 with SessionContext

use of io.crate.action.sql.SessionContext in project crate by crate.

the class AccessControlMaySeeTest method setUpUserAndValidator.

@Before
public void setUpUserAndValidator() {
    validationCallArguments = new ArrayList<>();
    user = new User("normal", Set.of(), Set.of(), null) {

        @Override
        public boolean hasAnyPrivilege(Privilege.Clazz clazz, String ident) {
            validationCallArguments.add(CollectionUtils.arrayAsArrayList(clazz, ident, user.name()));
            return true;
        }
    };
    accessControl = new AccessControlImpl(userName -> user, new SessionContext(user));
}
Also used : UnsupportedFeatureException(io.crate.exceptions.UnsupportedFeatureException) SessionContext(io.crate.action.sql.SessionContext) Privilege(io.crate.user.Privilege) User(io.crate.user.User) RelationName(io.crate.metadata.RelationName) Set(java.util.Set) Test(org.junit.Test) ArrayList(java.util.ArrayList) List(java.util.List) Matchers.hasItem(org.hamcrest.Matchers.hasItem) Matchers.contains(org.hamcrest.Matchers.contains) SchemaUnknownException(io.crate.exceptions.SchemaUnknownException) Matcher(org.hamcrest.Matcher) Is.is(org.hamcrest.core.Is.is) UnhandledServerException(io.crate.exceptions.UnhandledServerException) CollectionUtils(org.elasticsearch.common.util.CollectionUtils) ESTestCase(org.elasticsearch.test.ESTestCase) Before(org.junit.Before) RelationValidationException(io.crate.exceptions.RelationValidationException) User(io.crate.user.User) SessionContext(io.crate.action.sql.SessionContext) Privilege(io.crate.user.Privilege) Before(org.junit.Before)

Aggregations

SessionContext (io.crate.action.sql.SessionContext)31 Test (org.junit.Test)26 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)18 SQLExecutor (io.crate.testing.SQLExecutor)14 User (io.crate.user.User)13 List (java.util.List)13 ArrayList (java.util.ArrayList)12 DependencyCarrier (io.crate.planner.DependencyCarrier)11 DataTypes (io.crate.types.DataTypes)11 Arrays (java.util.Arrays)11 Map (java.util.Map)11 DescribeResult (io.crate.action.sql.DescribeResult)10 SQLOperations (io.crate.action.sql.SQLOperations)10 Session (io.crate.action.sql.Session)10 AccessControl (io.crate.auth.AccessControl)10 AlwaysOKAuthentication (io.crate.auth.AlwaysOKAuthentication)10 Authentication (io.crate.auth.Authentication)10 AuthenticationMethod (io.crate.auth.AuthenticationMethod)10 JobKilledException (io.crate.exceptions.JobKilledException)10 JobsLogs (io.crate.execution.engine.collect.stats.JobsLogs)10