def oauthroute(): token = oauth.fetch_token('https://accounts.google.com/o/oauth2/token', authorization_response=request.url, client_secret=client_secret) req = requests.Request() id_info = id_token.verify_oauth2_token(token['id_token'], req, client_id) add_user(id_info["sub"]) return "<p>Your user_id is: %s</p><p>Your JWT is: %s</p>" % ( id_info["sub"], token['id_token'])
def test_add_user(session): user = add_user('testuser1', DEFAULT_PASSWORD) user2 = User.get_by_email('*****@*****.**') assert user2.id == user.id assert user2.email == user.email assert user2.check_password(DEFAULT_PASSWORD)
def test_update_user(session): user = add_user('testuser1', DEFAULT_PASSWORD) assert user.name == 'testuser1' assert user.check_password(DEFAULT_PASSWORD) user.name = 'testuser2' user.set_password('test') assert user.name == 'testuser2' assert user.check_password('test')
def test_order(session): order = add_order() order2 = Order.get(order.id) assert order2 is not None user2 = add_user('testuser2', 'pwd') order.designers = [user2] order3 = Order.get(order.id) assert user2 in order3.designers
def test_add_user(self): with self.client as c: with c.session_transaction() as session: payload_1 = {'email': '*****@*****.**', 'password': '******', 'name': 'Tim'} helper.add_user(payload_1, session=session) user = User.query.filter_by(email='*****@*****.**').first() self.assertEqual(user.name, 'Tim') self.assertEqual(user.password, 'testpass') self.assertEqual(user.email, '*****@*****.**') self.assertEqual(session['user_name'], 'Tim') self.assertEqual(session['user_id'], user.user_id) payload_2 = {'email': '*****@*****.**', 'password': '******', 'name': 'Liz'} status = helper.add_user(payload_2, session=session) self.assertEqual(status, "That user already exists")
def test_order(session): order = add_order() user2 = add_user('testuser2', '2') msg = "test comment \n text \n" order.add_comment(user2, msg) comments = order.get_comments() assert len(comments) > 0 assert comments[0].msg == msg comments[0].delete() assert len(order.get_comments()) == 0
def test_add_user(self): with self.client as c: with c.session_transaction() as session: payload_1 = { 'email': '*****@*****.**', 'password': '******', 'name': 'Tim' } helper.add_user(payload_1, session=session) user = User.query.filter_by(email='*****@*****.**').first() self.assertEqual(user.name, 'Tim') self.assertEqual(user.password, 'testpass') self.assertEqual(user.email, '*****@*****.**') self.assertEqual(session['user_name'], 'Tim') self.assertEqual(session['user_id'], user.user_id) payload_2 = { 'email': '*****@*****.**', 'password': '******', 'name': 'Liz' } status = helper.add_user(payload_2, session=session) self.assertEqual(status, "That user already exists")
def post_account(): """creates user account""" form_data = request.form status = helper.add_user(form_data) # flash(status) if status == "That username already exists": return redirect('login') else: # todo add flash "your account has been created" & "you have been logged in" session['user_name'] = status[1] session['user_id'] = status[0] return redirect('/')
def post_account(): """creates user account""" form_data = request.form status = helper.add_user(form_data) # flash(status) if status == "That username already exists": return redirect('login') else: # todo add flash "your account has been created" & "you have been logged in" session['user_name'] = status[1] session['user_id'] = status[0] return redirect('/')
def test_delete_user(session): user = add_user('testuser1', DEFAULT_PASSWORD) user_id = user.id user.delete() assert User.get(user_id) is None