Example #1
0
		public void Methods_Deny_Unrestricted ()
		{
			CasHttpWorkerRequest hwr = new CasHttpWorkerRequest ();
			hwr.CloseConnection ();
			Assert.IsNull (hwr.GetAppPath (), "GetAppPath");
			Assert.IsNull (hwr.GetAppPathTranslated (), "GetAppPathTranslated");
			Assert.IsNull (hwr.GetAppPoolID (), "GetAppPoolID");
			Assert.AreEqual (0, hwr.GetBytesRead (), "GetBytesRead");
			Assert.IsNull (hwr.GetFilePath (), "GetFilePath");
			Assert.IsNull (hwr.GetFilePathTranslated (), "GetGetFilePathTranslated");
			Assert.IsNull (hwr.GetKnownRequestHeader (0), "GetKnownRequestHeader");
			Assert.AreEqual (String.Empty, hwr.GetPathInfo (), "GetPathInfo");
			Assert.IsNull (hwr.GetPreloadedEntityBody (), "GetPreloadedEntityBody");
			Assert.AreEqual ("http", hwr.GetProtocol (), "GetProtocol");
			Assert.IsNull (hwr.GetQueryStringRawBytes (), "GetQueryStringRawBytes");
			Assert.AreEqual (0, hwr.GetRequestReason (), "GetRequestReason");
			Assert.IsNull (hwr.GetServerVariable (null), "GetServerVariable");
			Assert.IsNull (hwr.GetUnknownRequestHeader (null), "GetUnknownRequestHeader");
			Assert.IsNull (hwr.GetUnknownRequestHeaders (), "GetUnknownRequestHeaders");
			Assert.AreEqual (IntPtr.Zero, hwr.GetUserToken (), "GetUserToken");
			Assert.IsFalse (hwr.HasEntityBody (), "HasEntityBody");
			Assert.IsTrue (hwr.HeadersSent (), "HeadersSent");
			Assert.IsTrue (hwr.IsClientConnected (), "IsClientConnected");
			Assert.IsFalse (hwr.IsEntireEntityBodyIsPreloaded (), "IsEntireEntityBodyIsPreloaded");
			Assert.IsFalse (hwr.IsSecure (), "IsSecure");
			Assert.IsNull (hwr.MapPath (null), "MapPath");

			try {
				Assert.AreEqual (0, hwr.ReadEntityBody (new byte[1], 1), "ReadEntityBody(byte[],int)");
			}
			catch (NotImplementedException) {
				// mono
			}

			try {
				hwr.SendCalculatedContentLength (0);
			}
			catch (NotImplementedException) {
				// mono
			}

			hwr.SendResponseFromMemory (IntPtr.Zero, 0);
			hwr.SetEndOfSendNotification (new HttpWorkerRequest.EndOfSendNotification (Callback), null);

			Assert.IsNotNull (hwr.GetClientCertificate (), "GetClientCertificate");
			Assert.IsNotNull (hwr.GetClientCertificateBinaryIssuer (), "GetClientCertificateBinaryIssuer");
			Assert.AreEqual (0, hwr.GetClientCertificateEncoding (), "GetClientCertificateEncoding");
			Assert.IsNotNull (hwr.GetClientCertificatePublicKey (), "GetClientCertificatePublicKey");
			DateTime dt = DateTime.Now.AddMinutes (1);
			Assert.IsTrue (hwr.GetClientCertificateValidFrom () < dt, "GetClientCertificateValidFrom");
			Assert.IsTrue (hwr.GetClientCertificateValidUntil () < dt, "GetClientCertificateValidUntil");
			Assert.AreEqual (0, hwr.GetConnectionID (), "GetConnectionID");
			Assert.AreEqual (0, hwr.GetUrlContextID (), "GetUrlContextID");
			Assert.AreEqual (IntPtr.Zero, hwr.GetVirtualPathToken (), "GetVirtualPathToken");
			Assert.AreEqual (0, hwr.GetPreloadedEntityBody (new byte[0], 0), "GetPreloadedEntityBody(byte[],int)");
			Assert.AreEqual (0, hwr.GetPreloadedEntityBodyLength (), "GetPreloadedEntityBodyLength");
			Assert.AreEqual (0, hwr.GetTotalEntityBodyLength (), "GetTotalEntityBodyLength");
			Assert.AreEqual (0, hwr.ReadEntityBody (new byte[1], 0, 1), "ReadEntityBody(byte[],int,int)");
		}
