File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import responses
22from tests .publisher .endpoint_testing import BaseTestCases
3+ from webapp .authentication import SESSION_DATA_KEYS
34
45# Make sure tests fail on stray responses.
56responses .mock .assert_all_requests_are_fired = True
@@ -13,8 +14,14 @@ def setUp(self):
1314
1415 @responses .activate
1516 def test_logout (self ):
17+ with self .client .session_transaction () as session :
18+ for key in SESSION_DATA_KEYS :
19+ session [key ] = "MOCK VALUE"
20+
1621 response = self .client .get (self .endpoint_url )
1722
1823 self .assertEqual (302 , response .status_code )
1924
2025 self .assertEqual ("/" , response .location )
26+
27+ self .assertIn ("session=;" , response .headers .get ("Set-Cookie" ))
Original file line number Diff line number Diff line change 2020]
2121
2222
23+ SESSION_DATA_KEYS = [
24+ "macaroons" ,
25+ "macaroon_root" ,
26+ "macaroon_discharge" ,
27+ "publisher" ,
28+ "github_auth_secret" ,
29+ "developer_token" ,
30+ "exchanged_developer_token" ,
31+ "csrf_token" ,
32+ ] # keys for data stored in the session that should be cleared on logout
33+
34+
2335def get_authorization_header (root , discharge ):
2436 """
2537 Bind root and discharge macaroons and return the authorization header.
@@ -52,11 +64,8 @@ def empty_session(session):
5264 """
5365 Empty the session, used to logout.
5466 """
55- session .pop ("macaroons" , None )
56- session .pop ("macaroon_root" , None )
57- session .pop ("macaroon_discharge" , None )
58- session .pop ("publisher" , None )
59- session .pop ("github_auth_secret" , None )
67+ for key in SESSION_DATA_KEYS :
68+ session .pop (key , None )
6069
6170
6271def get_caveat_id (root ):
You can’t perform that action at this time.
0 commit comments