def test_user_settings_password(): test_client = webapp.app.test_client() user = User() username = '******' password = '******' user.login(username,password) result = test_client.post('/login/',data={ 'username':username, 'password':password },follow_redirects=True) result = test_client.get('/settings/',follow_redirects=True) assert user.user.auth_token in result.data # create an update call, then check data # remember to reauthenticate password = '******' result = test_client.post('/settings/',data={ 'password':password, 'confirm':password },follow_redirects=True) user = User() user.login(username,password) assert user.is_authenticated() assert user.user.auth_token in result.data
def post(self): api_key = request.args.get('api_key') user = User() user.api_login(api_key) if not user.is_authenticated(): return jsonify({'status':False}) data = request.json project = Project() project.create(data['name'],data['description']) user.add_project(str(project.get_id())) return jsonify({'status':True})
def authorized(api_key,project_id): user = User() print "api key is %s" % api_key user.api_login(api_key) if not user.is_authenticated(): print "wrong password" return False login_user(user) identity_changed.send(current_app._get_current_object(),identity=Identity(user.user.id)) permission = EditProjectPermission(project_id) if not permission.can(): print "bad permission" return False return True
def test_user_registration(): username = '******' password = '******' email = '*****@*****.**' test_client = webapp.app.test_client() create = test_client.post('/register/',data={ 'username':username, 'password':password, 'confirm':password, 'email':email },follow_redirects=True) user = User() user.login(username,password) assert user.is_authenticated()