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.tool;
019
020import org.apache.hadoop.hbase.HBaseClassTestRule;
021import org.apache.hadoop.hbase.HConstants;
022import org.apache.hadoop.hbase.codec.KeyValueCodecWithTags;
023import org.apache.hadoop.hbase.security.HadoopSecurityEnabledUserProviderForTesting;
024import org.apache.hadoop.hbase.security.UserProvider;
025import org.apache.hadoop.hbase.security.access.PermissionStorage;
026import org.apache.hadoop.hbase.security.access.SecureTestUtil;
027import org.apache.hadoop.hbase.testclassification.LargeTests;
028import org.apache.hadoop.hbase.testclassification.MiscTests;
029import org.junit.BeforeClass;
030import org.junit.ClassRule;
031import org.junit.experimental.categories.Category;
032
033/**
034 * Reruns TestLoadIncrementalHFiles using LoadIncrementalHFiles in secure mode. This suite is unable
035 * to verify the security handoff/turnover as miniCluster is running as system user thus has root
036 * privileges and delegation tokens don't seem to work on miniDFS.
037 * <p>
038 * Thus SecureBulkload can only be completely verified by running integration tests against a secure
039 * cluster. This suite is still invaluable as it verifies the other mechanisms that need to be
040 * supported as part of a LoadIncrementalFiles call.
041 */
042@Category({ MiscTests.class, LargeTests.class })
043public class TestSecureLoadIncrementalHFiles extends TestLoadIncrementalHFiles {
044
045  @ClassRule
046  public static final HBaseClassTestRule CLASS_RULE =
047    HBaseClassTestRule.forClass(TestSecureLoadIncrementalHFiles.class);
048
049  @BeforeClass
050  public static void setUpBeforeClass() throws Exception {
051    // set the always on security provider
052    UserProvider.setUserProviderForTesting(util.getConfiguration(),
053      HadoopSecurityEnabledUserProviderForTesting.class);
054    // setup configuration
055    SecureTestUtil.enableSecurity(util.getConfiguration());
056    util.getConfiguration().setInt(LoadIncrementalHFiles.MAX_FILES_PER_REGION_PER_FAMILY,
057      MAX_FILES_PER_REGION_PER_FAMILY);
058    // change default behavior so that tag values are returned with normal rpcs
059    util.getConfiguration().set(HConstants.RPC_CODEC_CONF_KEY,
060      KeyValueCodecWithTags.class.getCanonicalName());
061
062    util.startMiniCluster();
063
064    // Wait for the ACL table to become available
065    util.waitTableEnabled(PermissionStorage.ACL_TABLE_NAME);
066
067    setupNamespace();
068  }
069
070}