public void GetClaims() { var provider = new CookieAuthorizationDataProvider(null); var claim1 = new Claim("TestType1", "TestValue1"); var claim2 = new Claim("TestType2", "TestValue2"); var httpContext = new HttpContextBuilder().Build(); provider.AddClaim(claim1, httpContext, "*****@*****.**"); provider.AddClaim(claim2, httpContext, "*****@*****.**"); var claims = provider.GetClaims(httpContext, "*****@*****.**"); claims.Length.Should().Be(2); claims[0].Type.Should().Be("TestType1"); claims[0].Value.Should().Be("TestValue1"); claims[1].Type.Should().Be("TestType2"); claims[1].Value.Should().Be("TestValue2"); }
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 AddClaims() { var provider = new CookieAuthorizationDataProvider(null); var claim1 = new Claim("TestType1", "TestValue1"); var claim2 = new Claim("TestType2", "TestValue2"); var httpContext = new HttpContextBuilder().Build(); provider.AddClaim(claim1, httpContext, "*****@*****.**"); provider.AddClaim(claim2, httpContext, "*****@*****.**"); var cookie = httpContext.Response.Cookies.Get(CookieName); cookie.Should().NotBeNull(); if (cookie != null) { var unprotectedValue = CookieAuthorizationDataProvider.Unprotect(cookie.Value); unprotectedValue.Should().Contain("TestType1"); unprotectedValue.Should().Contain("TestValue1"); unprotectedValue.Should().Contain("TestType2"); unprotectedValue.Should().Contain("TestValue2"); } }