Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alanhamlett committed Jul 29, 2024
1 parent f7f54f2 commit ed26536
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions test_seasurf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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',
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit ed26536

Please sign in to comment.