public void BeforeRequest(RequestBuilder requestBuilder, Uri absoluteUrl)
        {
            var ticket          = new AuthenticationTicket(principal, "FakeClaims");
            var ser             = new ClaimsSerializer();
            var cookieValue     = ser.SerializeTicket(ticket);
            var cookieContainer = new CookieContainer();
            var cookie          = new Cookie("FakeClaims", cookieValue, "/", absoluteUrl.Authority);

            cookieContainer.Add(cookie);
            var cookieHeader = cookieContainer.GetCookieHeader(absoluteUrl);

            requestBuilder.AddHeader(HeaderNames.Cookie, cookieHeader);
        }
Example #2
0
        public void DeserializeSameClaimsAfterSerialization()
        {
            var identity = new ClaimsIdentity();

            identity.AddClaim(new Claim("X", "Y"));
            var identities = new List <ClaimsIdentity> {
                identity
            };
            var user       = new ClaimsPrincipal(identities);
            var ticket     = new AuthenticationTicket(user, "test");
            var serializer = new ClaimsSerializer();
            var test       = serializer.SerializeTicket(ticket);

            var newTicket = serializer.DeserializeTicket(test);

            Assert.Single(newTicket.Principal.Identities.First().Claims);
        }