Profile insertion check (#484)

* Test setting profile
* Fix issue with app_context altering database connections/state
This commit is contained in:
Kevin Chung
2017-11-26 04:22:15 -05:00
committed by GitHub
parent 46544e5729
commit db2e3b5684
3 changed files with 50 additions and 22 deletions

View File

@@ -219,6 +219,35 @@ def test_user_get_profile():
destroy_ctfd(app)
def test_user_set_profile():
"""Can a registered user set their private profile (/profile)"""
app = create_ctfd()
with app.app_context():
register_user(app)
client = login_as_user(app)
r = client.get('/profile')
with client.session_transaction() as sess:
data = {
'name': 'user',
'email': 'user@ctfd.io',
'confirm': '',
'password': '',
'affiliation': 'affiliation_test',
'website': 'https://ctfd.io',
'country': 'United States of America',
'nonce': sess.get('nonce')
}
r = client.post('/profile', data=data)
assert r.status_code == 302
user = Teams.query.filter_by(id=2).first()
assert user.affiliation == 'affiliation_test'
assert user.website == 'https://ctfd.io'
assert user.country == 'United States of America'
destroy_ctfd(app)
def test_user_get_logout():
"""Can a registered user load /logout"""
app = create_ctfd()