public void InncorrectUsername() { var provider = new CookieAuthorizationDataProvider(null); var claim = new Claim("TestType", "TestValue"); var httpContext = new HttpContextBuilder().Build(); provider.AddClaim(claim, httpContext, "*****@*****.**"); var claims = provider.GetClaims(httpContext, "*****@*****.**"); claims.Length.Should().Be(0); }
public void GetClaim() { var provider = new CookieAuthorizationDataProvider(null); var claim = new Claim("TestType", "TestValue"); var httpContext = new HttpContextBuilder().Build(); provider.AddClaim(claim, httpContext, "*****@*****.**"); var claims = provider.GetClaims(httpContext, "*****@*****.**"); claims.Length.Should().Be(1); claims[0].Type.Should().Be("TestType"); claims[0].Value.Should().Be("TestValue"); }
public void AddClaim() { var provider = new CookieAuthorizationDataProvider(null); var claim = new Claim("TestType", "TestValue"); var httpContext = new HttpContextBuilder().Build(); provider.AddClaim(claim, httpContext, "*****@*****.**"); var cookie = httpContext.Response.Cookies.Get(CookieName); cookie.Should().NotBeNull(); if (cookie != null) { cookie.Value.Should().NotBeNullOrEmpty(); cookie.Value.Should().NotContain("TestType"); cookie.Value.Should().NotContain("TestValue"); var unprotectedValue = CookieAuthorizationDataProvider.Unprotect(cookie.Value); unprotectedValue.Should().Contain("TestType"); unprotectedValue.Should().Contain("TestValue"); } }