Exemple #1
0
        public static void PostConfigure_Throws_If_Domain_Is_Invalid(string value)
        {
            // Arrange
            string name   = "Okta";
            var    target = new OktaPostConfigureOptions();

            var options = new OktaAuthenticationOptions()
            {
                Domain = value,
            };

            // Act and Assert
            Assert.Throws <ArgumentException>("options", () => target.PostConfigure(name, options));
        }
        public static void Validate_Throws_If_UserInformationEndpoint_Not_Set()
        {
            // Arrange
            var options = new OktaAuthenticationOptions()
            {
                AuthorizationEndpoint = "https://okta.local",
                ClientId      = "ClientId",
                ClientSecret  = "ClientSecret",
                TokenEndpoint = "https://okta.local",
            };

            // Act and Assert
            Assert.Throws <ArgumentException>("UserInformationEndpoint", () => options.Validate());
        }
        public static void Validate_Does_Not_Throw_If_Uris_Are_Valid()
        {
            // Arrange
            var options = new OktaAuthenticationOptions()
            {
                AuthorizationEndpoint = "https://okta.local",
                ClientId                = "ClientId",
                ClientSecret            = "ClientSecret",
                TokenEndpoint           = "https://okta.local",
                UserInformationEndpoint = "https://okta.local",
            };

            // Act (no Assert)
            options.Validate();
        }
Exemple #4
0
        public static void PostConfigure_Configures_Valid_Endpoints(string domain)
        {
            // Arrange
            string name   = "Okta";
            var    target = new OktaPostConfigureOptions();

            var options = new OktaAuthenticationOptions()
            {
                Domain = domain,
            };

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

            // Assert
            options.AuthorizationEndpoint.ShouldStartWith("https://okta.local/oauth2/default/v1/");
            Uri.TryCreate(options.AuthorizationEndpoint, UriKind.Absolute, out var _).ShouldBeTrue();

            options.TokenEndpoint.ShouldStartWith("https://okta.local/oauth2/default/v1/");
            Uri.TryCreate(options.TokenEndpoint, UriKind.Absolute, out var _).ShouldBeTrue();

            options.UserInformationEndpoint.ShouldStartWith("https://okta.local/oauth2/default/v1/");
            Uri.TryCreate(options.UserInformationEndpoint, UriKind.Absolute, out var _).ShouldBeTrue();
        }