示例#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
        public void UriTest()
        {
            OpenIdRelyingParty     rp       = TestSupport.CreateRelyingParty(null);
            Identifier             id       = MockHttpRequest.RegisterMockXrdsResponse("/Discovery/xrdsdiscovery/xrds20.xml");
            IAuthenticationRequest request  = rp.CreateRequest(id, TestSupport.Realm, TestSupport.ReturnTo);
            IProviderEndpoint      provider = request.Provider;

            Assert.AreEqual(new Uri("http://a/b"), provider.Uri);
        }
示例#3
0
        public void IsExtensionSupportedTest()
        {
            OpenIdRelyingParty     rp       = TestSupport.CreateRelyingParty(null);
            Identifier             id       = MockHttpRequest.RegisterMockXrdsResponse("/Discovery/xrdsdiscovery/xrds20.xml");
            IAuthenticationRequest request  = rp.CreateRequest(id, TestSupport.Realm, TestSupport.ReturnTo);
            IProviderEndpoint      provider = request.Provider;

            Assert.IsTrue(provider.IsExtensionSupported <ClaimsRequest>());
            Assert.IsTrue(provider.IsExtensionSupported(typeof(ClaimsRequest)));
            Assert.IsFalse(provider.IsExtensionSupported <FetchRequest>());
            Assert.IsFalse(provider.IsExtensionSupported(typeof(FetchRequest)));

            // Test the AdditionalTypeUris list by pulling from an XRDS page with one of the
            // TypeURIs that only shows up in that list.
            id      = MockHttpRequest.RegisterMockXrdsResponse("/Discovery/xrdsdiscovery/xrds10.xml");
            request = rp.CreateRequest(id, realm, returnTo);
            Assert.IsTrue(provider.IsExtensionSupported <ClaimsRequest>());
            Assert.IsTrue(provider.IsExtensionSupported(typeof(ClaimsRequest)));
        }
示例#4
0
        public void ClaimedIdentifierChangesAtProviderUnexpectedly()
        {
            OpenIdRelyingParty rp           = TestSupport.CreateRelyingParty(null);
            Identifier         id           = TestSupport.GetMockIdentifier(TestSupport.Scenarios.ApproveOnSetup, ProtocolVersion.V20);
            Identifier         newClaimedId = TestSupport.GetMockIdentifier(TestSupport.Scenarios.AutoApproval, ProtocolVersion.V20);
            Identifier         newLocalId   = TestSupport.GetDelegateUrl(TestSupport.Scenarios.AutoApproval);

            MockHttpRequest.RegisterMockXrdsResponse(new Uri(newClaimedId), newClaimedId.Discover());
            var request   = rp.CreateRequest(id, realm, returnTo);
            var provider  = TestSupport.CreateProviderForRequest(request);
            var opRequest = provider.Request as DotNetOpenId.Provider.IAuthenticationRequest;

            opRequest.IsAuthenticated   = true;
            opRequest.ClaimedIdentifier = newClaimedId;
            opRequest.LocalIdentifier   = newLocalId;
            var assertion = opRequest.Response.ExtractUrl();
            var response  = TestSupport.CreateRelyingParty(TestSupport.RelyingPartyStore, assertion, HttpUtility.ParseQueryString(assertion.Query)).Response;

            Assert.AreEqual(AuthenticationStatus.Authenticated, response.Status);
        }
示例#5
0
    internal static MockIdentifier GetMockOPIdentifier(Scenarios scenario, UriIdentifier expectedClaimedId, bool useSslOpIdentifier, bool useSslProviderEndpoint)
    {
        var fields = new Dictionary <string, string> {
            { "user", scenario.ToString() },
        };
        Uri             opEndpoint   = GetFullUrl(DirectedProviderEndpoint, fields, useSslProviderEndpoint);
        Uri             opIdentifier = GetOPIdentityUrl(scenario, useSslOpIdentifier);
        ServiceEndpoint se           = ServiceEndpoint.CreateForProviderIdentifier(
            opIdentifier,
            opEndpoint,
            new string[] { Protocol.v20.OPIdentifierServiceTypeURI },
            10,
            10
            );

        // Register the Claimed Identifier that directed identity will choose so that RP
        // discovery on that identifier can be mocked up.
        MockHttpRequest.RegisterMockXrdsResponse(expectedClaimedId, se);

        return(new MockIdentifier(opIdentifier, new ServiceEndpoint[] { se }));
    }