@@ -141,6 +141,26 @@ def test_authorization_url_access_type(self, instance):
141141 code_challenge = '2yN0TOdl0gkGwFOmtfx3f913tgEaLM2d2S0WlmG1Z6Q' ,
142142 code_challenge_method = 'S256' )
143143
144+ def test_authorization_url_generated_verifier (self ):
145+ scope = 'scope_one'
146+ instance = flow .Flow .from_client_config (
147+ CLIENT_SECRETS_INFO , scopes = [scope ], autogenerate_code_verifier = True )
148+ authorization_url_path = mock .patch .object (
149+ instance .oauth2session , 'authorization_url' ,
150+ wraps = instance .oauth2session .authorization_url )
151+
152+ with authorization_url_path as authorization_url_spy :
153+ instance .authorization_url ()
154+
155+ _ , kwargs = authorization_url_spy .call_args_list [0 ]
156+ assert kwargs ['code_challenge_method' ] == 'S256'
157+ assert len (instance .code_verifier ) == 128
158+ assert len (kwargs ['code_challenge' ]) == 43
159+ valid_verifier = r'^[A-Za-z0-9-._~]*$'
160+ valid_challenge = r'^[A-Za-z0-9-_]*$'
161+ assert re .match (valid_verifier , instance .code_verifier )
162+ assert re .match (valid_challenge , kwargs ['code_challenge' ])
163+
144164 def test_fetch_token (self , instance ):
145165 instance .code_verifier = 'amanaplanacanalpanama'
146166 fetch_token_patch = mock .patch .object (
0 commit comments