def test_change_password_account_does_not_exist(): server = Camelot_Server() mydb = Camelot_Database() client_request = json.loads( json.dumps( { "change_password": { "username": "******", "current_password": "******", "new_password": "******" } }, indent=4)) expected_response = json.dumps( { "error": "The username/password combination do not exist in the database." }, indent=4) result = server.change_password(mydb, client_request) assert expected_response == result mydb.empty_tables()
def test_change_password_invalid_new_password(): server = Camelot_Server() mydb = Camelot_Database() client_request = json.loads( json.dumps( { "change_password": { "username": "******", "current_password": "******", "new_password": "******" } }, indent=4)) expected_response = json.dumps( { "error": "The password isn't of the correct length (0 < len(password) <= 20)." }, indent=4) mydb.create_account("username", "password") result = server.change_password(mydb, client_request) assert expected_response == result mydb.empty_tables()
def test_change_password_invalid_json(): server = Camelot_Server() mydb = Camelot_Database() client_request = json.loads( json.dumps( { "change_password": { "username_invalid": "username", "current_password": "******", "new_password": "******" } }, indent=4)) expected_response = json.dumps( {"error": "The JSON file sent didn't contain valid information."}, indent=4) result = server.change_password(mydb, client_request) assert expected_response == result mydb.empty_tables()
def test_change_password_success(): server = Camelot_Server() mydb = Camelot_Database() client_request = json.loads( json.dumps( { "change_password": { "username": "******", "current_password": "******", "new_password": "******" } }, indent=4)) expected_response = json.dumps( {"success": "Successfully changed username's password."}, indent=4) mydb.create_account("username", "password") result = server.change_password(mydb, client_request) assert expected_response == result mydb.empty_tables()