示例#1
0
def test_expire_stale_requests(reahl_system_fixture, party_account_fixture):
    fixture = party_account_fixture

    old_email = '*****@*****.**'
    recent_email = '*****@*****.**'
    password = '******'
    mailer_stub = fixture.mailer
    EmailAndPasswordSystemAccount.mailer = mailer_stub
    longago = datetime.now() - timedelta(
        reahl_system_fixture.config.accounts.request_verification_timeout)

    old_account_management_interface = AccountManagementInterface()
    old_account_management_interface.email = old_email
    old_account_management_interface.password = password
    old_account_management_interface.register()
    old_system_account = EmailAndPasswordSystemAccount.by_email(old_email)
    old_activation_request = Session.query(VerifyEmailRequest).one()
    old_activation_request.deferred_actions[0].deadline = longago

    new_account_management_interface = AccountManagementInterface()
    new_account_management_interface.email = recent_email
    new_account_management_interface.password = password
    new_account_management_interface.register()
    recent_system_account = EmailAndPasswordSystemAccount.by_email(
        recent_email)

    ReahlEgg.do_daily_maintenance_for_egg('reahl-domain')
    assert Session.query(EmailAndPasswordSystemAccount).filter_by(
        id=old_system_account.id).count() == 0
    assert Session.query(EmailAndPasswordSystemAccount).filter_by(
        id=recent_system_account.id).count() == 1
示例#2
0
 def setup_super_and_example_account(self):
     example_accounts = ['*****@*****.**' % i for i in range(100)]
     for email in [self.super_user_email_address] + example_accounts:
         try:
             EmailAndPasswordSystemAccount.by_email(email)
         except NoSuchAccountException:
             system_account = EmailAndPasswordSystemAccount(email=email)
             system_account.set_new_password(email, 'snakesnake')
             system_account.activate()
             Session.add(system_account)
示例#3
0
 def new_system_account(self,
                        party=None,
                        email='*****@*****.**',
                        activated=True):
     password = '******'
     system_account = EmailAndPasswordSystemAccount(owner=party
                                                    or self.party,
                                                    email=email)
     system_account.set_new_password(email, password)
     system_account.password = password  # The unencrypted version for use in tests
     if activated:
         system_account.activate()
     Session.add(system_account)
     Session.flush()
     return system_account
示例#4
0
 def new_account(self):
     account = EmailAndPasswordSystemAccount(email='*****@*****.**')
     Session.add(account)
     account.set_new_password(account.email, self.password)
     account.activate()
     return account
示例#5
0
文件: accounts.py 项目: dli7428/reahl
 def validate_parsed_value(self, email):
     try:
         EmailAndPasswordSystemAccount.assert_email_unique(email)
     except NotUniqueException:
         raise self