예제 #1
0
        /// <exception cref="System.Exception"/>
        private void TestAnonymousSimpleUser()
        {
            ApplicationSubmissionContextInfo app = new ApplicationSubmissionContextInfo();
            string appid = "application_123_0";

            app.SetApplicationId(appid);
            string requestBody = TestRMWebServicesDelegationTokenAuthentication.GetMarshalledAppInfo
                                     (app);
            Uri url = new Uri("http://localhost:8088/ws/v1/cluster/apps");
            HttpURLConnection conn = (HttpURLConnection)url.OpenConnection();

            TestRMWebServicesDelegationTokenAuthentication.SetupConn(conn, "POST", "application/xml"
                                                                     , requestBody);
            conn.GetInputStream();
            NUnit.Framework.Assert.AreEqual(ClientResponse.Status.Accepted.GetStatusCode(), conn
                                            .GetResponseCode());
            bool appExists = rm.GetRMContext().GetRMApps().Contains(ConverterUtils.ToApplicationId
                                                                        (appid));

            NUnit.Framework.Assert.IsTrue(appExists);
            RMApp actualApp = rm.GetRMContext().GetRMApps()[ConverterUtils.ToApplicationId(appid
                                                                                           )];
            string owner = actualApp.GetUser();

            NUnit.Framework.Assert.AreEqual(rm.GetConfig().Get(CommonConfigurationKeys.HadoopHttpStaticUser
                                                               , CommonConfigurationKeys.DefaultHadoopHttpStaticUser), owner);
            appid = "application_123_1";
            app.SetApplicationId(appid);
            requestBody = TestRMWebServicesDelegationTokenAuthentication.GetMarshalledAppInfo
                              (app);
            url  = new Uri("http://localhost:8088/ws/v1/cluster/apps?user.name=client");
            conn = (HttpURLConnection)url.OpenConnection();
            TestRMWebServicesDelegationTokenAuthentication.SetupConn(conn, "POST", MediaType.
                                                                     ApplicationXml, requestBody);
            conn.GetInputStream();
            appExists = rm.GetRMContext().GetRMApps().Contains(ConverterUtils.ToApplicationId
                                                                   (appid));
            NUnit.Framework.Assert.IsTrue(appExists);
            actualApp = rm.GetRMContext().GetRMApps()[ConverterUtils.ToApplicationId(appid)];
            owner     = actualApp.GetUser();
            NUnit.Framework.Assert.AreEqual("client", owner);
        }