Esempio n. 1
0
def test_channel_join():
    # Begin setup
    auth_user1_dict = auth_register("*****@*****.**", "user1", "random", "rand")
    user1_token = auth_user1['token']

    auth_user2_dict = auth_register ("*****@*****.**", "user2", "random2", "rand2")
    user2_token = auth_user2['token']

    channel_id = channels_create (user2_token, 'test', True)
    # End setup

    #standard join procedure
    channel_join (user1_token, channel_id)
    assert channel_id in channels_list (user1_token)

    #user is already in channel
    with pytest.raises(ValueError, match=r"*"):
        channel_join (user1_token, channel_id)

    #invalid channel id
    user3_token = 'invalid token'
    with pytest.raises(ValueError, match = r"*"):
        channel_join (user2_token, 'invalid channel id')    

    #attempting to join private channel
    channel_id2 = channels_create (user2_token, 'test2', False)
    with pytest.raises(ValueError, match = r"*"):
        channel_join (user1_token, channel_id2) 

    #invalid token
    with pytest.raises(ValueError, match = r"*"):
        channel_join ('invalid token', channel_id)   
    pass
Esempio n. 2
0
def test_message_editFAILeditOthers():
    ## set up
    AuthRegDict = auth_register("*****@*****.**", "123456", "Hayden", "Smith")
    token = AuthRegDict['token']
    AuthRegDict2 = auth_register("*****@*****.**", "1123456", "Hayen", "Sith")
    token2 = AuthRegDict['token']
    publicChan = channels_create(token, "public", True)
    publicId = publicChan['channel_id']
    ## end setup
    
    
    message_send(token, publicId, "message one")
    messageDic = channel_messages(token, publicChan, 0)
    ###messageDic{ message_id, u_id, message, time_created, is_unread }
    firstId = messageDic[message_id][0]
    firstMessage = messageDic[message][0]
    ## end setup
    with pytest.raises(AccessError, match=r"*"):
        message_edit(token2, firstId, "edited message one")
    
    messageDic1 = channel_messages(token, publicChan, 0)
    ###messageDic{ message_id, u_id, message, time_created, is_unread }
    editFirstId = messageDic[message_id][0]
    editFirstMessage = messageDic[message][0]
    assert editFirstMessage == "message one"
    assert editFirstId == firstId
Esempio n. 3
0
def test_userall_multiple():
    user_2 = auth_register('*****@*****.**', 'valid_password2', 'valid_first1', 'valid_last1')
    res2_2 = auth_login('*****@*****.**', 'valid_password2')
    
    user_3 = auth_register('*****@*****.**', 'valid_password3', 'valid_first2', 'valid_last2')
    res2_3 = auth_login('*****@*****.**', 'valid_password3')

    assert user_all() == {"users" : ["valid_first", "valid_first1", "valid_first2"]}
def test_auth_register_valid():
    # Test valid email, password, name_first and name_last at boundaries
    assert auth_register('*****@*****.**', 'abcdefr', '49_character_firstname',
                         '49_character_lastname') == {
                             'u_id': 0,
                             'token': GLOBAL_DATA["active_tokens"][0]
                         }
Esempio n. 5
0
def test_userall_0():
    user = auth_register('*****@*****.**', 'valid_password', 'valid_first', 'valid_last')
    res2 = auth_login('*****@*****.**', 'valid_password')
    token = res2['token']
    u_id = res2['u_id']

    assert user_all() == {"users" : ["valid_first"]}
Esempio n. 6
0
def test_standup_send_not_member():
    # SETUP BEGIN
    authRegDict = auth_register("*****@*****.**", "Abcd1234", "Sherry",
                                "Birkin")
    token = authRegDict['token']
    channel = channels_create(token, "Private_Channel", True)
    channel_id = channel['channel_id']

    authRegDict2 = auth_register("*****@*****.**", "Abcd1234", "Chris",
                                 "Smith")
    token2 = authRegDict2['token']
    # SETUP END

    with pytest.raises(AccessError, match=r"*"):
        standup_send(token2, channel_id, "Hello")
    with pytest.raises(AccessError, match=r"*"):
        standup_send(token2, channel_id, "I'm Chris")
