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

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

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

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

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

        options.UserInformationEndpoint.ShouldStartWith("https://okta.local/oauth2/custom/v1/");
        Uri.TryCreate(options.UserInformationEndpoint, UriKind.Absolute, out _).ShouldBeTrue();
    }
Exemple #2
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));
    }
Exemple #3
0
    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());
    }
Exemple #4
0
    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();
    }