3434
3535URI_OOB = "urn:ietf:wg:oauth:2.0:oob"
3636URI_OOB_AUTO = "urn:ietf:wg:oauth:2.0:oob:auto"
37+ CLEARTEXT_SECRET = "1234567890abcdefghijklmnopqrstuvwxyz"
3738
3839
3940# mocking a protected resource view
@@ -60,6 +61,7 @@ def setUp(self):
6061 user = self .dev_user ,
6162 client_type = Application .CLIENT_CONFIDENTIAL ,
6263 authorization_grant_type = Application .GRANT_AUTHORIZATION_CODE ,
64+ client_secret = CLEARTEXT_SECRET ,
6365 )
6466
6567 def tearDown (self ):
@@ -677,7 +679,7 @@ def test_basic_auth(self):
677679 "code" : authorization_code ,
678680 "redirect_uri" : "http://example.org" ,
679681 }
680- auth_headers = get_basic_auth_header (self .application .client_id , self . application . client_secret )
682+ auth_headers = get_basic_auth_header (self .application .client_id , CLEARTEXT_SECRET )
681683
682684 response = self .client .post (reverse ("oauth2_provider:token" ), data = token_request_data , ** auth_headers )
683685 self .assertEqual (response .status_code , 200 )
@@ -699,7 +701,7 @@ def test_refresh(self):
699701 "code" : authorization_code ,
700702 "redirect_uri" : "http://example.org" ,
701703 }
702- auth_headers = get_basic_auth_header (self .application .client_id , self . application . client_secret )
704+ auth_headers = get_basic_auth_header (self .application .client_id , CLEARTEXT_SECRET )
703705
704706 response = self .client .post (reverse ("oauth2_provider:token" ), data = token_request_data , ** auth_headers )
705707 content = json .loads (response .content .decode ("utf-8" ))
@@ -744,7 +746,7 @@ def test_refresh_with_grace_period(self):
744746 "code" : authorization_code ,
745747 "redirect_uri" : "http://example.org" ,
746748 }
747- auth_headers = get_basic_auth_header (self .application .client_id , self . application . client_secret )
749+ auth_headers = get_basic_auth_header (self .application .client_id , CLEARTEXT_SECRET )
748750
749751 response = self .client .post (reverse ("oauth2_provider:token" ), data = token_request_data , ** auth_headers )
750752 content = json .loads (response .content .decode ("utf-8" ))
@@ -795,7 +797,7 @@ def test_refresh_invalidates_old_tokens(self):
795797 "code" : authorization_code ,
796798 "redirect_uri" : "http://example.org" ,
797799 }
798- auth_headers = get_basic_auth_header (self .application .client_id , self . application . client_secret )
800+ auth_headers = get_basic_auth_header (self .application .client_id , CLEARTEXT_SECRET )
799801
800802 response = self .client .post (reverse ("oauth2_provider:token" ), data = token_request_data , ** auth_headers )
801803 content = json .loads (response .content .decode ("utf-8" ))
@@ -827,7 +829,7 @@ def test_refresh_no_scopes(self):
827829 "code" : authorization_code ,
828830 "redirect_uri" : "http://example.org" ,
829831 }
830- auth_headers = get_basic_auth_header (self .application .client_id , self . application . client_secret )
832+ auth_headers = get_basic_auth_header (self .application .client_id , CLEARTEXT_SECRET )
831833
832834 response = self .client .post (reverse ("oauth2_provider:token" ), data = token_request_data , ** auth_headers )
833835 content = json .loads (response .content .decode ("utf-8" ))
@@ -855,7 +857,7 @@ def test_refresh_bad_scopes(self):
855857 "code" : authorization_code ,
856858 "redirect_uri" : "http://example.org" ,
857859 }
858- auth_headers = get_basic_auth_header (self .application .client_id , self . application . client_secret )
860+ auth_headers = get_basic_auth_header (self .application .client_id , CLEARTEXT_SECRET )
859861
860862 response = self .client .post (reverse ("oauth2_provider:token" ), data = token_request_data , ** auth_headers )
861863 content = json .loads (response .content .decode ("utf-8" ))
@@ -881,7 +883,7 @@ def test_refresh_fail_repeating_requests(self):
881883 "code" : authorization_code ,
882884 "redirect_uri" : "http://example.org" ,
883885 }
884- auth_headers = get_basic_auth_header (self .application .client_id , self . application . client_secret )
886+ auth_headers = get_basic_auth_header (self .application .client_id , CLEARTEXT_SECRET )
885887
886888 response = self .client .post (reverse ("oauth2_provider:token" ), data = token_request_data , ** auth_headers )
887889 content = json .loads (response .content .decode ("utf-8" ))
@@ -911,7 +913,7 @@ def test_refresh_repeating_requests(self):
911913 "code" : authorization_code ,
912914 "redirect_uri" : "http://example.org" ,
913915 }
914- auth_headers = get_basic_auth_header (self .application .client_id , self . application . client_secret )
916+ auth_headers = get_basic_auth_header (self .application .client_id , CLEARTEXT_SECRET )
915917
916918 response = self .client .post (reverse ("oauth2_provider:token" ), data = token_request_data , ** auth_headers )
917919 content = json .loads (response .content .decode ("utf-8" ))
@@ -948,7 +950,7 @@ def test_refresh_repeating_requests_non_rotating_tokens(self):
948950 "code" : authorization_code ,
949951 "redirect_uri" : "http://example.org" ,
950952 }
951- auth_headers = get_basic_auth_header (self .application .client_id , self . application . client_secret )
953+ auth_headers = get_basic_auth_header (self .application .client_id , CLEARTEXT_SECRET )
952954
953955 response = self .client .post (reverse ("oauth2_provider:token" ), data = token_request_data , ** auth_headers )
954956 content = json .loads (response .content .decode ("utf-8" ))
@@ -977,7 +979,7 @@ def test_basic_auth_bad_authcode(self):
977979 "code" : "BLAH" ,
978980 "redirect_uri" : "http://example.org" ,
979981 }
980- auth_headers = get_basic_auth_header (self .application .client_id , self . application . client_secret )
982+ auth_headers = get_basic_auth_header (self .application .client_id , CLEARTEXT_SECRET )
981983
982984 response = self .client .post (reverse ("oauth2_provider:token" ), data = token_request_data , ** auth_headers )
983985 self .assertEqual (response .status_code , 400 )
@@ -989,7 +991,7 @@ def test_basic_auth_bad_granttype(self):
989991 self .client .login (username = "test_user" , password = "123456" )
990992
991993 token_request_data = {"grant_type" : "UNKNOWN" , "code" : "BLAH" , "redirect_uri" : "http://example.org" }
992- auth_headers = get_basic_auth_header (self .application .client_id , self . application . client_secret )
994+ auth_headers = get_basic_auth_header (self .application .client_id , CLEARTEXT_SECRET )
993995
994996 response = self .client .post (reverse ("oauth2_provider:token" ), data = token_request_data , ** auth_headers )
995997 self .assertEqual (response .status_code , 400 )
@@ -1014,7 +1016,7 @@ def test_basic_auth_grant_expired(self):
10141016 "code" : "BLAH" ,
10151017 "redirect_uri" : "http://example.org" ,
10161018 }
1017- auth_headers = get_basic_auth_header (self .application .client_id , self . application . client_secret )
1019+ auth_headers = get_basic_auth_header (self .application .client_id , CLEARTEXT_SECRET )
10181020
10191021 response = self .client .post (reverse ("oauth2_provider:token" ), data = token_request_data , ** auth_headers )
10201022 self .assertEqual (response .status_code , 400 )
@@ -1049,7 +1051,7 @@ def test_basic_auth_wrong_auth_type(self):
10491051 "redirect_uri" : "http://example.org" ,
10501052 }
10511053
1052- user_pass = "{0}:{1}" .format (self .application .client_id , self . application . client_secret )
1054+ user_pass = "{0}:{1}" .format (self .application .client_id , CLEARTEXT_SECRET )
10531055 auth_string = base64 .b64encode (user_pass .encode ("utf-8" ))
10541056 auth_headers = {
10551057 "HTTP_AUTHORIZATION" : "Wrong " + auth_string .decode ("utf-8" ),
@@ -1070,7 +1072,7 @@ def test_request_body_params(self):
10701072 "code" : authorization_code ,
10711073 "redirect_uri" : "http://example.org" ,
10721074 "client_id" : self .application .client_id ,
1073- "client_secret" : self . application . client_secret ,
1075+ "client_secret" : CLEARTEXT_SECRET ,
10741076 }
10751077
10761078 response = self .client .post (reverse ("oauth2_provider:token" ), data = token_request_data )
@@ -1445,7 +1447,7 @@ def test_code_exchange_succeed_when_redirect_uri_match(self):
14451447 "code" : authorization_code ,
14461448 "redirect_uri" : "http://example.org?foo=bar" ,
14471449 }
1448- auth_headers = get_basic_auth_header (self .application .client_id , self . application . client_secret )
1450+ auth_headers = get_basic_auth_header (self .application .client_id , CLEARTEXT_SECRET )
14491451
14501452 response = self .client .post (reverse ("oauth2_provider:token" ), data = token_request_data , ** auth_headers )
14511453 self .assertEqual (response .status_code , 200 )
@@ -1480,7 +1482,7 @@ def test_code_exchange_fails_when_redirect_uri_does_not_match(self):
14801482 "code" : authorization_code ,
14811483 "redirect_uri" : "http://example.org?foo=baraa" ,
14821484 }
1483- auth_headers = get_basic_auth_header (self .application .client_id , self . application . client_secret )
1485+ auth_headers = get_basic_auth_header (self .application .client_id , CLEARTEXT_SECRET )
14841486
14851487 response = self .client .post (reverse ("oauth2_provider:token" ), data = token_request_data , ** auth_headers )
14861488 self .assertEqual (response .status_code , 400 )
@@ -1520,7 +1522,7 @@ def test_code_exchange_succeed_when_redirect_uri_match_with_multiple_query_param
15201522 "code" : authorization_code ,
15211523 "redirect_uri" : "http://example.com?bar=baz&foo=bar" ,
15221524 }
1523- auth_headers = get_basic_auth_header (self .application .client_id , self . application . client_secret )
1525+ auth_headers = get_basic_auth_header (self .application .client_id , CLEARTEXT_SECRET )
15241526
15251527 response = self .client .post (reverse ("oauth2_provider:token" ), data = token_request_data , ** auth_headers )
15261528 self .assertEqual (response .status_code , 200 )
@@ -1565,7 +1567,7 @@ def test_oob_as_html(self):
15651567 "code" : authorization_code ,
15661568 "redirect_uri" : URI_OOB ,
15671569 "client_id" : self .application .client_id ,
1568- "client_secret" : self . application . client_secret ,
1570+ "client_secret" : CLEARTEXT_SECRET ,
15691571 }
15701572
15711573 response = self .client .post (reverse ("oauth2_provider:token" ), data = token_request_data )
@@ -1605,7 +1607,7 @@ def test_oob_as_json(self):
16051607 "code" : authorization_code ,
16061608 "redirect_uri" : URI_OOB_AUTO ,
16071609 "client_id" : self .application .client_id ,
1608- "client_secret" : self . application . client_secret ,
1610+ "client_secret" : CLEARTEXT_SECRET ,
16091611 }
16101612
16111613 response = self .client .post (reverse ("oauth2_provider:token" ), data = token_request_data )
@@ -1681,7 +1683,7 @@ def test_id_token_code_exchange_succeed_when_redirect_uri_match_with_multiple_qu
16811683 "code" : authorization_code ,
16821684 "redirect_uri" : "http://example.com?bar=baz&foo=bar" ,
16831685 }
1684- auth_headers = get_basic_auth_header (self .application .client_id , self . application . client_secret )
1686+ auth_headers = get_basic_auth_header (self .application .client_id , CLEARTEXT_SECRET )
16851687
16861688 response = self .client .post (reverse ("oauth2_provider:token" ), data = token_request_data , ** auth_headers )
16871689 self .assertEqual (response .status_code , 200 )
@@ -1715,7 +1717,7 @@ def test_id_token(self):
17151717 "code" : authorization_code ,
17161718 "redirect_uri" : "http://example.org" ,
17171719 "client_id" : self .application .client_id ,
1718- "client_secret" : self . application . client_secret ,
1720+ "client_secret" : CLEARTEXT_SECRET ,
17191721 "scope" : "openid" ,
17201722 }
17211723
@@ -1761,7 +1763,7 @@ def test_resource_access_allowed(self):
17611763 "code" : authorization_code ,
17621764 "redirect_uri" : "http://example.org" ,
17631765 }
1764- auth_headers = get_basic_auth_header (self .application .client_id , self . application . client_secret )
1766+ auth_headers = get_basic_auth_header (self .application .client_id , CLEARTEXT_SECRET )
17651767
17661768 response = self .client .post (reverse ("oauth2_provider:token" ), data = token_request_data , ** auth_headers )
17671769 content = json .loads (response .content .decode ("utf-8" ))
@@ -1819,7 +1821,7 @@ def test_id_token_resource_access_allowed(self):
18191821 "code" : authorization_code ,
18201822 "redirect_uri" : "http://example.org" ,
18211823 }
1822- auth_headers = get_basic_auth_header (self .application .client_id , self . application . client_secret )
1824+ auth_headers = get_basic_auth_header (self .application .client_id , CLEARTEXT_SECRET )
18231825
18241826 response = self .client .post (reverse ("oauth2_provider:token" ), data = token_request_data , ** auth_headers )
18251827 content = json .loads (response .content .decode ("utf-8" ))
0 commit comments