示例#1
0
 def test_too_many_tries(self, filter):
     filter = (
         filter.is_callable().returns_fake().provides('count').returns(1))
     for i in range(3):
         # Simulate existing username.
         filter = filter.next_call().returns(1)
     # Simulate available username.
     filter = filter.next_call().returns(0)
     # After the third try, give up, and generate a random string username.
     un = autocreate_username('base')
     assert not un.startswith('base'), 'Unexpected: %s' % un
 def test_too_many_tries(self, filter):
     filter = (filter.is_callable().returns_fake().provides('count')
               .returns(1))
     for i in range(3):
         # Simulate existing username.
         filter = filter.next_call().returns(1)
     # Simulate available username.
     filter = filter.next_call().returns(0)
     # After the third try, give up, and generate a random string username.
     un = autocreate_username('base')
     assert not un.startswith('base'), 'Unexpected: %s' % un
示例#3
0
    try:
        buyer_data = solitude.api.by_url(buyer_uri).get_object_or_404()
    except ObjectDoesNotExist:
        raise LookupError('Unable to look up buyer: '
                          '{buyer_uri} in Solitude'.format(
                              buyer_uri=buyer_uri))

    buyer_email = buyer_data['email']

    user_profile = UserProfile.objects.filter(email=buyer_email)

    if user_profile.exists():
        user_profile = user_profile.get()
    else:
        buyer_username = autocreate_username(buyer_email.partition('@')[0])
        source = amo.LOGIN_SOURCE_WEBPAY
        user_profile = UserProfile.objects.create(
            display_name=buyer_username,
            email=buyer_email,
            is_verified=True,
            source=source,
            username=buyer_username)

        log_cef('New Account', 5, request, username=buyer_username,
                signature='AUTHNOTICE',
                msg='A new account was created from Webpay (using FxA)')
        record_action('new-user', request)

    log.info('webpay postback: fulfilling purchase for contrib %s with '
             'transaction %s' % (contrib, trans_id))
示例#4
0
    try:
        buyer_data = solitude.api.by_url(buyer_uri).get_object_or_404()
    except ObjectDoesNotExist:
        raise LookupError(
            'Unable to look up buyer: '
            '{buyer_uri} in Solitude'.format(buyer_uri=buyer_uri))

    buyer_email = buyer_data['email']

    user_profile = UserProfile.objects.filter(email=buyer_email)

    if user_profile.exists():
        user_profile = user_profile.get()
    else:
        buyer_username = autocreate_username(buyer_email.partition('@')[0])
        source = amo.LOGIN_SOURCE_WEBPAY
        user_profile = UserProfile.objects.create(display_name=buyer_username,
                                                  email=buyer_email,
                                                  is_verified=True,
                                                  source=source,
                                                  username=buyer_username)

        log_cef('New Account',
                5,
                request,
                username=buyer_username,
                signature='AUTHNOTICE',
                msg='A new account was created from Webpay (using FxA)')
        record_action('new-user', request)
 def test_duplicate_username_counter(self, filter):
     filter = (filter.expects_call().returns_fake().expects('count')
               .returns(1).next_call().returns(1).next_call().returns(0))
     eq_(autocreate_username('existingname'), 'existingname3')
 def test_empty_username_is_a_random_hash(self):
     un = autocreate_username('.+')  # this shouldn't happen but it could!
     assert len(un) and not un.startswith('.+'), 'Unexpected: %s' % un
 def test_invalid_characters(self):
     eq_(autocreate_username('testaccount+slug'), 'testaccountslug')
示例#8
0
 def test_duplicate_username_counter(self, filter):
     filter = (filter.expects_call().returns_fake().expects(
         'count').returns(1).next_call().returns(1).next_call().returns(0))
     eq_(autocreate_username('existingname'), 'existingname3')
示例#9
0
 def test_empty_username_is_a_random_hash(self):
     un = autocreate_username('.+')  # this shouldn't happen but it could!
     assert len(un) and not un.startswith('.+'), 'Unexpected: %s' % un
示例#10
0
 def test_invalid_characters(self):
     eq_(autocreate_username('testaccount+slug'), 'testaccountslug')