Esempio n. 1
0
                    public void WhenCalled_UpdatesValue()
                    {
                        var options = new ClaimOptions.ClaimTypeOptions();
                        var value   = Guid.NewGuid().ToString();

                        options.SecurityStampValidated = value;

                        Assert.Equal(value, options.SecurityStampValidated);
                    }
Esempio n. 2
0
                    public void EmptyValue_Throws()
                    {
                        var options = new ClaimOptions.ClaimTypeOptions();

                        Assert.Throws <ArgumentException>("value", () =>
                        {
                            options.SecurityStampValidated = string.Empty;
                        });
                    }
Esempio n. 3
0
                    public void WhiteSpaceValue_Throws()
                    {
                        var options = new ClaimOptions.ClaimTypeOptions();

                        Assert.Throws <ArgumentException>("value", () =>
                        {
                            options.SecurityStampValidated = "   ";
                        });
                    }
Esempio n. 4
0
                    public void WhiteSpaceValue_Throws()
                    {
                        var options = new ClaimOptions.ClaimTypeOptions();

                        Assert.Throws <ArgumentException>("value", () =>
                        {
                            options.UserKey = " ";
                        });
                    }
Esempio n. 5
0
                    public void NullValue_Throws()
                    {
                        var options = new ClaimOptions.ClaimTypeOptions();

                        Assert.Throws <ArgumentNullException>("value", () =>
                        {
                            options.SecurityStampValidated = null;
                        });
                    }
Esempio n. 6
0
                    public void WhenCalled_SetsValue()
                    {
                        var options = new ClaimOptions.ClaimTypeOptions();
                        var value   = Guid.NewGuid().ToString();

                        options.UserKey = value;

                        Assert.Equal(value, options.UserKey);
                    }
Esempio n. 7
0
                    public void EmptyValue_Throws()
                    {
                        var options = new ClaimOptions.ClaimTypeOptions();

                        Assert.Throws <ArgumentException>("value", () =>
                        {
                            options.UserKey = string.Empty;
                        });
                    }
Esempio n. 8
0
                    public void NullValue_Throws()
                    {
                        var options = new ClaimOptions.ClaimTypeOptions();

                        Assert.Throws <ArgumentNullException>("value", () =>
                        {
                            options.UserKey = null;
                        });
                    }
            public UserClaims(ClaimsIdentity identity, ClaimOptions.ClaimTypeOptions options)
            {
                var keyClaim            = identity.FindFirst(options.UserKey);
                var stampClaim          = identity.FindFirst(options.SecurityStamp);
                var stampValidatedClaim = identity.FindFirst(options.SecurityStampValidated);

                this.UserKey                = keyClaim != null ? new UserKey(keyClaim.Value) : null;
                this.SecurityStamp          = stampClaim?.Value;
                this.SecurityStampValidated = stampValidatedClaim != null
                    ? new UtcDateTime(long.Parse(stampValidatedClaim.Value))
                    : null;
            }
Esempio n. 10
0
            public UserClaims(ClaimsIdentity identity, ClaimOptions.ClaimTypeOptions options)
            {
                var keyClaim            = identity.FindFirst(options.UserKey);
                var stampClaim          = identity.FindFirst(options.SecurityStamp);
                var stampValidatedClaim = identity.FindFirst(options.SecurityStampValidated);

                this.UserKey                = keyClaim != null ? new UserKey(keyClaim.Value) : null;
                this.SecurityStamp          = stampClaim?.Value;
                this.SecurityStampValidated = stampValidatedClaim != null
                    ? (DateTimeOffset?)new DateTimeOffset(
                    ticks: long.Parse(stampValidatedClaim.Value),
                    offset: TimeSpan.Zero)
                    : null;
            }
Esempio n. 11
0
                    public void DefaultValue_ReturnsCorrectDefault()
                    {
                        var options = new ClaimOptions.ClaimTypeOptions();

                        Assert.Equal("securitystampvalidated", options.SecurityStampValidated);
                    }
Esempio n. 12
0
                    public void DefaultValue_ReturnsCorrectDefault()
                    {
                        var options = new ClaimOptions.ClaimTypeOptions();

                        Assert.Equal("sub", options.UserKey);
                    }