desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Test various short URL error cases.'
| def testShortURLErrors(self):
| url = self.get_url('/test/1234567890')
response = self._RunAsync(self.http_client.fetch, url, method='GET')
self.assertEqual(response.code, 404)
url = self.get_url('/test/1')
response = self._RunAsync(self.http_client.fetch, url, method='GET')
self.assertEqual(response.code, 400)
util._TEST_... |
'Test the short domain redirect handler.'
| def testShortDomainRedirectHandler(self):
| url = ('http://%s:%d/p12345' % (options.options.short_domain, self.get_http_port()))
response = self._RunAsync(self.http_client.fetch, url, method='GET', follow_redirects=False)
self.assertEqual(response.code, 302)
self.assertEqual(response.headers['location'], 'https://goviewfinder.com/pr/12345')
|
'Remove single follower from viewpoint.'
| def testRemoveFollower(self):
| self._tester.RemoveFollowers(self._cookie, self._vp_id, [self._user2.user_id])
response_dict = self._tester.QueryFollowed(self._cookie2)
vp_dict = util.GetSingleListItem([vp_dict for vp_dict in response_dict['viewpoints'] if (vp_dict['viewpoint_id'] == self._vp_id)])
self.assertIn('removed', vp_dict['la... |
'Remove multiple followers from viewpoint.'
| def testRemoveMultipleFollowers(self):
| self._tester.RemoveFollowers(self._cookie, self._vp_id, [self._user.user_id, self._user2.user_id])
|
'Remove self from viewpoint, with no permission to remove others.'
| def testRemoveOnlySelf(self):
| self._tester.RemoveFollowers(self._cookie2, self._vp_id, [self._user2.user_id])
|
'Remove a follower after adding it to a viewpoint.'
| def testRemoveAfterAdd(self):
| (vp_id, _) = self._ShareSimpleTestAssets([])
self._tester.AddFollowers(self._cookie, vp_id, [self._user2.user_id])
self._tester.RemoveFollowers(self._cookie, vp_id, [self._user2.user_id])
|
'Remove same followers multiple times.'
| def testDuplicateFollowers(self):
| self._tester.RemoveFollowers(self._cookie, self._vp_id, [self._user2.user_id])
self._tester.RemoveFollowers(self._cookie, self._vp_id, [self._user3.user_id])
self._tester.RemoveFollowers(self._cookie, self._vp_id, [self._user2.user_id, self._user3.user_id])
|
'Remove a viewpoint, then remove the follower.'
| def testRemoveAfterRemoveViewpoint(self):
| self._tester.RemoveViewpoint(self._cookie2, self._vp_id)
self._tester.RemoveViewpoint(self._cookie3, self._vp_id)
self._tester.RemoveFollowers(self._cookie, self._vp_id, [self._user2.user_id])
self._tester.PostComment(self._cookie, self._vp_id, 'try to revive user #2')
response_dict = se... |
'Force op failure in order to test idempotency.'
| @mock.patch.object(Operation, 'FAILPOINTS_ENABLED', True)
def testIdempotency(self):
| self._tester.RemoveFollowers(self._cookie, self._vp_id, [self._user3.user_id])
self._tester.RemoveFollowers(self._cookie, self._vp_id, [self._user2.user_id, self._user3.user_id])
|
'Try to remove followers that don\'t exist on viewpoint.'
| def testNonFollowers(self):
| self._tester.RemoveFollowers(self._cookie, self._vp_id, [self._user3.user_id, 1000, 1001])
|
'Remove empty set of followers.'
| def testEmptyFollowers(self):
| self._tester.RemoveFollowers(self._cookie, self._vp_id, [])
|
'Ensure that removed follower has lost all permissions on the viewpoint.'
| def testRemovedFollowerPermission(self):
| self._tester.RemoveFollowers(self._cookie, self._vp_id, [self._user2.user_id])
self.assertRaisesHttpError(403, self._tester.ShareExisting, self._cookie2, self._vp_id, [(self._ep_id, self._photo_ids)])
self.assertRaisesHttpError(403, self._tester.AddFollowers, self._cookie2, self._vp_id, [self._user.user_id]... |
'ERROR: Try to remove follower from viewpoint that doesn\'t exist.'
| def testNonExistentViewpoint(self):
| self.assertRaisesHttpError(404, self._tester.RemoveFollowers, self._cookie, 'vunk', [self._user.user_id])
|
'ERROR: Try to remove user from own default viewpoint.'
| def testDefaultViewpoint(self):
| self.assertRaisesHttpError(403, self._tester.RemoveFollowers, self._cookie, self._user.private_vp_id, [self._user.user_id])
|
'ERROR: Try to remove follower from viewpoint that is not followed.'
| def testNotFollower(self):
| (vp_id, _) = self._ShareSimpleTestAssets([self._user2.user_id])
self.assertRaisesHttpError(403, self._tester.RemoveFollowers, self._cookie3, vp_id, [self._user3.user_id])
|
'ERROR: Try to remove follower from viewpoint without CONTRIBUTOR rights.'
| def testNotContributor(self):
| self._UpdateOrAllocateDBObject(Follower, viewpoint_id=self._vp_id, user_id=self._user3.user_id, labels=[])
self.assertRaisesHttpError(403, self._tester.RemoveFollowers, self._cookie3, self._vp_id, [self._user3.user_id])
|
'ERROR: Try to remove a follower not added by that user.'
| def testRemoveFollowerNotAdded(self):
| self.assertRaisesHttpError(403, self._tester.RemoveFollowers, self._cookie2, self._vp_id, [self._user3.user_id])
|
'ERROR: Try to remove a follower added more than 7 days ago.'
| def testRemoveOldFollower(self):
| util._TEST_TIME -= constants.SECONDS_PER_WEEK
(vp_id, _) = self._ShareSimpleTestAssets([self._user2.user_id])
util._TEST_TIME += (constants.SECONDS_PER_WEEK + 1)
self.assertRaisesHttpError(403, self._tester.RemoveFollowers, self._cookie, vp_id, [self._user2.user_id])
|
'Remove a viewpoint from a user\'s inbox.'
| def testRemoveViewpoint(self):
| self._UpdateOrAllocateDBObject(Follower, user_id=self._user.user_id, viewpoint_id=self._new_vp_id, labels=[])
self._tester.RemoveViewpoint(self._cookie, self._new_vp_id)
follower = self._RunAsync(Follower.Query, self._client, self._user.user_id, self._new_vp_id, None)
self.assertTrue(follower.IsRemoved(... |
'Error: Remove a viewpoint and then attempt other operations against that viewpoint.'
| def testAccessAfterRemoveViewpoint(self):
| self._UpdateOrAllocateDBObject(Follower, user_id=self._user.user_id, viewpoint_id=self._new_vp_id, labels=[])
self._tester.RemoveViewpoint(self._cookie, self._new_vp_id)
self.assertRaisesHttpError(403, self._tester.AddFollowers, self._cookie, self._new_vp_id, ['Email:extra.user1@emailscrubbed.com'])
sel... |
'Error: Remove a non-existent viewpoint.'
| def testRemoveNonExistentViewpointFails(self):
| vp_id = Viewpoint.ConstructViewpointId(self._device_ids[0], 129)
self.assertRaisesHttpError(403, self._tester.RemoveViewpoint, self._cookie, vp_id)
|
'Remove a viewpoint that was created by another user.'
| def testRemoveViewpointCreatedByOtherUser(self):
| self._UpdateOrAllocateDBObject(Follower, user_id=self._user2.user_id, viewpoint_id=self._new_vp_id, labels=[])
self._tester.RemoveViewpoint(self._cookie2, self._new_vp_id)
|
'Error: Remove a viewpoint which user isn\'t following.'
| def testRemoveViewpointThatUserIsNotFollowingFails(self):
| self.assertRaisesHttpError(403, self._tester.RemoveViewpoint, self._cookie3, self._new_vp_id)
|
'Error: Remove a viewpoint that\'s not owned by the user.'
| def testRemoveDefaultViewpointFails(self):
| self._UpdateOrAllocateDBObject(Follower, user_id=self._user.user_id, viewpoint_id=self._user.private_vp_id, labels=[])
self.assertRaisesHttpError(403, self._tester.RemoveViewpoint, self._cookie, self._user.private_vp_id)
|
'Share photo from originator to user2, non-owner removes viewpoint, then owner unshares.'
| def testRemoveViewpointByNonOwnerAndUnshare(self):
| self._tester.RemoveViewpoint(self._cookie2, self._new_vp_id)
self._tester.Unshare(self._cookie, self._new_vp_id, [(self._new_ep_id, self._photo_ids[:1])])
|
'Re-share photos, remove the reshared viewpoint, then unshare the source viewpoint.'
| def testUnshareSecondLevelRemoved(self):
| (child_vp_id, child_ep_ids) = self._tester.ShareNew(self._cookie2, [(self._new_ep_id, self._photo_ids)], [self._user3.user_id], **self._CreateViewpointDict(self._cookie2))
self._tester.RemoveViewpoint(self._cookie3, child_vp_id)
self._tester.Unshare(self._cookie, self._new_vp_id, [(self._new_ep_id, self._ph... |
'Test removing multiple followers and then observe that they\'re all revived.'
| def testRevivalAfterRemovingMultipleFollowers(self):
| self._tester.AddFollowers(self._cookie, self._new_vp_id, ['Email:user3@emailscrubbed.com'])
self._tester.RemoveViewpoint(self._cookie2, self._new_vp_id)
self._tester.RemoveViewpoint(self._cookie3, self._new_vp_id)
self._tester.UpdateViewpoint(self._cookie, self._new_vp_id, description='a new descr... |
'Test revival of removed follower after updating viewpoint.'
| def testUpdateViewpointAfterRemoveViewpoint(self):
| self._skip_validation_for = ['Alerts']
self._tester.RemoveViewpoint(self._cookie2, self._new_vp_id)
self._tester.UpdateViewpoint(self._cookie, self._new_vp_id, title='a new title')
|
'Test revival of removed follower after updating an episode in viewpoint.'
| def testUpdateEpisodeAfterRemoveViewpoint(self):
| self._tester.RemoveViewpoint(self._cookie2, self._new_vp_id)
self._tester.UpdateEpisode(self._cookie, self._episode_id, description='A newly added description')
|
'Test revival of removed follower after adding follower to viewpoint.'
| def testAddFollowersAfterRemoveViewpoint(self):
| self._tester.RemoveViewpoint(self._cookie2, self._new_vp_id)
self._tester.AddFollowers(self._cookie, self._new_vp_id, ['Email:extra.user1@emailscrubbed.com'])
|
'Test revival of removed follower after posting comment to viewpoint.'
| def testPostCommentAfterRemoveViewpoint(self):
| self._tester.RemoveViewpoint(self._cookie2, self._new_vp_id)
self._tester.PostComment(self._cookie, self._new_vp_id, message='My enlightening comment.')
|
'Test that sharing to an existing viewpoint revives the removed follower.'
| def testShareExistingAfterRemoveViewpoint(self):
| self._tester.RemoveViewpoint(self._cookie2, self._new_vp_id)
self._tester.ShareExisting(self._cookie, self._new_vp_id, [(self._episode_id2, self._photo_ids2)])
|
'Force op failure in order to test idempotency.'
| @mock.patch.object(Operation, 'FAILPOINTS_ENABLED', True)
def testIdempotency(self):
| self._tester.RemoveViewpoint(self._cookie2, self._new_vp_id)
self._tester.RemoveViewpoint(self._cookie2, self._new_vp_id)
|
'Verify a single user query.'
| def testQueryUser(self):
| response_dict = self._tester.QueryUsers(self._cookie, [self._andy_user.user_id])
self.assertEqual(len(response_dict['users']), 1)
|
'Verify multiple users query.'
| def testQueryMultiple(self):
| response_dict = self._tester.QueryUsers(self._cookie, [self._andy_user.user_id, self._user3.user_id])
self.assertEqual(len(response_dict['users']), 2)
|
'Verify query for own user id.'
| def testQuerySelf(self):
| response_dict = self._tester.QueryUsers(self._cookie, [self._user.user_id])
self.assertEqual(len(response_dict['users']), 1)
|
'Verify that no friendship means the user\'s profile won\'t be revealed, but that certain
labels will be returned.'
| def testNoFriendship(self):
| response_dict = self._tester.QueryUsers(self._cookie2, [self._user.user_id])
self.assertEqual(response_dict['users'][0], {'labels': ['registered'], 'user_id': self._user.user_id})
|
'Verify a user with as few fields as possible.'
| def testMinimalUser(self):
| user_dict = {'name': 'Andrew Kimball', 'given_name': 'Andy', 'email': 'andy@emailscrubbed.com'}
(min_user, device_id) = self._tester.RegisterViewfinderUser(user_dict, {})
cookie = self._tester.GetSecureUserCookie(min_user.user_id, device_id, 'Andy')
response_dict = self._tester.QueryUsers(cookie, [mi... |
'Verify that non-existent user results in empty record.'
| def testUnknown(self):
| response_dict = self._tester.QueryUsers(self._cookie, [100])
self.assertEqual(len(response_dict['users']), 0)
|
'Verify that a mix of friends, strangers, and unknown user ids
returns correct subset.'
| def testMix(self):
| identity = self._RunAsync(Identity.Query, self._client, 'Local:prospective', None)
response_dict = self._tester.QueryUsers(self._cookie, [self._user.user_id, self._user2.user_id, self._user3.user_id, identity.user_id, self._andy_user.user_id, 1000])
self.assertEqual(len(response_dict['users']), 5)
|
'Verify that only sub-set of user labels are projected.'
| def testLabels(self):
| self._UpdateOrAllocateDBObject(User, user_id=self._andy_user.user_id, labels=[User.STAGING, User.REGISTERED])
response_dict = self._tester.QueryUsers(self._cookie, [self._andy_user.user_id])
self.assertEqual(response_dict['users'][0]['labels'], [User.REGISTERED, 'friend'])
|
'Verify that a blocked friendship still returns user profile info.'
| def testBlockedFriendship(self):
| self._UpdateOrAllocateDBObject(Friend, user_id=self._andy_user.user_id, friend_id=self._user.user_id, status=Friend.BLOCKED)
response_dict = self._tester.QueryUsers(self._cookie, [self._andy_user.user_id])
self.assertIn('name', response_dict['users'][0])
|
'Verify that a muted friendship can be queried.'
| def testMutedFriendship(self):
| self._UpdateOrAllocateDBObject(Friend, user_id=self._andy_user.user_id, friend_id=self._user.user_id, status=Friend.MUTED)
response_dict = self._tester.QueryUsers(self._cookie, [self._andy_user.user_id])
self.assertEqual(len(response_dict['users']), 1)
|
'Query for a user with non-empty account settings.'
| def testAccountSettings(self):
| self._tester.UpdateUser(self._cookie, settings_dict={'email_alerts': 'on_share_new', 'sms_alerts': 'on_share_new', 'storage_options': ['use_cloud']})
response_dict = self._tester.QueryUsers(self._cookie, [self._user.user_id])
self.assertTrue(('account_settings' in response_dict['users'][0]['private']))
|
'Test friendships in which only one of the users considers the other a friend.'
| def testOneSidedFriendships(self):
| self._tester.UpdateFriend(self._cookie, user_id=self._user2.user_id, nickname='Jimmy John')
response = self._tester.QueryUsers(self._cookie, [self._user2.user_id])
self.assertEqual(response['users'][0], {'labels': ['registered'], 'user_id': self._user2.user_id, 'nickname': 'Jimmy John'})
response ... |
'Test the no_password field in the user\'s private section.'
| def testNoPassword(self):
| response_dict = self._tester.QueryUsers(self._cookie, [self._user.user_id])
self.assertEqual(response_dict['users'][0]['private']['no_password'], True)
self._tester.UpdateUser(self._cookie, password='supersecure')
response_dict = self._tester.QueryUsers(self._cookie, [self._user.user_id])
self.asser... |
'Tests various episode queries.'
| def testQueryEpisodes(self):
| cookie = self._cookies[0]
self._CreateQueryAssets()
self._all_episodes = self._validator.QueryModelObjects(Episode, hash_key=None)
episode_count = len(self._all_episodes)
self._QueryEpisodes(cookie, self._CreateEpisodeSelection([]))
self._QueryEpisodes(cookie, self._CreateEpisodeSelection([0]))
... |
'Ensure that post labels are returned by query_episodes.'
| def testPostLabels(self):
| (ep_id, ph_ids) = self._UploadOneEpisode(self._cookie, 9)
self._tester.HidePhotos(self._cookie, [(ep_id, ph_ids[::2])])
self._tester.QueryEpisodes(self._cookie, [self._tester.CreateEpisodeSelection(ep_id)])
|
'Shares a subset of photos with another user and ensures that
only that subset can be retrieved. The service_tester is already
doing this, but correct access control is so important that it
justifies redundant testing.'
| def testPhotoAccess(self):
| (ep_id, ph_ids) = self._UploadOneEpisode(self._cookie, 12)
(vp_id, new_ep_ids) = self._tester.ShareNew(self._cookie, [(ep_id, ph_ids[::2])], [self._user2.user_id], **self._CreateViewpointDict(self._cookie))
response_dict = self._tester.QueryEpisodes(self._cookie2, [self._tester.CreateEpisodeSelection(ep_id)... |
'Query for photos that are missing the MD5 attributes.'
| def testMissingMD5Attributes(self):
| self._skip_validation_for.append('Accounting')
self._UpdateOrAllocateDBObject(Episode, episode_id='e1', user_id=self._user.user_id, timestamp=time.time(), parent_ep_id='e2', publish_timestamp=time.time(), viewpoint_id=self._user.private_vp_id)
self._UpdateOrAllocateDBObject(Photo, photo_id='p1', user_id=sel... |
'Tests that a prospective user only has access to episodes in the cookie viewpoint.'
| def testProspectiveUser(self):
| self._CreateSimpleTestAssets()
(prospective_user, vp_id, ep_id) = self._CreateProspectiveUser()
prospective_cookie = self._tester.GetSecureUserCookie(user_id=prospective_user.user_id, device_id=prospective_user.webapp_dev_id, user_name=None, viewpoint_id=vp_id)
(vp_id2, ep_ids2) = self._tester.ShareNew(... |
'Given a list of indexes into self._all_episodes, return a
selection of the indexed episodes that can be passed to
QueryEpisodes.'
| def _CreateEpisodeSelection(self, ep_index_list):
| return [self._tester.CreateEpisodeSelection(self._all_episodes[i].episode_id, get_attributes=True, get_photos=True) for i in ep_index_list]
|
'Repeatedly invokes the QueryEpisodes service tester.
Sends an episode query request using "request_dict". If "fetch_all"
is true, then queries are repeated in case of limits. Returns when
either there are no more episodes to query, or a single query was made
and "fetch_all" was specified as False.'
| def _QueryEpisodes(self, cookie, ep_select_list, photo_limit=None, fetch_all=False):
| while True:
response_dict = self._tester.QueryEpisodes(cookie, ep_select_list, photo_limit=photo_limit)
if fetch_all:
response_ep_dict = {ep_dict['episode_id']: ep_dict for ep_dict in response_dict['episodes']}
for ep_select in ep_select_list:
response_ep = re... |
'Test unsubscribing from email alerts.'
| def testUnsubscribeEmailAlerts(self):
| self._tester.UpdateUser(self._cookie2, settings_dict={'email_alerts': 'on_share_new'})
self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids)], [self._user2.user_id])
assert (len(self._emails[self._user2.email]) == 1), len(self._emails[self._user2.email])
self._TestUnsubscribe(self._co... |
'Test unsubscribing from marketing communication.'
| def testUnsubscribeMarketing(self):
| self._TestUnsubscribe(self._cookie2, AccountSettings.MARKETING)
self._UpdateOrAllocateDBObject(AccountSettings, settings_id=AccountSettings.ConstructSettingsId(self._user2.user_id), group_name=AccountSettings.GROUP_NAME, marketing='all')
self._TestUnsubscribe(self._cookie2, AccountSettings.MARKETING)
se... |
'Test share_new with prospective user, then unsubscribe with no cookie.'
| def testProspectiveUnsubscribe(self):
| email_address = 'andy@emailscrubbed.com'
identity_key = ('Email:%s' % email_address)
self._tester.ShareNew(self._cookie, [(self._episode_id, self._photo_ids)], [identity_key])
identity = self._RunAsync(Identity.Query, self._client, identity_key, None)
user = self._RunAsync(User.Query, self._client, ... |
'Test unsubscribing multiple times.'
| def testMultipleUnsubscribes(self):
| self._TestUnsubscribe(self._cookie, AccountSettings.EMAIL_ALERTS)
self._TestUnsubscribe(self._cookie, AccountSettings.EMAIL_ALERTS)
self._TestUnsubscribe(self._cookie, AccountSettings.MARKETING)
self._TestUnsubscribe(self._cookie, AccountSettings.MARKETING)
|
'Test unsubscribe with invalid cookie.'
| def testInvalidCookie(self):
| unsubscribe_url = self._tester.GetUrl('/unsubscribe?cookie=unknown')
response = self._RunAsync(self._tester.http_client.fetch, unsubscribe_url, method='GET', follow_redirects=False)
self.assertEqual(response.code, 400)
self.assertIn('The requested link has expired and can no long... |
'Invoke the /unsubscribe handler and validate that emails were turned off.'
| def _TestUnsubscribe(self, user_cookie, email_type):
| (user_id, device_id) = self._tester.GetIdsFromCookie(user_cookie)
unsubscribe_cookie = User.CreateUnsubscribeCookie(user_id, email_type)
unsubscribe_url = (self._tester.GetUrl('/unsubscribe?cookie=%s') % unsubscribe_cookie)
response = self._RunAsync(self._tester.http_client.fetch, unsubscribe_url, metho... |
'Test basic merge using source cookie.'
| def testMergeWithCookie(self):
| self._tester.MergeAccounts(self._cookie2, source_user_cookie=self._confirmed_cookie3)
self.assertEqual(len(self._tester.QueryFollowed(self._cookie2)['viewpoints']), 3)
self._cookies.remove(self._cookie3)
|
'Test basic merge using source identity.'
| def testMergeWithIdentity(self):
| source_identity_dict = self._TestGenerateMergeToken(('Email:%s' % self._user3.email), user_cookie=self._cookie2, error_if_linked=False)
self._tester.MergeAccounts(self._cookie2, source_identity_dict=source_identity_dict)
self.assertEqual(len(self._tester.QueryFollowed(self._cookie2)['viewpoints']), 3)
s... |
'Test merge with multiple source viewpoints.'
| @mock.patch.object(MergeAccountsOperation, '_FOLLOWER_LIMIT', 2)
def testMergeMultipleViewpoints(self):
| self._ShareSimpleTestAssets([self._user3.user_id])
self._ShareSimpleTestAssets([self._user3.user_id])
self._ShareSimpleTestAssets([self._user3.user_id])
self._tester.MergeAccounts(self._cookie2, source_user_cookie=self._confirmed_cookie3)
self.assertEqual(len(self._tester.QueryFollowed(self._cookie2... |
'Test merge where some source viewpoints are already followed by the target user.'
| def testMergeOverlappingViewpoints(self):
| self._ShareSimpleTestAssets([self._user2.user_id, self._user3.user_id])
self._ShareSimpleTestAssets([self._user2.user_id, self._user3.user_id])
self._tester.MergeAccounts(self._cookie3, source_user_cookie=self._confirmed_cookie2)
self.assertEqual(len(self._tester.QueryFollowed(self._cookie3)['viewpoints... |
'Test merge where a source viewpoint has been removed.'
| def testMergeRemovedSourceViewpoint(self):
| (vp_id, ep_id) = self._ShareSimpleTestAssets([self._user2.user_id])
self._tester.RemoveViewpoint(self._cookie2, vp_id)
self._tester.MergeAccounts(self._cookie3, source_user_cookie=self._confirmed_cookie2)
self.assertEqual(len(self._tester.QueryFollowed(self._cookie3)['viewpoints']), 3)
self._cookies... |
'Test merge where the target user has removed the target viewpoint.'
| def testMergeRemovedTargetViewpoint(self):
| (vp_id, _) = self._ShareSimpleTestAssets([self._user2.user_id, self._user3.user_id])
self._tester.RemoveViewpoint(self._cookie3, vp_id)
self._tester.MergeAccounts(self._cookie3, source_user_cookie=self._confirmed_cookie2)
response_dict = self._tester.QueryFollowed(self._cookie3)
vp_dict = util.GetSi... |
'Bug 468: Test merge with follower that never had adding_user_id set.'
| def testMergeOldFollower(self):
| self._UpdateOrAllocateDBObject(Follower, user_id=self._user3.user_id, viewpoint_id=self._vp_id2, adding_user_id=None)
self._tester.MergeAccounts(self._cookie2, source_user_cookie=self._confirmed_cookie3)
follower = self._RunAsync(Follower.Query, self._client, self._user2.user_id, self._vp_id2, None)
sel... |
'Test merge with follower whose adding_user_id has been removed.'
| def testRemovedAddingUser(self):
| (vp_id, _) = self._tester.ShareNew(self._cookie2, [(self._ep_id, self._photo_ids)], [self._user3.user_id])
self._tester.RemoveFollowers(self._cookie, self._vp_id, [self._user.user_id])
self._tester.MergeAccounts(self._cookie3, source_user_cookie=self._confirmed_cookie2)
response_dict = self._tester.Quer... |
'Link an identity that exists, but is not bound to any user.'
| def testLinkUnboundIdentity(self):
| identity_key = 'Email:new.user@emailscrubbed.com'
self._UpdateOrAllocateDBObject(Identity, key=identity_key)
source_identity_dict = self._TestGenerateMergeToken(identity_key, user_cookie=self._cookie3)
self._tester.MergeAccounts(self._cookie3, source_identity_dict=source_identity_dict)
|
'Test linking an identity after it was unlinked from another user.'
| def testLinkAfterUnlink(self):
| identity_key = 'Phone:+12345678901'
source_identity_dict = self._TestGenerateMergeToken(identity_key, user_cookie=self._cookie3)
self._tester.MergeAccounts(self._cookie3, source_identity_dict=source_identity_dict)
self._tester.UnlinkIdentity(self._cookie3, identity_key)
source_identity_dict = self._... |
'Test link of an identity which another user has as a contact.'
| def testLinkWithContacts(self):
| identity_key = 'Email:foo@emailscrubbed.com'
contact_dict = Contact.CreateContactDict(self._user.user_id, [(identity_key, None)], util._TEST_TIME, Contact.GMAIL)
self._UpdateOrAllocateDBObject(Contact, **contact_dict)
source_identity_dict = self._TestGenerateMergeToken(identity_key, user_cookie=self._co... |
'Test the /merge_token auth API.'
| def testMergeToken(self):
| source_identity_dict = self._TestGenerateMergeToken('Email:mobile-user@bar.com', user_cookie=self._cookie2)
email = TestEmailManager.Instance().emails['mobile-user@bar.com'][0]
self.assertEqual(email['toname'], self._user2.name)
self.assertIn(('Hello %s' % self._user2.name), email['html'])
self.a... |
'Use valid and invalid access tokens with merge_accounts.'
| def testAccessToken(self):
| source_identity_dict = self._TestGenerateMergeToken('Email:foo@bar.com', user_cookie=self._cookie3)
bad_source_identity_dict = deepcopy(source_identity_dict)
bad_source_identity_dict['access_token'] = 'unknown'
self.assertRaisesHttpError(403, self._tester.MergeAccounts, self._cookie3, source_identity_di... |
'Test that merge will skip system viewpoints.'
| def testMergeSkipSystem(self):
| self._MakeSystemViewpoint(self._vp_id2)
self._tester.MergeAccounts(self._cookie2, source_user_cookie=self._confirmed_cookie3)
follower = self._RunAsync(Follower.Query, self._client, self._user2.user_id, self._vp_id2, None, must_exist=False)
self.assertIsNone(follower)
self._cookies.remove(self._cook... |
'Force op failure in order to test idempotency.'
| @mock.patch.object(Operation, 'FAILPOINTS_ENABLED', True)
def testMergeIdempotency(self):
| self._validate = False
request_dict = {'activity': self._tester.CreateActivityDict(self._cookie2), 'source_user_cookie': self._confirmed_cookie3}
self._tester.SendRequest('merge_accounts', self._cookie2, request_dict)
actual_dict = self._tester.SendRequest('query_followed', self._cookie2, {})
self.a... |
'Force op failure in order to test idempotency.'
| @mock.patch.object(Operation, 'FAILPOINTS_ENABLED', True)
def testLinkIdempotency(self):
| source_identity_dict = self._TestGenerateMergeToken('Email:test@test.com', user_cookie=self._cookie2)
self._tester.MergeAccounts(self._cookie2, source_identity_dict=source_identity_dict)
|
'ERROR: Try to merge without a user cookie or identity source.'
| def testNoMergeSource(self):
| self.assertRaisesHttpError(400, self._tester.MergeAccounts, self._confirmed_cookie2)
|
'ERROR: Try to merge account into itself.'
| def testMergeIntoSelf(self):
| self.assertRaisesHttpError(400, self._tester.MergeAccounts, self._confirmed_cookie2, source_user_cookie=self._confirmed_cookie2)
|
'ERROR: Pass bad source user cookie.'
| def testBadCookie(self):
| self.assertRaisesHttpError(403, self._tester.MergeAccounts, self._cookie, source_user_cookie='BADF00D')
|
'ERROR: Try to merge a terminated user account.'
| def testMergeTerminatedAccount(self):
| self._tester.TerminateAccount(self._confirmed_cookie3)
self.assertRaisesHttpError(400, self._tester.MergeAccounts, self._cookie, source_user_cookie=self._confirmed_cookie3)
self._cookies.remove(self._cookie3)
|
'Merge from a prospective user account.'
| def testMergeProspectiveUser(self):
| (prospective_user, vp_id, ep_id) = self._CreateProspectiveUser()
prospective_cookie = self._tester.GetSecureUserCookie(user_id=prospective_user.user_id, device_id=prospective_user.webapp_dev_id, user_name=None, viewpoint_id=vp_id, confirm_time=util._TEST_TIME)
self._tester.MergeAccounts(self._cookie, source... |
'Test merge in which another user has the source user as a contact.'
| def testMergeWithContacts(self):
| exp_contacts = []
for (user, identity) in zip(self._users[1:], self._identities[1:]):
contact_dict = Contact.CreateContactDict(self._user.user_id, [(identity.key, None)], util._TEST_TIME, Contact.GMAIL)
exp_contacts.append({'contact_id': contact_dict['contact_id'], 'contact_source': contact_dict... |
'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.'
| def _TestGenerateMergeToken(self, identity_key, user_cookie, error_if_linked=None):
| 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', use... |
'Test successful register of web user.'
| def testRegisterWebUser(self):
| self._tester.RegisterViewfinderUser(self._viewfinder_user_dict)
self.assertRaisesHttpError(403, self._tester.RegisterViewfinderUser, self._viewfinder_user_dict, self._mobile_device_dict)
|
'Test successful register of mobile user.'
| def testRegisterMobileUser(self):
| self._tester.RegisterViewfinderUser(self._viewfinder_user_dict, self._mobile_device_dict)
self.assertRaisesHttpError(403, self._tester.RegisterViewfinderUser, self._viewfinder_user_dict)
|
'Test successful login of web user.'
| def testLoginWebUser(self):
| (user, device_id) = self._tester.RegisterViewfinderUser(self._viewfinder_user2_dict)
(user2, device_id2) = self._tester.LoginViewfinderUser(self._viewfinder_user2_dict)
self.assertEqual(user.user_id, user2.user_id)
self.assertEqual(device_id, device_id2)
self._tester.LoginViewfinderUser(self._viewfi... |
'Test successful login of mobile user.'
| def testLoginMobileUser(self):
| (user, device_id) = self._tester.RegisterViewfinderUser(self._viewfinder_user2_dict, self._mobile_device_dict)
(user2, device_id2) = self._tester.LoginViewfinderUser(self._viewfinder_user2_dict, self._mobile_device_dict)
self.assertEqual(user.user_id, user2.user_id)
self.assertNotEqual(device_id, device... |
'Test /login_reset/viewfinder with web user.'
| def testLoginResetWebUser(self):
| emails = TestEmailManager.Instance().emails
self._tester.RegisterViewfinderUser(self._viewfinder_user_dict)
emails.clear()
self._tester.LoginResetViewfinderUser(self._viewfinder_user_dict)
self.assertIn('did not submit a password reset', emails[self._viewfinder_user_dict['email']][0][... |
'Test /login_reset/viewfinder with mobile user.'
| def testLoginResetMobileUser(self):
| emails = TestEmailManager.Instance().emails
self._tester.RegisterViewfinderUser(self._viewfinder_user_dict, self._mobile_device_dict)
emails.clear()
self._tester.LoginResetViewfinderUser(self._viewfinder_user_dict, self._mobile_device_dict)
self.assertIn('did not submit a password res... |
'Test successful link of mobile user.'
| def testLinkMobileUser(self):
| (user, device_id) = self._tester.RegisterViewfinderUser(self._viewfinder_user_dict)
cookie = self._GetSecureUserCookie(user, device_id)
self._tester.LinkViewfinderUser(self._viewfinder_user2_dict, self._mobile_device_dict, user_cookie=cookie)
self._tester.LinkViewfinderUser(self._viewfinder_user2_dict, ... |
'Test successful link of web user.'
| def testLinkWebUser(self):
| (user, device_id) = self._tester.RegisterViewfinderUser(self._viewfinder_user_dict, self._mobile_device_dict)
cookie = self._GetSecureUserCookie(user, device_id)
self._tester.LinkViewfinderUser(self._viewfinder_user2_dict, user_cookie=cookie)
self._tester.LinkViewfinderUser(self._viewfinder_user2_dict, ... |
'Register a user with a password, then login with the password.'
| def testAuthPassword(self):
| TestEmailManager.Instance().emails.clear()
(user, _) = self._tester.RegisterViewfinderUser(self._viewfinder_user3_dict, self._mobile_device_dict)
self.assertEqual(len(TestEmailManager.Instance().emails), 1)
expected_pwd_hash = base64.b64encode(PBKDF2(self._viewfinder_user3_dict['password'].encode('utf8'... |
'Test shortcut registration with a confirmed prospective user cookie.'
| def testConfirmedRegister(self):
| self._validate = False
self._CreateSimpleTestAssets()
(prospective_user, _, _) = self._CreateProspectiveUser()
auth_info_dict = {'identity': ('Email:%s' % prospective_user.email), 'name': 'Jimmy John', 'given_name': 'Jimmy', 'family_name': 'John'}
url = self._tester.GetUrl('/register/viewfinder')... |
'Register a prospective user, which is the target of a contact.'
| def testRegisterProspectiveContact(self):
| user_dict = {'email': 'prospective@emailscrubbed.com', 'name': 'Andy Kimball', 'given_name': 'Andy'}
identity_key = 'Email:prospective@emailscrubbed.com'
contact_dict = Contact.CreateContactDict(self._user2.user_id, [(identity_key, None)], util._TEST_TIME, Contact.GMAIL)
self._UpdateOrAllocateDBObjec... |
'ERROR: Try to register a password that does not meet min requirements.'
| def testInvalidPassword(self):
| self.assertRaisesHttpError(400, self._tester.RegisterViewfinderUser, {'name': 'Pete Mattis', 'given_name': 'Pete', 'email': 'pete@emailscrubbed.com', 'password': 'tiny'}, self._mobile_device_dict)
|
'ERROR: Try to use password to log into account with no password.'
| def testMissingPassword(self):
| self._tester.RegisterViewfinderUser(self._viewfinder_user_dict, self._mobile_device_dict)
self.assertRaisesHttpError(403, self._tester.LoginViewfinderUser, {'email': self._viewfinder_user_dict['email'], 'password': 'missing password'}, self._mobile_device_dict)
|
'ERROR: Test auth with incorrect password.'
| def testIncorrectPassword(self):
| self._tester.RegisterViewfinderUser(self._viewfinder_user3_dict, self._mobile_device_dict)
self.assertRaisesHttpError(403, self._tester.LoginViewfinderUser, {'email': self._viewfinder_user3_dict['email'], 'password': 'wrong password'}, self._mobile_device_dict)
|
'ERROR: Try to guess password too many times.'
| @mock.patch.object(password_util, '_MAX_PASSWORD_GUESSES', 1)
def testTooManyPasswordGuesses(self):
| self._tester.RegisterViewfinderUser(self._viewfinder_user3_dict, self._mobile_device_dict)
self.assertRaisesHttpError(403, self._tester.LoginViewfinderUser, {'email': self._viewfinder_user3_dict['email'], 'password': 'wrong password'}, self._mobile_device_dict)
self.assertRaisesHttpError(403, self._teste... |
'ERROR: Try to create users with missing name parts.'
| def testMissingNameParts(self):
| user_dict = {'email': 'no-one@island-of-cyclopes.com'}
self.assertRaisesHttpError(400, self._tester.RegisterViewfinderUser, user_dict, self._mobile_device_dict)
user_dict = {'name': 'Andy Kimball', 'phone': '13844759384'}
self.assertRaisesHttpError(400, self._tester.RegisterViewfinderUser, user_dict,... |
'ERROR: Test that non canonical identity keys are rejected.'
| def testNonCanonicalId(self):
| self._viewfinder_user_dict['email'] = self._viewfinder_user_dict['email'].upper()
self.assertRaisesHttpError(400, self._tester.RegisterViewfinderUser, self._viewfinder_user_dict, self._mobile_device_dict)
self._viewfinder_user2_dict['phone'] = '3854759'
self.assertRaisesHttpError(400, self._tester.Regis... |
'ERROR: Try to login with identity that is not linked to a Viewfinder account.'
| def testLoginNoExist(self):
| self.assertRaisesHttpError(403, self._tester.LoginViewfinderUser, self._viewfinder_user_dict, self._mobile_device_dict)
self.assertRaisesHttpError(403, self._tester.LoginViewfinderUser, self._viewfinder_user2_dict, None)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.