コード例 #1
0
        public void DiscoveryRequiresSslIgnoresInsecureEndpointsInXrds()
        {
            var           insecureEndpoint = TestSupport.GetServiceEndpoint(TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20, 10, false);
            var           secureEndpoint   = TestSupport.GetServiceEndpoint(TestSupport.Scenarios.ApproveOnSetup, ProtocolVersion.V20, 20, true);
            UriIdentifier secureClaimedId  = new UriIdentifier(TestSupport.GetFullUrl("/claimedId", null, true), true);

            MockHttpRequest.RegisterMockXrdsResponse(secureClaimedId, new ServiceEndpoint[] { insecureEndpoint, secureEndpoint });
            Assert.AreEqual(secureEndpoint.ProviderLocalIdentifier, secureClaimedId.Discover().Single().ProviderLocalIdentifier);
        }
コード例 #2
0
        void failDiscover(string url)
        {
            UriIdentifier userSuppliedId = TestSupport.GetFullUrl(url);

            Mocks.MockHttpRequest.RegisterMockResponse(new Uri(userSuppliedId), userSuppliedId, "text/html",
                                                       TestSupport.LoadEmbeddedFile(url));

            Assert.AreEqual(0, userSuppliedId.Discover().Count());             // ... but that no endpoint info is discoverable
        }
コード例 #3
0
        public void DiscoveryRequireSslWithInsecureXrdsInSecureHtmlHead()
        {
            var insecureXrdsSource = TestSupport.GetMockIdentifier(TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20, false);
            Uri secureClaimedUri   = TestSupport.GetFullUrl("/secureId", null, true);

            string html = string.Format("<html><head><meta http-equiv='X-XRDS-Location' content='{0}'/></head><body></body></html>",
                                        insecureXrdsSource);

            MockHttpRequest.RegisterMockResponse(secureClaimedUri, "text/html", html);

            Identifier userSuppliedIdentifier = new UriIdentifier(secureClaimedUri, true);

            Assert.AreEqual(0, userSuppliedIdentifier.Discover().Count());
        }
コード例 #4
0
        public void DiscoveryRequireSslWithInsecureXrdsInSecureHttpHeader()
        {
            var insecureXrdsSource = TestSupport.GetMockIdentifier(TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20, false);
            Uri secureClaimedUri   = TestSupport.GetFullUrl("/secureId", null, true);

            string html = "<html><head></head><body></body></html>";
            WebHeaderCollection headers = new WebHeaderCollection {
                { "X-XRDS-Location", insecureXrdsSource }
            };

            MockHttpRequest.RegisterMockResponse(secureClaimedUri, secureClaimedUri, "text/html", headers, html);

            Identifier userSuppliedIdentifier = new UriIdentifier(secureClaimedUri, true);

            Assert.AreEqual(0, userSuppliedIdentifier.Discover().Count());
        }
コード例 #5
0
        public void DiscoverRequireSslWithSecureRedirects()
        {
            MockHttpRequest.Reset();
            Identifier claimedId = TestSupport.GetMockIdentifier(TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20, true);

            // Add a couple of chained redirect pages that lead to the claimedId.
            // All redirects should be secure.
            Uri userSuppliedUri   = TestSupport.GetFullUrl("/someSecurePage", null, true);
            Uri secureMidpointUri = TestSupport.GetFullUrl("/secureStop", null, true);

            MockHttpRequest.RegisterMockRedirect(userSuppliedUri, secureMidpointUri);
            MockHttpRequest.RegisterMockRedirect(secureMidpointUri, new Uri(claimedId.ToString()));

            Identifier userSuppliedIdentifier = new UriIdentifier(userSuppliedUri, true);

            Assert.AreEqual(1, userSuppliedIdentifier.Discover().Count());
        }
コード例 #6
0
        public void DiscoveryWithRedirects()
        {
            MockHttpRequest.Reset();
            Identifier claimedId = TestSupport.GetMockIdentifier(TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20);

            // Add a couple of chained redirect pages that lead to the claimedId.
            Uri userSuppliedUri     = TestSupport.GetFullUrl("/someSecurePage", null, true);
            Uri insecureMidpointUri = TestSupport.GetFullUrl("/insecureStop");

            MockHttpRequest.RegisterMockRedirect(userSuppliedUri, insecureMidpointUri);
            MockHttpRequest.RegisterMockRedirect(insecureMidpointUri, new Uri(claimedId.ToString()));

            // don't require secure SSL discovery for this test.
            Identifier userSuppliedIdentifier = new UriIdentifier(userSuppliedUri, false);

            Assert.AreEqual(1, userSuppliedIdentifier.Discover().Count());
        }
