Ejemplo n.º 1
0
        public void GetEntityAsync_ThrowsXmlException()
        {
            PoisonedXmlResolver innerResolver = new PoisonedXmlResolver();
            XmlSecureResolver   outerResolver = new XmlSecureResolver(innerResolver, "some-url");
            Uri  absoluteUri  = new Uri("https://dot.net/");
            Type typeToReturn = typeof(Stream);

            Assert.Throws <XmlException>(() => (object)outerResolver.GetEntityAsync(absoluteUri, "role", typeToReturn));
            Assert.False(innerResolver.WasAnyApiInvoked);
        }
Ejemplo n.º 2
0
        public void TestAsync()
        {
            var      loc      = Assembly.GetExecutingAssembly().Location;
            Evidence e        = XmlSecureResolver.CreateEvidenceForUrl(loc);
            var      ur       = new XmlUrlResolver();
            var      sr       = new XmlSecureResolver(ur, e);
            Uri      resolved = sr.ResolveUri(null, loc);

            Assert.AreEqual("file", resolved.Scheme);
            var task = sr.GetEntityAsync(resolved, null, typeof(Stream));

            Assert.That(task.Wait(3000));
            Assert.IsInstanceOfType(typeof(Stream), task.Result);
        }