Skip to content

Commit

Permalink
bugfix cont
Browse files Browse the repository at this point in the history
  • Loading branch information
kingswanwho committed Jan 16, 2023
1 parent c7213c8 commit 056486a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ protected static void createView(final String viewOwner, final String viewGroup,
// test(String.format("CREATE VIEW %s.%s AS SELECT * FROM %s.%s;",
// getWSSchema(viewOwner), newViewName, fromSourceSchema, fromSourceTableName));

client.alterSession(DrillProperties.USER, viewOwner);
updateClient(viewOwner);
run(String.format("ALTER SESSION SET `%s`='%o';", ExecConstants.NEW_VIEW_DEFAULT_PERMS_KEY, viewPerms));
run(String.format("CREATE VIEW %s.%s AS SELECT * FROM %s.%s;",
getWSSchema(viewOwner), newViewName, fromSourceSchema, fromSourceTableName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@
*/
package org.apache.drill.exec.impersonation;

import com.typesafe.config.ConfigValue;
import org.apache.drill.common.exceptions.UserException;
import org.apache.drill.shaded.guava.com.google.common.collect.Maps;
import org.apache.drill.categories.SecurityTest;
import org.apache.drill.categories.SlowTest;
import org.apache.drill.common.config.DrillProperties;
import org.apache.drill.common.exceptions.UserException;
import org.apache.drill.exec.ExecConstants;
import org.apache.drill.exec.dotdrill.DotDrillType;
import org.apache.drill.exec.proto.UserBitShared;
import org.apache.drill.exec.rpc.RpcException;
import org.apache.drill.exec.rpc.user.security.testing.UserAuthenticatorTestImpl;
import org.apache.drill.exec.store.dfs.WorkspaceConfig;
import org.apache.drill.shaded.guava.com.google.common.collect.Maps;
import org.apache.drill.test.ClusterFixtureBuilder;
import org.apache.drill.test.UserExceptionMatcher;
import org.apache.hadoop.fs.FileStatus;
Expand Down Expand Up @@ -63,47 +61,13 @@ public class TestInboundImpersonation extends BaseTestImpersonation {
@BeforeClass
public static void setup() throws Exception {
startMiniDfsCluster(TestInboundImpersonation.class.getSimpleName());

// cluster = new ClusterFixtureBuilder(dirTestWatcher)
// .configProperty(ExecConstants.USER_AUTHENTICATION_ENABLED, true)
// .configProperty(ExecConstants.IMPERSONATION_ENABLED, true)
// .configProperty(ExecConstants.USER_AUTHENTICATOR_IMPL, UserAuthenticatorTestImpl.TYPE)
// .configProperty(DrillProperties.USER, "anonymous")
// .configProperty(DrillProperties.PASSWORD, "anything works!")
// .build();
//
// client = cluster.clientBuilder()
// .property(DrillProperties.USER, "anonymous")
// .property(DrillProperties.PASSWORD, "anything works!")
// .build();

ClusterFixtureBuilder builder = new ClusterFixtureBuilder(dirTestWatcher)
.configProperty(ExecConstants.USER_AUTHENTICATION_ENABLED, true)
.configProperty(ExecConstants.USER_AUTHENTICATOR_IMPL, UserAuthenticatorTestImpl.TYPE)
.configProperty(ExecConstants.IMPERSONATION_ENABLED, true)
.configProperty(DrillProperties.USER, "anonymous")
.configProperty(DrillProperties.PASSWORD, "anything works!")
.configClientProperty(DrillProperties.USER, "anonymous")
.configClientProperty(DrillProperties.PASSWORD, "anything works!");


startCluster(builder);
for (Map.Entry<String, ConfigValue> entry : cluster.config().entrySet()) {
System.out.println(entry.getKey() + " : " + entry.getValue());
}

// final DrillConfig newConfig = new DrillConfig(DrillConfig.create()
// .withValue(ExecConstants.USER_AUTHENTICATION_ENABLED,
// ConfigValueFactory.fromAnyRef(true))
// .withValue(ExecConstants.USER_AUTHENTICATOR_IMPL,
// ConfigValueFactory.fromAnyRef(UserAuthenticatorTestImpl.TYPE))
// .withValue(ExecConstants.IMPERSONATION_ENABLED,
// ConfigValueFactory.fromAnyRef(true)));
//
// final Properties connectionProps = new Properties();
// connectionProps.setProperty(DrillProperties.USER, "anonymous");
// connectionProps.setProperty(DrillProperties.PASSWORD, "anything works!");
// startDrillCluster(1, newConfig, connectionProps);
addMiniDfsBasedStorage(createTestWorkspaces());
createTestData();
}
Expand Down Expand Up @@ -175,7 +139,7 @@ public void selectChainedView() throws Exception {
.go();
}

@Test(expected = RpcException.class)
@Test(expected = IllegalStateException.class)
// PERMISSION ERROR: Proxy user 'user2_1' is not authorized to impersonate target user 'user0_2'.
public void unauthorizedTarget() throws Exception {
final String unauthorizedTarget = org2Users[0];
Expand Down

0 comments on commit 056486a

Please sign in to comment.