def test_changeName_notin_channel(): token = A['token'] channelID = Pub_channel['channel_id'] auth_login("*****@*****.**", 'HoyaLee2019') with pytest.raises(CF.AccessError): CF.channel_name_change(token, channelID, 'name')
def test_user_NULL(): auth_login("*****@*****.**", 'HoyaLee2019') token = None channelID = Pub_channel['channel_id'] length = '15' with pytest.raises(TypeError): OF.standup_start(token, channelID, length)
def test_canNot_addOwner(): auth_login("*****@*****.**", 'HoyaLee2019') token = A['token'] u_id = A['u_id'] Pub_channel = CF.channels_create(A['token'], 'Test1', 'True') channelID = Pub_channel['channel_id'] with pytest.raises(CHF.ValueError): CF.channel_addowner(token, channelID, u_id)
def test_channel_ID(): #get stoken token = A['token'] auth_login("*****@*****.**", 'HoyaLee2019') #get channelID channelID = '6509779080987' #start start = '0' with pytest.raises(CHF.ValueError): CF.channel_messages(token, channelID, start)
def test_auth_login(): ''' Test functions for auth_login ''' data.initialise_all() # Register a user and then log in auth.auth_register("*****@*****.**", "registered_password", "a", "b") # A registered user is logged in login = auth.auth_login("*****@*****.**", "registered_password") \ # Check database for id and token user_id = get_user_by_email("*****@*****.**").u_id user_token = get_user_token_by_u_id(user_id) assert login == {"u_id": user_id, "token": user_token} # An invalid email is given with pytest.raises(ValueError, match="Invalid Email"): auth.auth_login("invalid_email", "valid_password") # Email is not a registered email with pytest.raises(ValueError, match="Email not registered"): auth.auth_login("*****@*****.**", "valid_password") # Password is incorrect with pytest.raises(ValueError, match="Password Incorrect"): auth.auth_login("*****@*****.**", "bpas")
def auth_login(): """ Given a registered user' email and password, generates a valid token for the user to remain authenticated """ #Gets username and password email = request.form.get("email") password = request.form.get("password") #Calls function from auth_functions.py return dumps(auth.auth_login(email, password))
import pytest import server.other_functions as OF import server.channel_helper_functions as CHF from server.auth_functions import auth_login, auth_logout, auth_register from server.channel_functions import channels_create from server.global_variables import reset_data import server.Errors as Errors A = auth_login("*****@*****.**", 'HoyaLee2019') B = auth_login("*****@*****.**", "wsad1990") Pub_channel = channels_create(A['token'], 'StdChannel', 'True') '''If user not login''' def test_standUp_logout(): token = A['token'] auth_logout(A['token']) channelID = Pub_channel['channel_id'] length = '15' with pytest.raises(OF.AccessError): OF.standup_start(token, channelID, length) '''User is not the ownre''' def test_user_notTheOwner():
def test_invalid_AD_token(): token = A['token'] + '10010' auth_login("*****@*****.**", 'HoyaLee2019') with pytest.raises(TF.AccessError): CF.channels_list(token)