當前位置: 首頁>>代碼示例>>C#>>正文


C# AuthenticationService.RedirectToAuthenticationProvider方法代碼示例

本文整理匯總了C#中AuthenticationService.RedirectToAuthenticationProvider方法的典型用法代碼示例。如果您正苦於以下問題:C# AuthenticationService.RedirectToAuthenticationProvider方法的具體用法?C# AuthenticationService.RedirectToAuthenticationProvider怎麽用?C# AuthenticationService.RedirectToAuthenticationProvider使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在AuthenticationService的用法示例。


在下文中一共展示了AuthenticationService.RedirectToAuthenticationProvider方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GivenAValidProviderKeyWithNoState_RedirectToAuthenticate_ReturnsAUri

            public void GivenAValidProviderKeyWithNoState_RedirectToAuthenticate_ReturnsAUri()
            {
                // Arrange.
                var authenticationService = new AuthenticationService();
                authenticationService.AddProvider(new FacebookProvider("aa", "bb", new Uri("http://www.whatever.com")));

                // Act.
                var result = authenticationService.RedirectToAuthenticationProvider("Facebook");

                // Assert.
                Assert.NotNull(result);
                Assert.Equal("https://www.facebook.com/dialog/oauth?client_id=aa&scope=email&redirect_uri=http://www.whatever.com/", result.AbsoluteUri);
            }
開發者ID:plurby,項目名稱:WorldDomination.Web.Authentication,代碼行數:13,代碼來源:AuthenticationServiceFacts.cs

示例2: GivenAnInvalidProviderKey_RedirectToAuthenticationProvider_ThrowsAnException

            public void GivenAnInvalidProviderKey_RedirectToAuthenticationProvider_ThrowsAnException()
            {
                // Arrange.
                const string providerKey = "aaa";
                var authenticationService = new AuthenticationService();

                // Act and Assert.
                var result = Assert.Throws<AuthenticationException>(
                    () => authenticationService.RedirectToAuthenticationProvider(providerKey));

                Assert.NotNull(result);
                Assert.Equal("No 'aaa' provider has been added.", result.Message);
            }
開發者ID:plurby,項目名稱:WorldDomination.Web.Authentication,代碼行數:13,代碼來源:AuthenticationServiceFacts.cs

示例3: GivenAValidProviderKeyWithState_RedirectToAuthenticate_ReturnsAUriWithState

            public void GivenAValidProviderKeyWithState_RedirectToAuthenticate_ReturnsAUriWithState()
            {
                // Arrange.
                var authenticationService = new AuthenticationService();

                // Act.
                var authenticationServiceSettings = authenticationService.GetAuthenticateServiceSettings("facebook");
                authenticationServiceSettings.State = "pewpew";
                authenticationServiceSettings.CallBackUri = new Uri("http://www.whatever.com");
                var result = authenticationService.RedirectToAuthenticationProvider(authenticationServiceSettings);

                // Assert.
                Assert.NotNull(result);
                Assert.Equal(
                    "https://www.facebook.com/dialog/oauth?client_id=testKey&state=pewpew&scope=email&redirect_uri=http://www.whatever.com/",
                    result.AbsoluteUri);
            }
開發者ID:codeprogression,項目名稱:WorldDomination.Web.Authentication,代碼行數:17,代碼來源:AuthenticationServiceFacts.cs

示例4: GivenAnInvalidProviderKey_RedirectToAuthenticationProvider_ThrowsAnException

            public void GivenAnInvalidProviderKey_RedirectToAuthenticationProvider_ThrowsAnException()
            {
                // Arrange.
                const string providerKey = "aaa";
                var authenticationService = new AuthenticationService();

                // Act and Assert.
                var result = Assert.Throws<AuthenticationException>(
                    () => authenticationService.RedirectToAuthenticationProvider(providerKey));

                Assert.NotNull(result);
                Assert.Equal("No 'aaa' provider details have been added/provided. Maybe you forgot to add the name/key/value data into your web.config? Eg. in your web.config configuration/authenticationProviders/providers section add the following (if you want to offer Google authentication): <add name=\"Google\" key=\"someNumber.apps.googleusercontent.com\" secret=\"someSecret\" />", result.Message);
            }
開發者ID:jchannon,項目名稱:World-Domination.Web.Authentication,代碼行數:13,代碼來源:AuthenticationServiceFacts.cs

示例5: GivenAFakeProviderKeyWhichDoesExist_RedirectToAuthenticate_ReturnsAUri

            public void GivenAFakeProviderKeyWhichDoesExist_RedirectToAuthenticate_ReturnsAUri()
            {
                // Arrange.
                const string name = "FakeProviderWoot";
                var fakeProvider = new FakeProvider(name)
                {
                    AccessToken = new AccessToken
                    {
                        ExpiresOn = DateTime.Now.AddMinutes(100),
                        PublicToken = "I.Am.A.Public.Token"
                    },
                    UserInformation = new UserInformation
                    {
                        Email = "[email protected]",
                        Gender = GenderType.Male,
                        Name = "Fake Name",
                        Id = "1234567890",
                        UserName = "Fake.UserName"
                    }
                };

                var authenticationService = new AuthenticationService();
                authenticationService.AddProvider(fakeProvider);

                // Act.
                var result = authenticationService.RedirectToAuthenticationProvider(name,
                                                                       new Uri(
                                                                           "http://i.want.to.go.home.com/click/feet/together?provider=google"));

                // Assert.
                Assert.NotNull(result);
                Assert.Equal("http://i.want.to.go.home.com/click/feet/together?provider=google&state=This%20is%20some%20fake%20state", result.AbsoluteUri);
            }
開發者ID:ActivePHOENiX,項目名稱:SimpleAuthentication,代碼行數:33,代碼來源:AuthenticationServiceFacts.cs

示例6: GivenAValidFakeProviderKeyWhichDoesntExist_RedirectToAuthenticate_ReturnsAUri

            public void GivenAValidFakeProviderKeyWhichDoesntExist_RedirectToAuthenticate_ReturnsAUri()
            {
                // Arrange.
                var authenticationService = new AuthenticationService();

                // Act.
                var result = authenticationService.RedirectToAuthenticationProvider("FakeBlahBlah",
                                                                                    new Uri(
                                                                                        "http://www.pleasecomehome.com?provider=foo"));

                // Assert.
                Assert.NotNull(result);
                Assert.Equal("http://www.pleasecomehome.com/?provider=foo&state=This%20is%20some%20fake%20state", result.AbsoluteUri);
            }
開發者ID:ActivePHOENiX,項目名稱:SimpleAuthentication,代碼行數:14,代碼來源:AuthenticationServiceFacts.cs


注:本文中的AuthenticationService.RedirectToAuthenticationProvider方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。