Skip to content

Commit

Permalink
Try to force simple auth mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
jnturton committed Aug 15, 2023
1 parent 4e3992b commit 5e1705e
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@
package org.apache.drill.exec.impersonation;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.drill.common.config.DrillConfig;
import org.apache.drill.exec.ExecConstants;
import org.apache.drill.exec.dotdrill.DotDrillType;
import org.apache.drill.exec.rpc.security.KerberosHelper;
import org.apache.drill.exec.store.StoragePluginRegistry;
import org.apache.drill.exec.store.dfs.FileSystemConfig;
import org.apache.drill.exec.store.dfs.WorkspaceConfig;
import org.apache.drill.shaded.guava.com.google.common.base.Preconditions;
import org.apache.drill.shaded.guava.com.google.common.base.Strings;
import org.apache.drill.test.BaseDirTestWatcher;
import org.apache.drill.test.ClientFixture;
import org.apache.drill.test.ClusterFixture;
import org.apache.drill.test.ClusterFixtureBuilder;
Expand All @@ -38,13 +41,15 @@
import org.apache.hadoop.hdfs.MiniDFSCluster;
import org.apache.hadoop.security.UserGroupInformation;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.nio.file.Paths;
import java.util.Map;
import java.util.Properties;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_KEYTAB_FILE_KEY;

public class BaseTestImpersonation extends ClusterTest {
protected static final String MINI_DFS_STORAGE_PLUGIN_NAME = "mini_dfs_plugin";
Expand All @@ -54,6 +59,7 @@ public class BaseTestImpersonation extends ClusterTest {
protected static Configuration dfsConf;
protected static FileSystem fs;
protected static File miniDfsStoragePath;
private static KerberosHelper krbHelper;

// Test users and groups
protected static final String[] org1Users = { "user0_1", "user1_1", "user2_1", "user3_1", "user4_1", "user5_1" };
Expand Down Expand Up @@ -100,9 +106,22 @@ protected static void startMiniDfsCluster(String testClass, boolean isImpersonat
dfsConf.set("hdfs.minidfs.basedir", miniDfsStoragePath.getCanonicalPath());

if (isImpersonationEnabled) {
krbHelper = new KerberosHelper(BaseTestImpersonation.class.getSimpleName(), null);
krbHelper.setupKdc(BaseDirTestWatcher.createTempDir(dirTestWatcher.getTmpDir()));
String simpleAuth = "<configuration>" +
"<property>" +
"<name>hadoop.security.authentication</name>" +
"<value>simple</value>" +
"<final>true</final>" +
"</property>" +
"</configuration>";
// The following InputStream will be closed by dfsConf after reading
dfsConf.addResource(new ByteArrayInputStream(simpleAuth.getBytes()));

// Set the proxyuser settings so that the user who is running the Drillbits/MiniDfs can impersonate other users.
dfsConf.set(String.format("hadoop.proxyuser.%s.hosts", processUser), "*");
dfsConf.set(String.format("hadoop.proxyuser.%s.groups", processUser), "*");
//dfsConf.set(DFS_NAMENODE_KEYTAB_FILE_KEY, krbHelper.serverKeytab.toString());
}

// Start the MiniDfs cluster
Expand Down

0 comments on commit 5e1705e

Please sign in to comment.