Exemplo n.º 1
0
    def _get_account_by_email(self):
        """Use email returned by the authentication platform for validation"""
        if self.email_address is None:
            raise AuthenticationError('could not retrieve email from provider')

        acct_repository = AccountRepository(self.db)
        self.account = acct_repository.get_account_by_email(self.email_address)

        if self.account is None:
            raise AuthenticationError('no account found for provided email')
Exemplo n.º 2
0
def check_db_for_account(context):
    acct_repository = AccountRepository(context.db)
    account = acct_repository.get_account_by_email('*****@*****.**')
    # add account to context so it will deleted by cleanup step
    context.accounts['bar'] = account
    assert_that(account, not_none())
    assert_that(account.email_address, equal_to('*****@*****.**'))

    assert_that(len(account.agreements), equal_to(2))
    for agreement in account.agreements:
        assert_that(agreement.type, is_in((PRIVACY_POLICY, TERMS_OF_USE)))
        assert_that(agreement.accept_date, equal_to(str(date.today())))
Exemplo n.º 3
0
    def get(self):
        return_data = dict(accountExists=False, noFederatedEmail=False)
        if self.request.args['token']:
            email_address = self._get_email_address()
            if self.request.args[
                    'platform'] != 'Internal' and not email_address:
                return_data.update(noFederatedEmail=True)
            account_repository = AccountRepository(self.db)
            account = account_repository.get_account_by_email(email_address)
            if account is None:
                return_data.update(accountExists=False)

        return return_data, HTTPStatus.OK
Exemplo n.º 4
0
def check_db_for_account(context):
    """Check that the account was created as expected."""
    acct_repository = AccountRepository(context.db)
    account = acct_repository.get_account_by_email("*****@*****.**")
    # add account to context so it will deleted by cleanup step
    context.accounts["bar"] = account
    assert_that(account, not_none())
    assert_that(account.email_address, equal_to("*****@*****.**"))

    assert_that(len(account.agreements), equal_to(2))
    utc_date = datetime.utcnow().date()
    for agreement in account.agreements:
        assert_that(agreement.type, is_in((PRIVACY_POLICY, TERMS_OF_USE)))
        assert_that(agreement.accept_date, equal_to(str(utc_date)))
Exemplo n.º 5
0
def _add_account(context, db):
    test_account = Account(email_address='*****@*****.**',
                           username='******',
                           membership=AccountMembership(
                               type='Monthly Membership',
                               start_date=date.today(),
                               payment_method='Stripe',
                               payment_account_id='foo',
                               payment_id='bar'),
                           agreements=[
                               AccountAgreement(type=PRIVACY_POLICY,
                                                accept_date=date.today())
                           ])
    acct_repository = AccountRepository(db)
    acct_repository.add(test_account, 'foo')
    context.account = acct_repository.get_account_by_email(
        test_account.email_address)
Exemplo n.º 6
0
 def _get_account_from_email(self):
     acct_repository = AccountRepository(self.db)
     self.account = acct_repository.get_account_by_email(
         self.request.json['emailAddress'])