示例#1
0
        public static void PostConfigure_Does_Not_Update_Endpoints_If_EnterpriseDomain_Not_Set(string value)
        {
            // Arrange
            string name   = "GitHub";
            var    target = new GitHubPostConfigureOptions();

            var options = new GitHubAuthenticationOptions()
            {
                EnterpriseDomain = value,
            };

            // Act
            target.PostConfigure(name, options);

            // Assert
            options.AuthorizationEndpoint.ShouldStartWith("https://github.com/");
            Uri.TryCreate(options.AuthorizationEndpoint, UriKind.Absolute, out var _).ShouldBeTrue();

            options.TokenEndpoint.ShouldStartWith("https://github.com/");
            Uri.TryCreate(options.TokenEndpoint, UriKind.Absolute, out var _).ShouldBeTrue();

            options.UserEmailsEndpoint.ShouldStartWith("https://api.github.com/");
            Uri.TryCreate(options.UserEmailsEndpoint, UriKind.Absolute, out var _).ShouldBeTrue();

            options.UserInformationEndpoint.ShouldStartWith("https://api.github.com/");
            Uri.TryCreate(options.UserInformationEndpoint, UriKind.Absolute, out var _).ShouldBeTrue();
        }
        public static void PostConfigure_Configures_Valid_Endpoints_For_GitHub_Enterprise(string value)
        {
            // Arrange
            string name   = "GitHub";
            var    target = new GitHubPostConfigureOptions();

            var options = new GitHubAuthenticationOptions()
            {
                EnterpriseDomain = value,
            };

            // Act
            target.PostConfigure(name, options);

            // Assert
            options.AuthorizationEndpoint.ShouldStartWith("https://github.local/");
            Uri.TryCreate(options.AuthorizationEndpoint, UriKind.Absolute, out _).ShouldBeTrue();

            options.TokenEndpoint.ShouldStartWith("https://github.local/");
            Uri.TryCreate(options.TokenEndpoint, UriKind.Absolute, out _).ShouldBeTrue();

            options.UserEmailsEndpoint.ShouldStartWith("https://github.local/api/v3/");
            Uri.TryCreate(options.UserEmailsEndpoint, UriKind.Absolute, out _).ShouldBeTrue();

            options.UserInformationEndpoint.ShouldStartWith("https://github.local/api/v3/");
            Uri.TryCreate(options.UserInformationEndpoint, UriKind.Absolute, out _).ShouldBeTrue();
        }