001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.security;
019
020import java.util.ArrayList;
021import java.util.Arrays;
022import java.util.List;
023import java.util.stream.Stream;
024import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
025import org.apache.hadoop.hbase.ipc.BlockingRpcClient;
026import org.apache.hadoop.hbase.ipc.NettyRpcClient;
027import org.apache.hadoop.hbase.ipc.NettyRpcServer;
028import org.apache.hadoop.hbase.ipc.RpcClientFactory;
029import org.apache.hadoop.hbase.ipc.RpcServerFactory;
030import org.apache.hadoop.hbase.ipc.SimpleRpcServer;
031import org.apache.hadoop.hbase.testclassification.LargeTests;
032import org.apache.hadoop.hbase.testclassification.SecurityTests;
033import org.junit.jupiter.api.AfterAll;
034import org.junit.jupiter.api.BeforeAll;
035import org.junit.jupiter.api.BeforeEach;
036import org.junit.jupiter.api.Tag;
037import org.junit.jupiter.params.provider.Arguments;
038
039@Tag(SecurityTests.TAG)
040@Tag(LargeTests.TAG)
041@HBaseParameterizedTestTemplate(name = "{index}: rpcClientImpl={0}, rpcServerImpl={1}")
042public class TestSecureIPC extends AbstractTestSecureIPC {
043
044  public static Stream<Arguments> parameters() {
045    List<Arguments> params = new ArrayList<>();
046    List<String> rpcClientImpls =
047      Arrays.asList(BlockingRpcClient.class.getName(), NettyRpcClient.class.getName());
048    List<String> rpcServerImpls =
049      Arrays.asList(SimpleRpcServer.class.getName(), NettyRpcServer.class.getName());
050    for (String rpcClientImpl : rpcClientImpls) {
051      for (String rpcServerImpl : rpcServerImpls) {
052        params.add(Arguments.of(rpcClientImpl, rpcServerImpl));
053      }
054    }
055    return params.stream();
056  }
057
058  public String rpcClientImpl;
059
060  public String rpcServerImpl;
061
062  public TestSecureIPC(String rpcClientImpl, String rpcServerImpl) {
063    this.rpcClientImpl = rpcClientImpl;
064    this.rpcServerImpl = rpcServerImpl;
065  }
066
067  @BeforeAll
068  public static void setUp() throws Exception {
069    initKDCAndConf();
070  }
071
072  @AfterAll
073  public static void tearDown() throws Exception {
074    stopKDC();
075    TEST_UTIL.cleanupTestDir();
076  }
077
078  @BeforeEach
079  public void setUpTest() throws Exception {
080    setUpPrincipalAndConf();
081    clientConf.set(RpcClientFactory.CUSTOM_RPC_CLIENT_IMPL_CONF_KEY, rpcClientImpl);
082    serverConf.set(RpcServerFactory.CUSTOM_RPC_SERVER_IMPL_CONF_KEY, rpcServerImpl);
083  }
084}