コード例 #7
0
        public void DiscoverRequireSslWithInsecureRedirect()
        {
            MockHttpRequest.Reset();
            Identifier claimedId = TestSupport.GetMockIdentifier(TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20, true);

            // Add a couple of chained redirect pages that lead to the claimedId.
            // Include an insecure HTTP jump in those redirects to verify that
            // the ultimate endpoint is never found as a result of high security profile.
            Uri userSuppliedUri     = TestSupport.GetFullUrl("/someSecurePage", null, true);
            Uri insecureMidpointUri = TestSupport.GetFullUrl("/insecureStop");

            MockHttpRequest.RegisterMockRedirect(userSuppliedUri, insecureMidpointUri);
            MockHttpRequest.RegisterMockRedirect(insecureMidpointUri, new Uri(claimedId.ToString()));

            Identifier userSuppliedIdentifier = new UriIdentifier(userSuppliedUri, true);

            userSuppliedIdentifier.Discover();
        }
コード例 #8
0
        public void DiscoveryRequireSslWithInsecureXrdsButSecureLinkTags()
        {
            var insecureXrdsSource = TestSupport.GetMockIdentifier(TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20, false);
            Uri secureClaimedUri   = TestSupport.GetFullUrl("/secureId", null, true);

            Identifier localIdForLinkTag = TestSupport.GetDelegateUrl(TestSupport.Scenarios.AlwaysDeny, true);
            string     html = string.Format(@"
	<html><head>
		<meta http-equiv='X-XRDS-Location' content='{0}'/> <!-- this one will be insecure and ignored -->
		<link rel='openid2.provider' href='{1}' />
		<link rel='openid2.local_id' href='{2}' />
	</head><body></body></html>"    ,
                                            HttpUtility.HtmlEncode(insecureXrdsSource),
                                            HttpUtility.HtmlEncode(TestSupport.GetFullUrl("/" + TestSupport.ProviderPage, null, true).AbsoluteUri),
                                            HttpUtility.HtmlEncode(localIdForLinkTag.ToString())
                                            );

            MockHttpRequest.RegisterMockResponse(secureClaimedUri, "text/html", html);

            Identifier userSuppliedIdentifier = new UriIdentifier(secureClaimedUri, true);

            Assert.AreEqual(localIdForLinkTag, userSuppliedIdentifier.Discover().Single().ProviderLocalIdentifier);
        }
コード例 #9
0
		public void DiscoveryRequiresSslIgnoresInsecureEndpointsInXrds() {
			var insecureEndpoint = TestSupport.GetServiceEndpoint(TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20, 10, false);
			var secureEndpoint = TestSupport.GetServiceEndpoint(TestSupport.Scenarios.ApproveOnSetup, ProtocolVersion.V20, 20, true);
			UriIdentifier secureClaimedId = new UriIdentifier(TestSupport.GetFullUrl("/claimedId", null, true), true);
			MockHttpRequest.RegisterMockXrdsResponse(secureClaimedId, new ServiceEndpoint[] { insecureEndpoint, secureEndpoint });
			Assert.AreEqual(secureEndpoint.ProviderLocalIdentifier, secureClaimedId.Discover().Single().ProviderLocalIdentifier);
		}
コード例 #10
0
		public void DiscoveryRequireSslWithInsecureXrdsButSecureLinkTags() {
			var insecureXrdsSource = TestSupport.GetMockIdentifier(TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20, false);
			Uri secureClaimedUri = TestSupport.GetFullUrl("/secureId", null, true);

			Identifier localIdForLinkTag = TestSupport.GetDelegateUrl(TestSupport.Scenarios.AlwaysDeny, true);
			string html = string.Format(@"
	<html><head>
		<meta http-equiv='X-XRDS-Location' content='{0}'/> <!-- this one will be insecure and ignored -->
		<link rel='openid2.provider' href='{1}' />
		<link rel='openid2.local_id' href='{2}' />
	</head><body></body></html>",
				HttpUtility.HtmlEncode(insecureXrdsSource),
				HttpUtility.HtmlEncode(TestSupport.GetFullUrl("/" + TestSupport.ProviderPage, null, true).AbsoluteUri),
				HttpUtility.HtmlEncode(localIdForLinkTag.ToString())
				);
			MockHttpRequest.RegisterMockResponse(secureClaimedUri, "text/html", html);

			Identifier userSuppliedIdentifier = new UriIdentifier(secureClaimedUri, true);
			Assert.AreEqual(localIdForLinkTag, userSuppliedIdentifier.Discover().Single().ProviderLocalIdentifier);
		}