Example #2
0
        public void Methods_Deny_Unrestricted()
        {
            CasHttpWorkerRequest hwr = new CasHttpWorkerRequest();

            hwr.CloseConnection();
            Assert.IsNull(hwr.GetAppPath(), "GetAppPath");
            Assert.IsNull(hwr.GetAppPathTranslated(), "GetAppPathTranslated");
            Assert.IsNull(hwr.GetAppPoolID(), "GetAppPoolID");
            Assert.AreEqual(0, hwr.GetBytesRead(), "GetBytesRead");
            Assert.IsNull(hwr.GetFilePath(), "GetFilePath");
            Assert.IsNull(hwr.GetFilePathTranslated(), "GetGetFilePathTranslated");
            Assert.IsNull(hwr.GetKnownRequestHeader(0), "GetKnownRequestHeader");
            Assert.AreEqual(String.Empty, hwr.GetPathInfo(), "GetPathInfo");
            Assert.IsNull(hwr.GetPreloadedEntityBody(), "GetPreloadedEntityBody");
            Assert.AreEqual("http", hwr.GetProtocol(), "GetProtocol");
            Assert.IsNull(hwr.GetQueryStringRawBytes(), "GetQueryStringRawBytes");
            Assert.AreEqual(0, hwr.GetRequestReason(), "GetRequestReason");
            Assert.IsNull(hwr.GetServerVariable(null), "GetServerVariable");
            Assert.IsNull(hwr.GetUnknownRequestHeader(null), "GetUnknownRequestHeader");
            Assert.IsNull(hwr.GetUnknownRequestHeaders(), "GetUnknownRequestHeaders");
            Assert.AreEqual(IntPtr.Zero, hwr.GetUserToken(), "GetUserToken");
            Assert.IsFalse(hwr.HasEntityBody(), "HasEntityBody");
            Assert.IsTrue(hwr.HeadersSent(), "HeadersSent");
            Assert.IsTrue(hwr.IsClientConnected(), "IsClientConnected");
            Assert.IsFalse(hwr.IsEntireEntityBodyIsPreloaded(), "IsEntireEntityBodyIsPreloaded");
            Assert.IsFalse(hwr.IsSecure(), "IsSecure");
            Assert.IsNull(hwr.MapPath(null), "MapPath");

            try {
                Assert.AreEqual(0, hwr.ReadEntityBody(new byte[1], 1), "ReadEntityBody(byte[],int)");
            }
            catch (NotImplementedException) {
                // mono
            }

            try {
                hwr.SendCalculatedContentLength(0);
            }
            catch (NotImplementedException) {
                // mono
            }

            hwr.SendResponseFromMemory(IntPtr.Zero, 0);
            hwr.SetEndOfSendNotification(new HttpWorkerRequest.EndOfSendNotification(Callback), null);

            Assert.IsNotNull(hwr.GetClientCertificate(), "GetClientCertificate");
            Assert.IsNotNull(hwr.GetClientCertificateBinaryIssuer(), "GetClientCertificateBinaryIssuer");
            Assert.AreEqual(0, hwr.GetClientCertificateEncoding(), "GetClientCertificateEncoding");
            Assert.IsNotNull(hwr.GetClientCertificatePublicKey(), "GetClientCertificatePublicKey");
            DateTime dt = DateTime.Now.AddMinutes(1);

            Assert.IsTrue(hwr.GetClientCertificateValidFrom() < dt, "GetClientCertificateValidFrom");
            Assert.IsTrue(hwr.GetClientCertificateValidUntil() < dt, "GetClientCertificateValidUntil");
            Assert.AreEqual(0, hwr.GetConnectionID(), "GetConnectionID");
            Assert.AreEqual(0, hwr.GetUrlContextID(), "GetUrlContextID");
            Assert.AreEqual(IntPtr.Zero, hwr.GetVirtualPathToken(), "GetVirtualPathToken");
            Assert.AreEqual(0, hwr.GetPreloadedEntityBody(new byte[0], 0), "GetPreloadedEntityBody(byte[],int)");
            Assert.AreEqual(0, hwr.GetPreloadedEntityBodyLength(), "GetPreloadedEntityBodyLength");
            Assert.AreEqual(0, hwr.GetTotalEntityBodyLength(), "GetTotalEntityBodyLength");
            Assert.AreEqual(0, hwr.ReadEntityBody(new byte[1], 0, 1), "ReadEntityBody(byte[],int,int)");
        }