Esempio n. 7
0
def test_message_pinFAILadminNotInChan():
    ## set up
    AuthRegDict = auth_register("*****@*****.**", "123456", "Hayden", "Smith")
    token = AuthRegDict['token']
    AuthRegDict2 = auth_register("*****@*****.**", "1123456", "Hayen", "Sith")
    token2 = AuthRegDict['token']
    publicChan = channels_create(token2, "public", True)
    publicId = publicChan['channel_id']
    
    message_send(token2, publicId, "message one")
    messageDic = channel_messages(token2, publicChan, 0)
    ###messageDic{ message_id, u_id, message, time_created, is_unread }
    firstId = messageDic[message_id][0]
    firstMessage = messageDic[message][0]
    ## set up done

    with pytest.raises(AccessError, match=r"*"):
        message_pin(token, firstId)
Esempio n. 8
0
def test_standup_send_correct():
    # SETUP BEGIN
    authRegDict = auth_register("*****@*****.**", "Abcd1234", "Sherry",
                                "Birkin")
    token = authRegDict['token']
    channel = channels_create(token, "Private_Channel", True)
    channel_id = channel['channel_id']
    # SETUP END

    standup_send(token, channel_id, "Hello!!")
    standup_send(token, channel_id, "Just created a channel")
Esempio n. 9
0
def test_standup_send_channel_not_exist():
    # SETUP BEGIN
    authRegDict = auth_register("*****@*****.**", "Abcd1234", "Sherry",
                                "Birkin")
    token = authRegDict['token']

    channel_id = "1234"
    # SETUP END

    # Channel does not exist
    with pytest.raises(ValueError, match=r"*"):
        standup_send(token, channel_id, "Hello!!")
Esempio n. 10
0
def Channel_invite_test():
    #setup
    user1 = auth_register("*****@*****.**", "pass", "userfirst", "userlast")
    user1_token = user1['token']

    user2 = auth_register("*****@*****.**", "pass", "user2first",
                          "user2last")
    user2_token = user2['token']

    user3 = auth_register("*****@*****.**", "pass", "user3first",
                          "user3last")
    user3_token = user3['token']

    user4 = auth_register("*****@*****.**", "pass", "user4first",
                          "user4last")
    user4_token = user4['token']

    channel_id = channels_create(user2_token, 'test', False)
    #end setup

    #expected invite procedure
    Channel_invite(user2_token, channel_id, user1['u_id'])
    assert in_channel(user1_token, channel_id) == True

    #invalid channel id
    with pytest.raises(ValueError, match=r"*"):
        Channel_invite(user2_token, 'invalid channel id', user3['u_id'])

    #user is not in channel
    with pytest.raises(ValueError, match=r"*"):
        Channel_invite(user4_token, channel_id, user3['u_id'])

    #inviting a user with an invalid u_id
    with pytest.raises(ValueError, match=r"*"):
        Channel_invite(user4_token, channel_id, 'invalid u_id')

    #user to be invited is already in channel
    with pytest.raises(ValueError, match=r"*"):
        Channel_invite(user2_token, channel_id, user1['u_id'])
Esempio n. 11
0
def test_Channels_list():
    #setup
    user = auth_register("*****@*****.**", "pass", "userfirst", "userlast")
    user_token = user1['token']

    user2 = auth_register("*****@*****.**", "pass", "user2", "user2")
    user2_token = user1['token2']

    channel_id = channels_create (user_token, 'test', False)
    channel_id2 = channels_create (user_token, 'test2', False)
    channel_id3 = channels_create (user_token, 'test3', False)
    #end setup

    #invalid token call
    with pytest.raises (ValueError, match =r"*"):
        channels_list ('invalid token')

    #standard channel list call
    assert channels_listall(user_token) == {'test','test2'}

    #return channels user is not in
    assert channels_listall(user2_token) == {'test','test2','test3'}
    pass
Esempio n. 12
0
def test_standup_send_long_message():
    # SETUP BEGIN
    authRegDict = auth_register("*****@*****.**", "Abcd1234", "Sherry",
                                "Birkin")
    token = authRegDict['token']
    channel = channels_create(token, "Private_Channel", True)
    channel_id = channel['channel_id']
    # SETUP END

    with pytest.raises(ValueError, match=r"*"):
        standup_send(
            token, channel_id,
            "Hellooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo!!"
        )
