|
@@ -26,17 +26,20 @@ import org.apache.hadoop.hdfs.security.token.delegation.DelegationTokenIdentifie
|
|
|
import org.apache.hadoop.hdfs.server.federation.RouterConfigBuilder;
|
|
|
import org.apache.hadoop.hdfs.server.federation.router.security.RouterSecurityManager;
|
|
|
import org.apache.hadoop.hdfs.server.federation.router.Router;
|
|
|
+import org.apache.hadoop.hdfs.server.federation.router.security.token.ZKDelegationTokenSecretManagerImpl;
|
|
|
import org.apache.hadoop.io.Text;
|
|
|
import org.apache.hadoop.security.Credentials;
|
|
|
import org.apache.hadoop.security.UserGroupInformation;
|
|
|
import org.apache.hadoop.security.token.SecretManager;
|
|
|
import org.apache.hadoop.security.token.Token;
|
|
|
import org.apache.hadoop.security.token.delegation.AbstractDelegationTokenSecretManager;
|
|
|
+import org.apache.hadoop.service.ServiceStateException;
|
|
|
import org.junit.rules.ExpectedException;
|
|
|
import org.junit.BeforeClass;
|
|
|
import org.junit.Rule;
|
|
|
import org.junit.Test;
|
|
|
|
|
|
+import static org.apache.hadoop.test.LambdaTestUtils.intercept;
|
|
|
import static org.junit.Assert.assertTrue;
|
|
|
import static org.junit.Assert.assertFalse;
|
|
|
import static org.junit.Assert.assertNotNull;
|
|
@@ -77,7 +80,7 @@ public class TestRouterSecurityManager {
|
|
|
public ExpectedException exceptionRule = ExpectedException.none();
|
|
|
|
|
|
@Test
|
|
|
- public void testCreateSecretManagerUsingReflection() {
|
|
|
+ public void testCreateSecretManagerUsingReflection() throws IOException {
|
|
|
Configuration conf = new HdfsConfiguration();
|
|
|
conf.set(
|
|
|
DFS_ROUTER_DELEGATION_TOKEN_DRIVER_CLASS,
|
|
@@ -187,4 +190,15 @@ public class TestRouterSecurityManager {
|
|
|
String[] groupsForTesting = {"router_group"};
|
|
|
return groupsForTesting;
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void testWithoutSecretManager() throws Exception {
|
|
|
+ Configuration conf = initSecurity();
|
|
|
+ conf.set(DFS_ROUTER_DELEGATION_TOKEN_DRIVER_CLASS,
|
|
|
+ ZKDelegationTokenSecretManagerImpl.class.getName());
|
|
|
+ Router router = new Router();
|
|
|
+ // router will throw an exception since zookeeper isn't running
|
|
|
+ intercept(ServiceStateException.class, "Failed to create SecretManager",
|
|
|
+ () -> router.init(conf));
|
|
|
+ }
|
|
|
}
|