HBASE-27279 Addendum fix TestSaslTlsIPCRejectPlainText

This commit is contained in:
Duo Zhang 2022-08-16 21:43:03 +08:00
parent 4a57cbd2cb
commit 116458ab04
3 changed files with 9 additions and 6 deletions

View File

@ -59,7 +59,7 @@ import org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProto
public abstract class AbstractTestTlsRejectPlainText {
protected static final HBaseCommonTestingUtil UTIL = new HBaseCommonTestingUtil();
protected static HBaseCommonTestingUtil UTIL;
protected static File DIR;

View File

@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.security;
import java.io.IOException;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseCommonTestingUtil;
import org.apache.hadoop.hbase.ipc.TestProtobufRpcServiceImpl;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RPCTests;
@ -41,6 +42,7 @@ public class TestNettyTlsIPCRejectPlainText extends AbstractTestTlsRejectPlainTe
@BeforeClass
public static void setUpBeforeClass() throws IOException {
UTIL = new HBaseCommonTestingUtil();
initialize();
}

View File

@ -46,9 +46,7 @@ public class TestSaslTlsIPCRejectPlainText extends AbstractTestTlsRejectPlainTex
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestSaslTlsIPCRejectPlainText.class);
private static final HBaseTestingUtil UTIL = new HBaseTestingUtil();
private static final File KEYTAB_FILE = new File(UTIL.getDataTestDir("keytab").toUri().getPath());
private static File KEYTAB_FILE;
private static MiniKdc KDC;
private static String HOST = "localhost";
@ -57,13 +55,16 @@ public class TestSaslTlsIPCRejectPlainText extends AbstractTestTlsRejectPlainTex
@BeforeClass
public static void setUpBeforeClass() throws Exception {
HBaseTestingUtil util = new HBaseTestingUtil();
UTIL = util;
initialize();
KDC = UTIL.setupMiniKdc(KEYTAB_FILE);
KEYTAB_FILE = new File(util.getDataTestDir("keytab").toUri().getPath());
KDC = util.setupMiniKdc(KEYTAB_FILE);
PRINCIPAL = "hbase/" + HOST;
KDC.createPrincipal(KEYTAB_FILE, PRINCIPAL);
HBaseKerberosUtils.setPrincipalForTesting(PRINCIPAL + "@" + KDC.getRealm());
UGI = loginKerberosPrincipal(KEYTAB_FILE.getCanonicalPath(), PRINCIPAL);
setSecuredConfiguration(UTIL.getConfiguration());
setSecuredConfiguration(util.getConfiguration());
SecurityInfo securityInfoMock = Mockito.mock(SecurityInfo.class);
Mockito.when(securityInfoMock.getServerPrincipal())
.thenReturn(HBaseKerberosUtils.KRB_PRINCIPAL);