Esempio n. 13
0
def channel_leave_test():
    # Begin setup
    auth_user1_dict = auth_register("*****@*****.**", "user1", "random", "rand")
    user1_token = auth_user1['token']

    auth_user2_dict = auth_register ("*****@*****.**", "user2", "random2", "rand2")
    user2_token = auth_user2['token']

    channel_id = channels_create (user2_token, 'test', True)
    channel_join (user1_token, channel_id)
    # End setup

    #standard leave procedure
    channel_leave (user1_token, channel_id)
    assert channel_id not in channels_list (user1_token)

    #user is not in channel
    with pytest.raises(ValueError, match=r"*"):
        channel_leave (user1_token, channel_id)

    #invalid channel id
    user3_token = 'invalid token'
    with pytest.raises(ValueError, match = r"*"):
        channel_leave (user2_token, 'invalid channel id')    
Esempio n. 14
0
def test_message_edit():
    ## set up
    AuthRegDict = auth_register("*****@*****.**", "123456", "Hayden", "Smith")
    token = AuthRegDict['token']

    publicChan = channels_create(token, "public", True)
    publicId = publicChan['channel_id']
    ## end setup
    
    
    message_send(token, publicId, "message one")
    messageDic = channel_messages(token, publicChan, 0)
    ###messageDic{ message_id, u_id, message, time_created, is_unread }
    firstId = messageDic[message_id][0]
    firstMessage = messageDic[message][0]
    ## end setup
    message_edit(token, firstId, "edited message one")
    
    messageDic1 = channel_messages(token, publicChan, 0)
    ###messageDic{ message_id, u_id, message, time_created, is_unread }
    editFirstId = messageDic[message_id][0]
    editFirstMessage = messageDic[message][0]
    assert editFirstMessage == "edit message one"
    assert editFirstId == firstId
Esempio n. 15
0
import pytest

from auth_login import auth_login
from auth_register import auth_register
from GLOBAL import GLOBAL_DATA, User, generate_token, generate_user_id

# Register user
user1 = auth_register('*****@*****.**', 'valid_password', 'valid_first',
                      'valid_last')

user2 = auth_register('*****@*****.**', 'valid_password2',
                      'valid_first2', 'valid_last2')


def test_auth_login_incorrect_password():
    # Test incorrect password for a valid user
    with pytest.raises(ValueError):
        auth_login('*****@*****.**', 'incorrect_password')


def test_auth_login_invalid_email():
    # Test invalid input for email
    with pytest.raises(ValueError):
        auth_login('invalid_email', 'valid_password')


def test_auth_login_nonuser():
    # Test email that does not belong to a user
    with pytest.raises(ValueError):
        auth_login('*****@*****.**', 'valid_password')
import pytest

from auth_login import auth_login
from auth_register import auth_register
from channel_invite import channel_invite
from channel_create import channel_create
from Error import AccessError

# Create channel owner
user1 = auth_register('*****@*****.**', 'valid_password1',
                      'valid_first1', 'valid_last1')
res1 = auth_login('*****@*****.**', 'valid_password1')
token1 = res1['token']
channel_id1 = channel_create(token1, 'Example channel 1', True)['channel_id']

# Create user to be invited
user2 = auth_register('*****@*****.**', 'valid_password2',
                      'valid_first2', 'valid_last2')
res2 = auth_login('*****@*****.**', 'valid_password2')
token2 = res2['token']
u_id2 = res2['u_id']

# Create new user who owns a different channel
user3 = auth_register('*****@*****.**', 'valid_password3',
                      'valid_first3', 'valid_last3')
res3 = auth_login('*****@*****.**', 'valid_password3')
token3 = res3['token']
channel_id3 = channel_create(token3, 'Example channel 3', True)['channel_id']


def test_channel_invite_valid():
def test_auth_register_invalid_lastname():
    # Test invalid 50 character last name (50 character boundary test)
    with pytest.raises(ValueError):
        auth_register('*****@*****.**', 'abcdef', 'Firstname',
                      '51_character_lastname_01234567890123456789012345678')
def test_auth_register_invalid_password():
    # Test invalid 4 character password (6 character boundary test)
    with pytest.raises(ValueError):
        auth_register('*****@*****.**', 'abde', 'Firstname', 'Lastname')
import pytest

from Error import AccessError
from user_profile_setname import user_profile_setname
from auth_login import auth_login
from auth_register import auth_register
from user_all import user_all
from standup_start import standup_start
from standup_send import standup_send
from channel_create import channel_create

