From ed26536c066900e83e5fc14e16a757e221454dea Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Mon, 29 Jul 2024 15:35:06 +0200 Subject: [PATCH] Fix tests --- test_seasurf.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test_seasurf.py b/test_seasurf.py index d51396e..261624f 100644 --- a/test_seasurf.py +++ b/test_seasurf.py @@ -93,7 +93,7 @@ def test_json_token_validation_bad(self): with self.app.test_client() as client: with client.session_transaction() as sess: sess[self.csrf._csrf_name] = tokenA - client.set_cookie('www.example.com', self.csrf._csrf_name, tokenB) + client.set_cookie(domain='www.example.com', key=self.csrf._csrf_name, value=tokenB) rv = client.post('/bar', data=data) self.assertEqual(rv.status_code, 403, rv) @@ -107,7 +107,7 @@ def test_json_token_validation_good(self): data = {'_csrf_token': token} with self.app.test_client() as client: with client.session_transaction() as sess: - client.set_cookie('www.example.com', self.csrf._csrf_name, token) + client.set_cookie(domain='www.example.com', key=self.csrf._csrf_name, value=token) sess[self.csrf._csrf_name] = token rv = client.post('/bar', data=data) @@ -124,7 +124,7 @@ def test_token_with_non_ascii_chars(self): with self.app.test_client() as client: with client.session_transaction() as sess: sess[self.csrf._csrf_name] = tokenA - client.set_cookie('www.example.com', self.csrf._csrf_name, tokenB) + client.set_cookie(domain='www.example.com', key=self.csrf._csrf_name, value=tokenB) rv = client.post('/bar', data=data) self.assertEqual(rv.status_code, 403, rv) @@ -134,7 +134,7 @@ def test_https_bad_referer(self): with client.session_transaction() as sess: token = self.csrf._generate_token() - client.set_cookie('www.example.com', self.csrf._csrf_name, token) + client.set_cookie(domain='www.example.com', key=self.csrf._csrf_name, value=token) sess[self.csrf._csrf_name] = token # once this is reached the session was stored @@ -154,10 +154,10 @@ def test_https_bad_referer(self): def test_https_good_referer(self): with self.app.test_client() as client: - with client.session_transaction() as sess: + with client.session_transaction(base_url="https://www.example.com") as sess: token = self.csrf._generate_token() - client.set_cookie('www.example.com', self.csrf._csrf_name, token) + client.set_cookie(domain='www.example.com', key=self.csrf._csrf_name, value=token) sess[self.csrf._csrf_name] = token # once this is reached the session was stored @@ -180,7 +180,7 @@ def test_malformed_referer(self): with client.session_transaction() as sess: token = self.csrf._generate_token() - client.set_cookie('www.example.com', self.csrf._csrf_name, token) + client.set_cookie(domain='www.example.com', key=self.csrf._csrf_name, value=token) sess[self.csrf._csrf_name] = token rv = client.post('/bar', @@ -661,10 +661,10 @@ def bar(term=None): def test_https_referer_check_disabled(self): with self.app.test_client() as client: - with client.session_transaction() as sess: + with client.session_transaction(base_url="https://www.example.com") as sess: token = self.csrf._generate_token() - client.set_cookie('www.example.com', self.csrf._csrf_name, token) + client.set_cookie(domain='www.example.com', key=self.csrf._csrf_name, value=token) sess[self.csrf._csrf_name] = token # once this is reached the session was stored @@ -802,7 +802,7 @@ def test_generate_new_token(self): client.get('/foo') tokenA = self.csrf._get_token() - client.set_cookie('www.example.com', self.csrf._csrf_name, tokenA) + client.set_cookie(domain='www.example.com', key=self.csrf._csrf_name, value=tokenA) with client.session_transaction() as sess: sess[self.csrf._csrf_name] = tokenA