コード例 #11
0
		public void DiscoveryRequireSslWithInsecureXrdsInSecureHttpHeader() {
			var insecureXrdsSource = TestSupport.GetMockIdentifier(TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20, false);
			Uri secureClaimedUri = TestSupport.GetFullUrl("/secureId", null, true);

			string html = "<html><head></head><body></body></html>";
			WebHeaderCollection headers = new WebHeaderCollection {
				{ "X-XRDS-Location", insecureXrdsSource }
			};
			MockHttpRequest.RegisterMockResponse(secureClaimedUri, secureClaimedUri, "text/html", headers, html);

			Identifier userSuppliedIdentifier = new UriIdentifier(secureClaimedUri, true);
			Assert.AreEqual(0, userSuppliedIdentifier.Discover().Count());
		}
コード例 #12
0
		public void DiscoveryRequireSslWithInsecureXrdsInSecureHtmlHead() {
			var insecureXrdsSource = TestSupport.GetMockIdentifier(TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20, false);
			Uri secureClaimedUri = TestSupport.GetFullUrl("/secureId", null, true);

			string html = string.Format("<html><head><meta http-equiv='X-XRDS-Location' content='{0}'/></head><body></body></html>",
				insecureXrdsSource);
			MockHttpRequest.RegisterMockResponse(secureClaimedUri, "text/html", html);

			Identifier userSuppliedIdentifier = new UriIdentifier(secureClaimedUri, true);
			Assert.AreEqual(0, userSuppliedIdentifier.Discover().Count());
		}
コード例 #13
0
		public void DiscoverRequireSslWithInsecureRedirect() {
			MockHttpRequest.Reset();
			Identifier claimedId = TestSupport.GetMockIdentifier(TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20, true);

			// Add a couple of chained redirect pages that lead to the claimedId.
			// Include an insecure HTTP jump in those redirects to verify that
			// the ultimate endpoint is never found as a result of high security profile.
			Uri userSuppliedUri = TestSupport.GetFullUrl("/someSecurePage", null, true);
			Uri insecureMidpointUri = TestSupport.GetFullUrl("/insecureStop");
			MockHttpRequest.RegisterMockRedirect(userSuppliedUri, insecureMidpointUri);
			MockHttpRequest.RegisterMockRedirect(insecureMidpointUri, new Uri(claimedId.ToString()));

			Identifier userSuppliedIdentifier = new UriIdentifier(userSuppliedUri, true);
			userSuppliedIdentifier.Discover();
		}
コード例 #14
0
		public void DiscoverRequireSslWithSecureRedirects() {
			MockHttpRequest.Reset();
			Identifier claimedId = TestSupport.GetMockIdentifier(TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20, true);

			// Add a couple of chained redirect pages that lead to the claimedId.
			// All redirects should be secure.
			Uri userSuppliedUri = TestSupport.GetFullUrl("/someSecurePage", null, true);
			Uri secureMidpointUri = TestSupport.GetFullUrl("/secureStop", null, true);
			MockHttpRequest.RegisterMockRedirect(userSuppliedUri, secureMidpointUri);
			MockHttpRequest.RegisterMockRedirect(secureMidpointUri, new Uri(claimedId.ToString()));

			Identifier userSuppliedIdentifier = new UriIdentifier(userSuppliedUri, true);
			Assert.AreEqual(1, userSuppliedIdentifier.Discover().Count());
		}
コード例 #15
0
		public void DiscoveryWithRedirects() {
			MockHttpRequest.Reset();
			Identifier claimedId = TestSupport.GetMockIdentifier(TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20);

			// Add a couple of chained redirect pages that lead to the claimedId.
			Uri userSuppliedUri = TestSupport.GetFullUrl("/someSecurePage", null, true);
			Uri insecureMidpointUri = TestSupport.GetFullUrl("/insecureStop");
			MockHttpRequest.RegisterMockRedirect(userSuppliedUri, insecureMidpointUri);
			MockHttpRequest.RegisterMockRedirect(insecureMidpointUri, new Uri(claimedId.ToString()));

			// don't require secure SSL discovery for this test.
			Identifier userSuppliedIdentifier = new UriIdentifier(userSuppliedUri, false);
			Assert.AreEqual(1, userSuppliedIdentifier.Discover().Count());
		}