HBASE-15365 Do not write to '/tmp' in TestHBaseConfiguration
This commit is contained in:
parent
bab8d1527b
commit
69e442efe4
|
@ -20,29 +20,37 @@ package org.apache.hadoop.hbase;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.hbase.testclassification.MiscTests;
|
import org.apache.hadoop.hbase.testclassification.MiscTests;
|
||||||
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
import org.apache.hadoop.hbase.testclassification.SmallTests;
|
||||||
import org.apache.hadoop.hbase.zookeeper.ZKConfig;
|
import org.junit.AfterClass;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.experimental.categories.Category;
|
import org.junit.experimental.categories.Category;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
|
||||||
@Category({MiscTests.class, SmallTests.class})
|
@Category({MiscTests.class, SmallTests.class})
|
||||||
public class TestHBaseConfiguration {
|
public class TestHBaseConfiguration {
|
||||||
|
|
||||||
private static final Log LOG = LogFactory.getLog(TestHBaseConfiguration.class);
|
private static final Log LOG = LogFactory.getLog(TestHBaseConfiguration.class);
|
||||||
|
|
||||||
|
private static HBaseCommonTestingUtility UTIL = new HBaseCommonTestingUtility();
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void tearDown() throws IOException {
|
||||||
|
UTIL.cleanupTestDir();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetIntDeprecated() {
|
public void testGetIntDeprecated() {
|
||||||
int VAL = 1, VAL2 = 2;
|
int VAL = 1, VAL2 = 2;
|
||||||
|
@ -99,22 +107,19 @@ public class TestHBaseConfiguration {
|
||||||
@Test
|
@Test
|
||||||
public void testGetPassword() throws Exception {
|
public void testGetPassword() throws Exception {
|
||||||
Configuration conf = HBaseConfiguration.create();
|
Configuration conf = HBaseConfiguration.create();
|
||||||
conf.set(ReflectiveCredentialProviderClient.CREDENTIAL_PROVIDER_PATH,
|
conf.set(ReflectiveCredentialProviderClient.CREDENTIAL_PROVIDER_PATH, "jceks://file"
|
||||||
"jceks://file/tmp/foo.jks");
|
+ new File(UTIL.getDataTestDir().toUri().getPath(), "foo.jks").getCanonicalPath());
|
||||||
ReflectiveCredentialProviderClient client =
|
ReflectiveCredentialProviderClient client = new ReflectiveCredentialProviderClient();
|
||||||
new ReflectiveCredentialProviderClient();
|
|
||||||
if (client.isHadoopCredentialProviderAvailable()) {
|
if (client.isHadoopCredentialProviderAvailable()) {
|
||||||
char[] keyPass = {'k', 'e', 'y', 'p', 'a', 's', 's'};
|
char[] keyPass = { 'k', 'e', 'y', 'p', 'a', 's', 's' };
|
||||||
char[] storePass = {'s', 't', 'o', 'r', 'e', 'p', 'a', 's', 's'};
|
char[] storePass = { 's', 't', 'o', 'r', 'e', 'p', 'a', 's', 's' };
|
||||||
client.createEntry(conf, "ssl.keypass.alias", keyPass);
|
client.createEntry(conf, "ssl.keypass.alias", keyPass);
|
||||||
client.createEntry(conf, "ssl.storepass.alias", storePass);
|
client.createEntry(conf, "ssl.storepass.alias", storePass);
|
||||||
|
|
||||||
String keypass = HBaseConfiguration.getPassword(
|
String keypass = HBaseConfiguration.getPassword(conf, "ssl.keypass.alias", null);
|
||||||
conf, "ssl.keypass.alias", null);
|
|
||||||
assertEquals(keypass, new String(keyPass));
|
assertEquals(keypass, new String(keyPass));
|
||||||
|
|
||||||
String storepass = HBaseConfiguration.getPassword(
|
String storepass = HBaseConfiguration.getPassword(conf, "ssl.storepass.alias", null);
|
||||||
conf, "ssl.storepass.alias", null);
|
|
||||||
assertEquals(storepass, new String(storePass));
|
assertEquals(storepass, new String(storePass));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,7 +203,6 @@ public class TestHBaseConfiguration {
|
||||||
getProvidersMethod = loadMethod(hadoopCredProviderFactoryClz,
|
getProvidersMethod = loadMethod(hadoopCredProviderFactoryClz,
|
||||||
HADOOP_CRED_PROVIDER_FACTORY_GET_PROVIDERS_METHOD_NAME,
|
HADOOP_CRED_PROVIDER_FACTORY_GET_PROVIDERS_METHOD_NAME,
|
||||||
Configuration.class);
|
Configuration.class);
|
||||||
|
|
||||||
// Load Hadoop CredentialProvider
|
// Load Hadoop CredentialProvider
|
||||||
Class<?> hadoopCredProviderClz = null;
|
Class<?> hadoopCredProviderClz = null;
|
||||||
hadoopCredProviderClz = Class.forName(HADOOP_CRED_PROVIDER_CLASS_NAME);
|
hadoopCredProviderClz = Class.forName(HADOOP_CRED_PROVIDER_CLASS_NAME);
|
||||||
|
|
Loading…
Reference in New Issue