1616from urllib .parse import urlencode
1717from datetime import datetime
1818from inspect import isawaitable
19+ from base64 import b64encode
1920from typing import Any , Dict , Union
2021
2122from django .http import HttpRequest , HttpResponse , JsonResponse
@@ -455,10 +456,10 @@ async def test_thirdparty_parsing_works(self):
455456
456457 start_st ()
457458
458- data = {
459- "state" : "afc596274293e1587315c" ,
460- "code" : "c7685e261f98e4b3b94e34b3a69ff9cf4.0.rvxt.eE8rO__6hGoqaX1B7ODPmA" ,
461- }
459+ state = b64encode ( json . dumps ({ "redirectURI" : "http://localhost:3000/redirect" }). encode ()). decode ()
460+ code = "testing"
461+
462+ data = { "state" : state , "code" : code }
462463
463464 request = self .factory .post (
464465 "/auth/callback/apple" ,
@@ -470,11 +471,9 @@ async def test_thirdparty_parsing_works(self):
470471 raise Exception ("Should never come here" )
471472 response = await temp
472473
473- self .assertEqual (response .status_code , 200 )
474- self .assertEqual (
475- response .content ,
476- b'<html><head><script>window.location.replace("http://supertokens.io/auth/callback/apple?state=afc596274293e1587315c&code=c7685e261f98e4b3b94e34b3a69ff9cf4.0.rvxt.eE8rO__6hGoqaX1B7ODPmA");</script></head></html>' ,
477- )
474+ self .assertEqual (response .status_code , 303 )
475+ self .assertEqual (response .content , b'' )
476+ self .assertEqual (response .headers ['location' ], f"http://localhost:3000/redirect?state={ state .replace ('=' , '%3D' )} &code={ code } " )
478477
479478 @pytest .mark .asyncio
480479 async def test_search_with_multiple_emails (self ):
0 commit comments