user1 = auth_register('*****@*****.**', 'valid_password1',
                      'valid_first1', 'valid_last1')
res1 = auth_login('*****@*****.**', 'valid_password1')
token1 = res1['token']
u_id1 = res1['u_id']
channel_id1 = channel_create(token1, 'Example channel 1', True)['channel_id']


def test_standup_send_1():
    #testing valid case
    standup_start(token1, channel_id1, 3)
    assert standup_send(token1, channel_id1, "test") == {}

    #testing invalid case
    #assert admin_userpermission_change("!", 135 , "eaifjij") == {}


"""
def test_standup_send_2():
    #ValueError exceptions Channel (based on ID) does not exist
from auth_login import auth_login
from auth_passwordreset_request import auth_password_reset_req
from auth_register import auth_register
import pytest

# Register a user with valid credentials and log them in
user1 = auth_register('*****@*****.**', 'valid_password1', 'valid_first1',
                      'valid_last1')
res1 = auth_login('*****@*****.**', 'valid_password1')


def test_auth_passwordreset_request_valid_user():
    # Test a valid email belonging to a registered user
    assert auth_password_reset_req('*****@*****.**') == {}


def test_auth_passwordreset_request_non_user():
    # Test a valid email that does not belong to a registered user
    with pytest.raises(ValueError):
        auth_password_reset_req('*****@*****.**')
def test_auth_register_emails_exists():
    # Test valid email, password, name_first and name_last at boundaries
    with pytest.raises(ValueError):
        auth_register('*****@*****.**', 'abcdefef', 'Firstname', 'Lastname')
Esempio n. 22
0
import pytest
from GLOBAL import (GLOBAL_DATA, User, Channel, generate_token,
                    generate_user_id, get_user_from_token, get_user_from_u_id,
                    Message, is_admin_or_owner_token, re_calibrate_msgID,
                    get_u_id_from_token)

from user_profile_sethandle import user_profile_sethandle
from auth_login import auth_login
from auth_register import auth_register

user = auth_register('*****@*****.**', 'valid_password', 'valid_first',
                     'valid_last')
res2 = auth_login('*****@*****.**', 'valid_password')
token1 = res2['token']
u_id = res2['u_id']


def test_user_profile_sethandle_1():
    #testing valid case
    assert GLOBAL_DATA["users"][0].handle_name == ""
    assert user_profile_sethandle(token1, "I" * 20) == {}
    assert GLOBAL_DATA["users"][0].handle_name == "I" * 20


def test_user_profile_sethandle_another():
    #testing valid case
    assert user_profile_sethandle(token1, "asshole") == {}
    assert GLOBAL_DATA["users"][0].handle_name == "asshole"


def test_user_profile_sethandle_2():
def test_auth_register_invalid_email():
    # Test invalid email
    with pytest.raises(ValueError):
        auth_register('invalid_email', 'abcdef', 'Firstname', 'Lastname')
Esempio n. 24
0
import pytest

from auth_login import auth_login
from auth_register import auth_register
from channel_create import channel_create
from message_send import message_send
from channel_join import channel_join
from message_edit import message_edit

from Error import AccessError

user1 = auth_register("*****@*****.**", "valid_password1",
                      "valid_first1", "valid_last1")
res1 = auth_login("*****@*****.**", "valid_password1")
token1 = res1["token"]
channel_id1 = channel_create(token1, "Example channel 1", True)["channel_id"]

# Create additional user
user2 = auth_register("*****@*****.**", "valid_password2",
                      "valid_first2", "valid_last2")
res2 = auth_login("*****@*****.**", "valid_password2")
token2 = res2["token"]
u_id2 = res2["u_id"]


# Add messages data
def test_message_edit():
    message_send(token1, channel_id1, "test_message1")  # assume message id 0
    channel_join(token2, channel_id1)
    message_send(token2, channel_id1, "test_message2")  # assume message id 1
    # Test valid message edit
Esempio n. 25
0
def test_auth_register_valid():
    # Test valid email, password, name_first and name_last at boundaries
    assert auth_register('*****@*****.**', 'abcdefr',
                '49_character_firstname',
                '49_character_lastname') == { 'u_id': 0, 'token': generate_token('*****@*****.**') }