コード例 #1
0
def test_channel_leave_invalid_token():
    test_user = auth_register("*****@*****.**", "password", "John",
                              "Smith")
    test_channel = channels_create(test_user["token"], "test_channel", True)
    auth_logout(test_user["token"])  # Invalidating token
    with pytest.raises(AccessError):
        channel_leave(test_user["token"], test_channel["channel_id"])
コード例 #2
0
ファイル: auth_test.py プロジェクト: Kevinwochan/Slackr
def test_logout_twice():
    """Tests logging out twice using the same token"""
    new_user = auth_register('*****@*****.**', 'password',
                             'placeholder_first_name', 'placeholder_last_name')
    assert auth_logout(new_user['token']) == {'is_success': True}
    with pytest.raises(AccessError):
        assert auth_logout(new_user['token']) == {'is_success': False}
コード例 #3
0
def test_channel_join_InvalidToken():
    test_user = auth_register("*****@*****.**", "password", "John",
                              "Smith")
    test_user2 = auth_register("*****@*****.**", "password", "Bob",
                               "Smith")
    test_channel = channels_create(test_user2["token"], "test_channel", True)
    auth_logout(test_user["token"])  # Invalidating token of user1
    with pytest.raises(AccessError):
        channel_join(test_user["token"], test_channel["channel_id"])
コード例 #4
0
ファイル: channels_test.py プロジェクト: Kevinwochan/Slackr
def test_chan_create_invalid_token():
    test_user = auth_register("*****@*****.**", "1234567", "John",
                              "Smith")
    token = test_user['token']
    assert auth_logout(token)  #invalidating token
    with pytest.raises(AccessError):
        auth_logout(token)  #confirming that token is an invalid token

    with pytest.raises(AccessError):
        channels_create(token, 'name', True)
コード例 #5
0
ファイル: channels_test.py プロジェクト: Kevinwochan/Slackr
def test_list_invalid_token():
    test_user = auth_register("*****@*****.**", "1234567", "John",
                              "Smith")
    token = test_user['token']
    assert auth_logout(token)  #invalidating token
    with pytest.raises(AccessError):
        channels_list(token)
コード例 #6
0
ファイル: conftest.py プロジェクト: Kevinwochan/Slackr
def inv_token():
    '''
    Generates an always invalid token
    '''
    inv_token = auth_register('*****@*****.**', 'password',
                              'invalid', 'token')['token']
    # Invalidate the token using logout (and check it worked)
    assert auth_logout(inv_token) == {'is_success': True}
    return inv_token
コード例 #7
0
def auth_logout_wsgi():
    json = request.get_json()
    #token = request.cookies.get('token') TODO
    return jsonify(auth_logout(json['token']))
コード例 #8
0
def test_logout_no_account():
    """Tests logging out without a valid token"""
    with pytest.raises(AccessError):
        assert auth_logout('not a valid token') == {'is_success': False}
コード例 #9
0
ファイル: auth_test.py プロジェクト: Kevinwochan/Slackr
def test_logout():
    """Tests logging out after logging in"""
    new_user = auth_register('*****@*****.**', 'password',
                             'placeholder_first_name', 'placeholder_last_name')
    assert auth_logout(new_user['token']) == {'is_success': True}
コード例 #10
0
def test_invalid_token(new_user, new_user_2):
    '''tests that permission_change throws an AccessError when it's given an invalid token'''
    auth_logout(new_user['token'])  #invalidating token by logging out
    with pytest.raises(AccessError):
        permission_change(new_user['token'], new_user_2['u_id'], 1)