def test_httponly(self): cookie = Cookie('color', 'blue', httponly=True) self.assertTrue(cookie.http_return_ok('http://example.com')) self.assertTrue(cookie.http_return_ok('https://example.com')) with self.assertRaises(Cookie.URLMismatch): self.assertTrue(cookie.http_return_ok('ftp://example.com'))
def test_httponly(self): cookie = Cookie("color", "blue", httponly=True) self.assertTrue(cookie.http_return_ok("http://example.com")) self.assertTrue(cookie.http_return_ok("https://example.com")) with self.assertRaises(Cookie.URLMismatch): self.assertTrue(cookie.http_return_ok("ftp://example.com"))
def test_httponly(self): cookie = Cookie('color', 'blue', httponly=True) assert cookie.http_return_ok('http://example.com') assert cookie.http_return_ok('https://example.com') with pytest.raises(Cookie.URLMismatch): assert cookie.http_return_ok('ftp://example.com')
def test_httponly(self): cookie = Cookie('color', 'blue', httponly=True) self.assertTrue(cookie.http_return_ok('http://example.com')) self.assertTrue(cookie.http_return_ok('https://example.com')) with self.assertRaises(Cookie.URLMismatch): self.assertTrue(cookie.http_return_ok('ftp://example.com'))
def test_path(self): cookie = Cookie('color', 'blue') self.assertTrue(cookie.http_return_ok(self.url)) cookie = Cookie('color', 'blue', path='/') self.assertTrue(cookie.http_return_ok(self.url)) cookie = Cookie('color', 'blue', path='/one') self.assertTrue(cookie.http_return_ok(self.url)) cookie = Cookie('color', 'blue', path='/oneX') with self.assertRaises(Cookie.URLMismatch): self.assertTrue(cookie.http_return_ok(self.url))
def test_path(self): cookie = Cookie('color', 'blue') self.assertTrue(cookie.http_return_ok(self.url)) cookie = Cookie('color', 'blue', path='/') self.assertTrue(cookie.http_return_ok(self.url)) cookie = Cookie('color', 'blue', path='/one') self.assertTrue(cookie.http_return_ok(self.url)) cookie = Cookie('color', 'blue', path='/oneX') with self.assertRaises(Cookie.URLMismatch): self.assertTrue(cookie.http_return_ok(self.url))
def test_path(self): cookie = Cookie('color', 'blue') assert cookie.http_return_ok(self.url) cookie = Cookie('color', 'blue', path='/') assert cookie.http_return_ok(self.url) cookie = Cookie('color', 'blue', path='/one') assert cookie.http_return_ok(self.url) cookie = Cookie('color', 'blue', path='/oneX') with pytest.raises(Cookie.URLMismatch): assert cookie.http_return_ok(self.url)
def test_path(self): cookie = Cookie("color", "blue") self.assertTrue(cookie.http_return_ok(self.url)) cookie = Cookie("color", "blue", path="/") self.assertTrue(cookie.http_return_ok(self.url)) cookie = Cookie("color", "blue", path="/one") self.assertTrue(cookie.http_return_ok(self.url)) cookie = Cookie("color", "blue", path="/oneX") with self.assertRaises(Cookie.URLMismatch): self.assertTrue(cookie.http_return_ok(self.url))
def test_expires(self): now = datetime.datetime.utcnow().replace(microsecond=0) # expires 1 day from now expires = now + datetime.timedelta(days=1) cookie = Cookie('color', 'blue', expires=expires) self.assertTrue(cookie.http_return_ok(self.url)) # expired 1 day ago expires = now + datetime.timedelta(days=-1) cookie = Cookie('color', 'blue', expires=expires) with self.assertRaises(Cookie.Expired): self.assertTrue(cookie.http_return_ok(self.url))
def test_expires(self): now = datetime.datetime.utcnow().replace(microsecond=0) # expires 1 day from now expires = now + datetime.timedelta(days=1) cookie = Cookie('color', 'blue', expires=expires) assert cookie.http_return_ok(self.url) # expired 1 day ago expires = now + datetime.timedelta(days=-1) cookie = Cookie('color', 'blue', expires=expires) with pytest.raises(Cookie.Expired): assert cookie.http_return_ok(self.url)
def test_domain(self): cookie = Cookie('color', 'blue', domain='www.foo.bar.com') assert cookie.http_return_ok(self.url) cookie = Cookie('color', 'blue', domain='.foo.bar.com') assert cookie.http_return_ok(self.url) cookie = Cookie('color', 'blue', domain='.bar.com') assert cookie.http_return_ok(self.url) cookie = Cookie('color', 'blue', domain='bar.com') with pytest.raises(Cookie.URLMismatch): assert cookie.http_return_ok(self.url) cookie = Cookie('color', 'blue', domain='bogus.com') with pytest.raises(Cookie.URLMismatch): assert cookie.http_return_ok(self.url) cookie = Cookie('color', 'blue', domain='www.foo.bar.com') with pytest.raises(Cookie.URLMismatch): assert cookie.http_return_ok('http://192.168.1.1/one/two')
def test_domain(self): cookie = Cookie('color', 'blue', domain='www.foo.bar.com') self.assertTrue(cookie.http_return_ok(self.url)) cookie = Cookie('color', 'blue', domain='.foo.bar.com') self.assertTrue(cookie.http_return_ok(self.url)) cookie = Cookie('color', 'blue', domain='.bar.com') self.assertTrue(cookie.http_return_ok(self.url)) cookie = Cookie('color', 'blue', domain='bar.com') with self.assertRaises(Cookie.URLMismatch): self.assertTrue(cookie.http_return_ok(self.url)) cookie = Cookie('color', 'blue', domain='bogus.com') with self.assertRaises(Cookie.URLMismatch): self.assertTrue(cookie.http_return_ok(self.url)) cookie = Cookie('color', 'blue', domain='www.foo.bar.com') with self.assertRaises(Cookie.URLMismatch): self.assertTrue(cookie.http_return_ok('http://192.168.1.1/one/two'))
def test_domain(self): cookie = Cookie("color", "blue", domain="www.foo.bar.com") self.assertTrue(cookie.http_return_ok(self.url)) cookie = Cookie("color", "blue", domain=".foo.bar.com") self.assertTrue(cookie.http_return_ok(self.url)) cookie = Cookie("color", "blue", domain=".bar.com") self.assertTrue(cookie.http_return_ok(self.url)) cookie = Cookie("color", "blue", domain="bar.com") with self.assertRaises(Cookie.URLMismatch): self.assertTrue(cookie.http_return_ok(self.url)) cookie = Cookie("color", "blue", domain="bogus.com") with self.assertRaises(Cookie.URLMismatch): self.assertTrue(cookie.http_return_ok(self.url)) cookie = Cookie("color", "blue", domain="www.foo.bar.com") with self.assertRaises(Cookie.URLMismatch): self.assertTrue(cookie.http_return_ok("http://192.168.1.1/one/two"))
def test_secure(self): cookie = Cookie('color', 'blue', secure=True) self.assertTrue(cookie.http_return_ok('https://Xexample.com')) with self.assertRaises(Cookie.URLMismatch): self.assertTrue(cookie.http_return_ok('http://Xexample.com'))
def test_secure(self): cookie = Cookie("color", "blue", secure=True) self.assertTrue(cookie.http_return_ok("https://Xexample.com")) with self.assertRaises(Cookie.URLMismatch): self.assertTrue(cookie.http_return_ok("http://Xexample.com"))
def test_no_attributes(self): cookie = Cookie('color', 'blue') assert cookie.http_return_ok(self.url)
def test_secure(self): cookie = Cookie('color', 'blue', secure=True) self.assertTrue(cookie.http_return_ok('https://Xexample.com')) with self.assertRaises(Cookie.URLMismatch): self.assertTrue(cookie.http_return_ok('http://Xexample.com'))
def test_no_attributes(self): cookie = Cookie('color', 'blue') self.assertTrue(cookie.http_return_ok(self.url))
def test_secure(self): cookie = Cookie('color', 'blue', secure=True) assert cookie.http_return_ok('https://Xexample.com') with pytest.raises(Cookie.URLMismatch): assert cookie.http_return_ok('http://Xexample.com')
def test_no_attributes(self): cookie = Cookie("color", "blue") self.assertTrue(cookie.http_return_ok(self.url))