public void CookieWithNonExistingKey() { var cookie = WebCookie.FromString("foo", loose: true); Assert.AreEqual("", cookie.Key); Assert.AreEqual("foo", cookie.Value); Assert.AreEqual(null, cookie.Path); Assert.IsFalse(cookie.Expires.HasValue); Assert.IsFalse(cookie.IsSecure); Assert.IsFalse(cookie.IsHttpOnly); }
public void CookieWithWeirdFormat() { var cookie = WebCookie.FromString("=foo=bar", loose: true); Assert.AreEqual("foo", cookie.Key); Assert.AreEqual("bar", cookie.Value); Assert.AreEqual(null, cookie.Path); Assert.IsFalse(cookie.Expires.HasValue); Assert.IsFalse(cookie.IsSecure); Assert.IsFalse(cookie.IsHttpOnly); }
public void CookieWithQuotesSpacesInTheValue() { var cookie = WebCookie.FromString("a=\"one two three\""); Assert.AreEqual("a", cookie.Key); Assert.AreEqual("\"one two three\"", cookie.Value); Assert.AreEqual(null, cookie.Path); Assert.IsFalse(cookie.Expires.HasValue); Assert.IsFalse(cookie.IsSecure); Assert.IsFalse(cookie.IsHttpOnly); }
public void CookieWithNonAsciiInValue() { var cookie = WebCookie.FromString("farbe=weiß"); Assert.AreEqual("farbe", cookie.Key); Assert.AreEqual("weiß", cookie.Value); Assert.AreEqual(null, cookie.Path); Assert.IsFalse(cookie.Expires.HasValue); Assert.IsFalse(cookie.IsSecure); Assert.IsFalse(cookie.IsHttpOnly); }
public void GoogleGaps() { var cookie = WebCookie.FromString("GAPS=1:A1aaaaAaAAa1aaAaAaaAAAaaa1a11a:aaaAaAaAa-aaaA1-;Path=/;Expires=Thu, 17-Apr-2014 02:12:29 GMT;Secure;HttpOnly"); Assert.AreEqual("GAPS", cookie.Key); Assert.AreEqual("1:A1aaaaAaAAa1aaAaAaaAAAaaa1a11a:aaaAaAaAa-aaaA1-", cookie.Value); Assert.AreEqual("/", cookie.Path); Assert.AreEqual(new DateTime(2014, 4, 17), cookie.Expires.Value.Date); Assert.IsTrue(cookie.IsSecure); Assert.IsTrue(cookie.IsHttpOnly); }
public void CookieWithManyEqualSigns() { var cookie = WebCookie.FromString("queryPref=b=c&d=e; Path=/f=g; Expires=Thu, 17 Apr 2014 02:12:29 GMT; HttpOnly"); Assert.AreEqual("queryPref", cookie.Key); Assert.AreEqual("b=c&d=e", cookie.Value); Assert.AreEqual("/f=g", cookie.Path); Assert.AreEqual(new DateTime(2014, 4, 17), cookie.Expires.Value.Date); Assert.IsFalse(cookie.IsSecure); Assert.IsTrue(cookie.IsHttpOnly); }
public void ExpiringCookie() { var cookie = WebCookie.FromString("a=bcd; Expires=Tue, 18 Oct 2011 07:05:03 GMT"); Assert.AreEqual("a", cookie.Key); Assert.AreEqual("bcd", cookie.Value); Assert.IsTrue(cookie.Validate()); Assert.AreEqual(null, cookie.Path); Assert.AreEqual(null, cookie.Domain); Assert.AreEqual(new DateTime(2011, 10, 18), cookie.Expires.Value.Date); Assert.AreEqual(0, cookie.Extensions.Count()); }
public void SimpleCookie() { var cookie = WebCookie.FromString("a=bcd"); Assert.AreEqual("a", cookie.Key); Assert.AreEqual("bcd", cookie.Value); Assert.IsTrue(cookie.Validate()); Assert.AreEqual(null, cookie.Path); Assert.AreEqual(null, cookie.Domain); Assert.IsFalse(cookie.Expires.HasValue); Assert.AreEqual(0, cookie.Extensions.Count()); }
public void HttpOnlyCookieWithValue() { var cookie = WebCookie.FromString("a=b; HttpOnly=xyxz"); Assert.AreEqual("a", cookie.Key); Assert.AreEqual("b", cookie.Value); Assert.AreEqual(null, cookie.Path); Assert.AreEqual(null, cookie.Domain); Assert.IsFalse(cookie.IsSecure); Assert.IsTrue(cookie.IsHttpOnly); Assert.IsFalse(cookie.Expires.HasValue); Assert.AreEqual(0, cookie.Extensions.Count()); }
public void CookieWithTrailingSemicolons() { var cookie = WebCookie.FromString("a=b;;;;"); Assert.AreEqual("a", cookie.Key); Assert.AreEqual("b", cookie.Value); Assert.AreEqual(null, cookie.Path); Assert.AreEqual(null, cookie.Domain); Assert.IsFalse(cookie.IsSecure); Assert.IsFalse(cookie.IsHttpOnly); Assert.IsFalse(cookie.Expires.HasValue); Assert.AreEqual(0, cookie.Extensions.Count()); }
public void CookieWithInvalidExpirationDate() { var cookie = WebCookie.FromString("a=b; Expires=xyzzy"); Assert.AreEqual("a", cookie.Key); Assert.AreEqual("b", cookie.Value); Assert.AreEqual(null, cookie.Path); Assert.AreEqual(null, cookie.Domain); Assert.IsFalse(cookie.IsSecure); Assert.IsFalse(cookie.IsHttpOnly); Assert.IsFalse(cookie.Expires.HasValue); Assert.AreEqual(0, cookie.Extensions.Count()); }
public void ExpiringCookieWithPath() { var cookie = WebCookie.FromString("a=\"xyzzy!\"; Expires=Tue, 18 Oct 2011 07:05:03 GMT; Path=/aBc"); Assert.AreEqual("a", cookie.Key); Assert.AreEqual("\"xyzzy!\"", cookie.Value); Assert.AreEqual("/aBc", cookie.Path); Assert.AreEqual(null, cookie.Domain); Assert.IsFalse(cookie.IsSecure); Assert.IsFalse(cookie.IsHttpOnly); Assert.AreEqual(new DateTime(2011, 10, 18), cookie.Expires.Value.Date); Assert.AreEqual(0, cookie.Extensions.Count()); }
public void CookieWitUppercaseDomain() { var cookie = WebCookie.FromString("a=b; domain=EXAMPLE.COM"); Assert.AreEqual("a", cookie.Key); Assert.AreEqual("b", cookie.Value); Assert.AreEqual(null, cookie.Path); Assert.AreEqual("example.com", cookie.Domain); Assert.IsFalse(cookie.MaxAge.HasValue); Assert.IsFalse(cookie.IsSecure); Assert.IsFalse(cookie.IsHttpOnly); Assert.IsFalse(cookie.Expires.HasValue); Assert.AreEqual(0, cookie.Extensions.Count()); }
public void CookieWithNegativeMaxAge() { var cookie = WebCookie.FromString("a=b; Max-Age=-1"); Assert.AreEqual("a", cookie.Key); Assert.AreEqual("b", cookie.Value); Assert.AreEqual(null, cookie.Path); Assert.AreEqual(null, cookie.Domain); Assert.AreEqual(-1, cookie.MaxAge.Value); Assert.IsFalse(cookie.IsSecure); Assert.IsFalse(cookie.IsHttpOnly); Assert.IsFalse(cookie.Expires.HasValue); Assert.AreEqual(0, cookie.Extensions.Count()); }
public void CompleteCookie() { var cookie = WebCookie.FromString("abc=\"xyzzy!\"; Expires=Tue, 18 Oct 2011 07:05:03 GMT; Path=/aBc; Domain=example.com; Secure; HTTPOnly; Max-Age=1234; Foo=Bar; Baz"); Assert.AreEqual("abc", cookie.Key); Assert.AreEqual("\"xyzzy!\"", cookie.Value); Assert.AreEqual("/aBc", cookie.Path); Assert.AreEqual("example.com", cookie.Domain); Assert.IsTrue(cookie.IsSecure); Assert.IsTrue(cookie.IsHttpOnly); Assert.AreEqual(1234, cookie.MaxAge.Value); Assert.AreEqual(new DateTime(2011, 10, 18), cookie.Expires.Value.Date); Assert.AreEqual("Foo=Bar", cookie.Extensions.Skip(0).First()); Assert.AreEqual("Baz", cookie.Extensions.Skip(1).First()); }