Example #1
0
 /// <exception cref="System.IO.IOException"/>
 public override IList <string> GetGroups(string user)
 {
     if (user.Equals("root"))
     {
         return(Arrays.AsList("admin"));
     }
     else
     {
         if (user.Equals("nobody"))
         {
             return(Arrays.AsList("nobody"));
         }
         else
         {
             string[] groups = HadoopUsersConfTestHelper.GetHadoopUserGroups(user);
             return((groups != null) ? Arrays.AsList(groups) : Sharpen.Collections.EmptyList);
         }
     }
 }
Example #2
0
 /// <exception cref="System.Exception"/>
 private void TestSetOwner()
 {
     if (!IsLocalFS())
     {
         FileSystem fs = FileSystem.Get(GetProxiedFSConf());
         fs.Mkdirs(GetProxiedFSTestDir());
         Path         path = new Path(GetProxiedFSTestDir(), "foo.txt");
         OutputStream os   = fs.Create(path);
         os.Write(1);
         os.Close();
         fs.Close();
         fs = GetHttpFSFileSystem();
         string user  = HadoopUsersConfTestHelper.GetHadoopUsers()[1];
         string group = HadoopUsersConfTestHelper.GetHadoopUserGroups(user)[0];
         fs.SetOwner(path, user, group);
         fs.Close();
         fs = FileSystem.Get(GetProxiedFSConf());
         FileStatus status1 = fs.GetFileStatus(path);
         fs.Close();
         NUnit.Framework.Assert.AreEqual(status1.GetOwner(), user);
         NUnit.Framework.Assert.AreEqual(status1.GetGroup(), group);
     }
 }
Example #3
0
        /// <exception cref="System.Exception"/>
        private void CreateHttpFSServer(bool addDelegationTokenAuthHandler)
        {
            FilePath homeDir = TestDirHelper.GetTestDir();

            NUnit.Framework.Assert.IsTrue(new FilePath(homeDir, "conf").Mkdir());
            NUnit.Framework.Assert.IsTrue(new FilePath(homeDir, "log").Mkdir());
            NUnit.Framework.Assert.IsTrue(new FilePath(homeDir, "temp").Mkdir());
            HttpFSServerWebApp.SetHomeDirForCurrentThread(homeDir.GetAbsolutePath());
            FilePath   secretFile = new FilePath(new FilePath(homeDir, "conf"), "secret");
            TextWriter w          = new FileWriter(secretFile);

            w.Write("secret");
            w.Close();
            //HDFS configuration
            FilePath hadoopConfDir = new FilePath(new FilePath(homeDir, "conf"), "hadoop-conf"
                                                  );

            hadoopConfDir.Mkdirs();
            string fsDefaultName = TestHdfsHelper.GetHdfsConf().Get(CommonConfigurationKeysPublic
                                                                    .FsDefaultNameKey);
            Configuration conf = new Configuration(false);

            conf.Set(CommonConfigurationKeysPublic.FsDefaultNameKey, fsDefaultName);
            conf.SetBoolean(DFSConfigKeys.DfsNamenodeAclsEnabledKey, true);
            conf.SetBoolean(DFSConfigKeys.DfsNamenodeXattrsEnabledKey, true);
            FilePath     hdfsSite = new FilePath(hadoopConfDir, "hdfs-site.xml");
            OutputStream os       = new FileOutputStream(hdfsSite);

            conf.WriteXml(os);
            os.Close();
            //HTTPFS configuration
            conf = new Configuration(false);
            if (addDelegationTokenAuthHandler)
            {
                conf.Set("httpfs.authentication.type", typeof(HttpFSKerberosAuthenticationHandlerForTesting
                                                              ).FullName);
            }
            conf.Set("httpfs.services.ext", typeof(TestHttpFSServer.MockGroups).FullName);
            conf.Set("httpfs.admin.group", HadoopUsersConfTestHelper.GetHadoopUserGroups(HadoopUsersConfTestHelper
                                                                                         .GetHadoopUsers()[0])[0]);
            conf.Set("httpfs.proxyuser." + HadoopUsersConfTestHelper.GetHadoopProxyUser() + ".groups"
                     , HadoopUsersConfTestHelper.GetHadoopProxyUserGroups());
            conf.Set("httpfs.proxyuser." + HadoopUsersConfTestHelper.GetHadoopProxyUser() + ".hosts"
                     , HadoopUsersConfTestHelper.GetHadoopProxyUserHosts());
            conf.Set("httpfs.authentication.signature.secret.file", secretFile.GetAbsolutePath
                         ());
            conf.Set("httpfs.hadoop.config.dir", hadoopConfDir.ToString());
            FilePath httpfsSite = new FilePath(new FilePath(homeDir, "conf"), "httpfs-site.xml"
                                               );

            os = new FileOutputStream(httpfsSite);
            conf.WriteXml(os);
            os.Close();
            ClassLoader   cl      = Sharpen.Thread.CurrentThread().GetContextClassLoader();
            Uri           url     = cl.GetResource("webapp");
            WebAppContext context = new WebAppContext(url.AbsolutePath, "/webhdfs");

            Org.Mortbay.Jetty.Server server = TestJettyHelper.GetJettyServer();
            server.AddHandler(context);
            server.Start();
            if (addDelegationTokenAuthHandler)
            {
                HttpFSServerWebApp.Get().SetAuthority(TestJettyHelper.GetAuthority());
            }
        }
Example #4
0
 /// <exception cref="System.IO.IOException"/>
 public virtual IList <string> GetGroups(string user)
 {
     return(Arrays.AsList(HadoopUsersConfTestHelper.GetHadoopUserGroups(user)));
 }