|
@@ -1,94 +0,0 @@
|
|
|
-/**
|
|
|
- * Licensed to the Apache Software Foundation (ASF) under one
|
|
|
- * or more contributor license agreements. See the NOTICE file
|
|
|
- * distributed with this work for additional information
|
|
|
- * regarding copyright ownership. The ASF licenses this file
|
|
|
- * to you under the Apache License, Version 2.0 (the
|
|
|
- * "License"); you may not use this file except in compliance
|
|
|
- * with the License. You may obtain a copy of the License at
|
|
|
- *
|
|
|
- * http://www.apache.org/licenses/LICENSE-2.0
|
|
|
- *
|
|
|
- * Unless required by applicable law or agreed to in writing, software
|
|
|
- * distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
- * See the License for the specific language governing permissions and
|
|
|
- * limitations under the License.
|
|
|
- */
|
|
|
-package org.apache.hadoop.fs.http.server;
|
|
|
-
|
|
|
-import org.apache.hadoop.conf.Configuration;
|
|
|
-import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
|
|
|
-import org.apache.hadoop.fs.FileSystem;
|
|
|
-import org.apache.hadoop.fs.Path;
|
|
|
-import org.apache.hadoop.fs.http.client.HttpFSKerberosAuthenticator;
|
|
|
-import org.apache.hadoop.lib.server.Service;
|
|
|
-import org.apache.hadoop.lib.server.ServiceException;
|
|
|
-import org.apache.hadoop.lib.service.Groups;
|
|
|
-import org.apache.hadoop.lib.wsrs.UserProvider;
|
|
|
-import org.apache.hadoop.security.authentication.client.AuthenticatedURL;
|
|
|
-import org.apache.hadoop.security.authentication.server.AuthenticationToken;
|
|
|
-import org.apache.hadoop.security.authentication.util.Signer;
|
|
|
-import org.apache.hadoop.test.HFSTestCase;
|
|
|
-import org.apache.hadoop.test.HadoopUsersConfTestHelper;
|
|
|
-import org.apache.hadoop.test.TestDir;
|
|
|
-import org.apache.hadoop.test.TestDirHelper;
|
|
|
-import org.apache.hadoop.test.TestHdfs;
|
|
|
-import org.apache.hadoop.test.TestHdfsHelper;
|
|
|
-import org.apache.hadoop.test.TestJetty;
|
|
|
-import org.apache.hadoop.test.TestJettyHelper;
|
|
|
-import org.json.simple.JSONObject;
|
|
|
-import org.json.simple.parser.JSONParser;
|
|
|
-import org.junit.Assert;
|
|
|
-import org.junit.Test;
|
|
|
-import org.mortbay.jetty.Server;
|
|
|
-import org.mortbay.jetty.webapp.WebAppContext;
|
|
|
-
|
|
|
-import java.io.BufferedReader;
|
|
|
-import java.io.File;
|
|
|
-import java.io.FileOutputStream;
|
|
|
-import java.io.FileWriter;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.InputStream;
|
|
|
-import java.io.InputStreamReader;
|
|
|
-import java.io.OutputStream;
|
|
|
-import java.io.Writer;
|
|
|
-import java.net.HttpURLConnection;
|
|
|
-import java.net.URL;
|
|
|
-import java.text.MessageFormat;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-public class TestHttpFSCustomUserName extends HFSTestCase {
|
|
|
-
|
|
|
- @Test
|
|
|
- @TestDir
|
|
|
- @TestJetty
|
|
|
- public void defaultUserName() throws Exception {
|
|
|
- String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
|
-
|
|
|
- Configuration httpfsConf = new Configuration(false);
|
|
|
- HttpFSServerWebApp server =
|
|
|
- new HttpFSServerWebApp(dir, dir, dir, dir, httpfsConf);
|
|
|
- server.init();
|
|
|
- Assert.assertEquals(UserProvider.USER_PATTERN_DEFAULT,
|
|
|
- UserProvider.getUserPattern().pattern());
|
|
|
- server.destroy();
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- @TestDir
|
|
|
- @TestJetty
|
|
|
- public void customUserName() throws Exception {
|
|
|
- String dir = TestDirHelper.getTestDir().getAbsolutePath();
|
|
|
-
|
|
|
- Configuration httpfsConf = new Configuration(false);
|
|
|
- httpfsConf.set(UserProvider.USER_PATTERN_KEY, "1");
|
|
|
- HttpFSServerWebApp server =
|
|
|
- new HttpFSServerWebApp(dir, dir, dir, dir, httpfsConf);
|
|
|
- server.init();
|
|
|
- Assert.assertEquals("1", UserProvider.getUserPattern().pattern());
|
|
|
- server.destroy();
|
|
|
- }
|
|
|
-
|
|
|
-}
|