1212from django .urls import reverse
1313from django .test import Client
1414from waffle .testutils import override_switch
15+ from apps .fhir .bluebutton .models import Crosswalk
16+ from django .contrib .auth .models import User
17+ from waffle import switch_is_active
1518
1619from apps .test import BaseApiTest
1720from ..models import Application , ArchivedToken
@@ -271,7 +274,10 @@ def test_refresh_token(self):
271274 'client_secret' : application .client_secret_plain ,
272275 }
273276 c = Client ()
274- response = c .post ('/v1/o/token/' , data = token_request_data )
277+ if switch_is_active ('v3_endpoints' ):
278+ response = c .post ('/v3/o/token/' , data = token_request_data )
279+ else :
280+ response = c .post ('/v2/o/token/' , data = token_request_data )
275281 self .assertEqual (response .status_code , 200 )
276282 # Now we have a token and refresh token
277283 tkn = response .json ()['access_token' ]
@@ -286,6 +292,14 @@ def test_refresh_token(self):
286292 response = self .client .post (reverse ('oauth2_provider:token' ), data = refresh_request_data )
287293 self .assertEqual (response .status_code , 200 )
288294 self .assertNotEqual (response .json ()['access_token' ], tkn )
295+ user = User .objects .get (username = 'anna' )
296+ crosswalk = Crosswalk .objects .get (user = user )
297+ print (f'what is in crosswalk { crosswalk .fhir_id_v3 } ' )
298+ # Verify both fhir_id_v2 and fhir_id_v3 are populated
299+ self .assertIsNotNone (crosswalk .fhir_id_v2 )
300+ self .assertIsNotNone (crosswalk .fhir_id_v3 )
301+ self .assertTrue (len (crosswalk .fhir_id_v2 ) > 0 )
302+ self .assertTrue (len (crosswalk .fhir_id_v3 ) > 0 )
289303
290304 def test_refresh_with_expired_token (self ):
291305 redirect_uri = 'http://localhost'
0 commit comments