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); }
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 }
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()); }
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()); }
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()); }
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()); }
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(); }
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); }
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); }