def _TestGenerateMergeToken(self, identity_key, user_cookie, error_if_linked=None): """Invokes the merge_token auth API that triggers the email of a Viewfinder access token. Validates that an identity was created. Returns a source_identity_dict that can be passed directly to merge_accounts. """ url = self._tester.GetUrl('/merge_token/viewfinder') request_dict = {'headers': {'version': message.MAX_SUPPORTED_MESSAGE_VERSION, 'synchronous': True}, 'identity': identity_key} util.SetIfNotNone(request_dict, 'error_if_linked', error_if_linked) auth_test._SendAuthRequest(self._tester, url, 'POST', user_cookie=user_cookie, request_dict=request_dict) identity = self._RunAsync(Identity.Query, self._client, identity_key, None) # Validate the identity. self._validator.ValidateUpdateDBObject(Identity, key=identity_key, authority='Viewfinder', user_id=identity.user_id, access_token=identity.access_token, expires=identity.expires) return {'identity': identity.key, 'access_token': identity.access_token}
def _TestGenerateMergeToken(self, identity_key, user_cookie, error_if_linked=None): """Invokes the merge_token auth API that triggers the email of a Viewfinder access token. Validates that an identity was created. Returns a source_identity_dict that can be passed directly to merge_accounts. """ url = self._tester.GetUrl('/merge_token/viewfinder') request_dict = { 'headers': { 'version': message.MAX_SUPPORTED_MESSAGE_VERSION, 'synchronous': True }, 'identity': identity_key } util.SetIfNotNone(request_dict, 'error_if_linked', error_if_linked) auth_test._SendAuthRequest(self._tester, url, 'POST', user_cookie=user_cookie, request_dict=request_dict) identity = self._RunAsync(Identity.Query, self._client, identity_key, None) # Validate the identity. self._validator.ValidateUpdateDBObject( Identity, key=identity_key, authority='Viewfinder', user_id=identity.user_id, access_token=identity.access_token, expires=identity.expires) return { 'identity': identity.key, 'access_token': identity.access_token }
def testSuppressAuthNameMigration(self): """Test migrator that removes names from non-register auth messages.""" user_dict = {'name': 'Andy Kimball', 'given_name': 'Andy', 'family_name': 'Kimball', 'email': '*****@*****.**'} user, device_id = self._tester.RegisterViewfinderUser(user_dict, None) user_cookie = self._GetSecureUserCookie(user, device_id) url = self._tester.GetUrl('/link/viewfinder') request_dict = {'headers': {'version': Message.RENAME_PHOTO_LABEL, 'synchronous': True}, 'auth_info': {'identity': 'Email:[email protected]', 'name': 'Andy Kimball', 'given_name': 'Andy', 'family_name': 'Kimball'}} response = auth_test._SendAuthRequest(self._tester, url, 'POST', user_cookie=user_cookie, request_dict=request_dict) self.assertEqual(response.code, 200)