def check_code(self, user): tm = int(time.time() / 30) code_attempt = self.cform.data['code'] # try 30 seconds behind and ahead as well for ix in [-1, 0, 1]: code = get_google_auth_code(user.secret, tm + ix) if not strings_differ(code, str(code_attempt)): return True return False
def test_submit_success_with_code_check_headers(self): from factored.utils import get_google_auth_code from factored.models import User user = self.session.query(User).filter_by(username='******').first() resp = self.testapp.post('/auth/ga', status=302, params={ 'submit': 'Authenticate', 'username': '******', 'code': get_google_auth_code(user.secret) }) assert 'pnutbtr=' in resp.headers['Set-Cookie']
def test_submit_success_with_code(self): from factored.utils import get_google_auth_code from factored.models import User user = self.session.query(User).filter_by(username='******').first() self.testapp.post('/auth/ga', status=302, params={ 'submit': 'Authenticate', 'username': '******', 'code': get_google_auth_code(user.secret) }) self.testapp.get('/')