Example #1
0
def test_settings_api_admin_get(session, admin1_logged):
    '''Setting API get call by Admin'''
    #call get without ID
    check_api_get(url_for('admin.settings_api'), settings)

    #call get with ID
    check_api_get(url_for('admin.settings_api', id=10), settings)
Example #2
0
def test_settings_api_admin_post(session,admin1_logged):
    '''Setting API POST call by Admin'''
    new_settings = {'unifi_server':'test.test.com','unifi_user':'******','unifi_pass':'******','id':1,'unifi_server_ip':'192.168.1.1'}
    #post  form
    check_api_post(url_for('admin.settings_api'),
                {'unifi_server':'test.test.com','unifi_user':'******','unifi_pass':'******','unifi_server_ip':'192.168.1.1'})
    #retrieve same and verify
    check_api_get(url_for('admin.settings_api'),
                    new_settings)
Example #3
0
def test_settings_api_admin_get(session,admin1_logged):
    '''Setting API get call by Admin'''
    #call get without ID
    check_api_get(url_for('admin.settings_api'),
                    settings)

    #call get with ID
    check_api_get(url_for('admin.settings_api',id=10),
                    settings)
Example #4
0
def test_admin_api_admin_get(session,admin1_logged):
    '''Admin API get call by Admin'''
    #call get without ID, returns datatble
    check_api_get_datatable(url_for('admin.admin_api'),2)
    #call get on self id
    check_api_get(url_for('admin.admin_api',id=1))
    #call get on  id of another admin on same account
    check_api_get(url_for('admin.admin_api',id=2))

    #call get with ID of admin in another account
    check_api_get_error(url_for('admin.admin_api',id=10),'Not Authorized')
Example #5
0
def test_admin_api_admin_get(session, admin1_logged):
    '''Admin API get call by Admin'''
    #call get without ID, returns datatble
    check_api_get_datatable(url_for('admin.admin_api'), 2)
    #call get on self id
    check_api_get(url_for('admin.admin_api', id=1))
    #call get on  id of another admin on same account
    check_api_get(url_for('admin.admin_api', id=2))

    #call get with ID of admin in another account
    check_api_get_error(url_for('admin.admin_api', id=10), 'Not Authorized')
Example #6
0
def test_client_api_client_get(session,client1_logged):
    '''User API get call by Client'''

    client1 = Client.query.filter_by(email='*****@*****.**').first()
    #call get without ID, not authorized
    check_api_get_error(url_for('admin.user_api'),'Not Authorized')

    #call get on  self user id
    check_api_get(url_for('admin.user_api',id=client1.id))

    #call get with ID of client in another account
    check_api_get_error(url_for('admin.user_api',id=5),'Not Authorized')
Example #7
0
def test_client_api_client_get(session, client1_logged):
    '''User API get call by Client'''

    client1 = Client.query.filter_by(email='*****@*****.**').first()
    #call get without ID, not authorized
    check_api_get_error(url_for('admin.user_api'), 'Not Authorized')

    #call get on  self user id
    check_api_get(url_for('admin.user_api', id=client1.id))

    #call get with ID of client in another account
    check_api_get_error(url_for('admin.user_api', id=5), 'Not Authorized')
Example #8
0
def test_client_api_admin_get(session,admin1_logged):
    '''Client API get call by Admin'''

    client1 = Client.query.filter_by(email='*****@*****.**').first()
    client2 = Client.query.filter_by(email='*****@*****.**').first()
    #call get without ID, returns datatble
    check_api_get_datatable(url_for('admin.client_api'),2)

    #call get on  id of client on same account
    check_api_get(url_for('admin.client_api',id=client1.id))

    #call get with ID of client in another account
    check_api_get_error(url_for('admin.client_api',id=client2.id),'Not Authorized')
Example #9
0
def test_device_api_client_get(session,client1_logged):
    '''Device API get call by Client'''
    site1 = Wifisite.query.filter_by(unifi_id='site1').first()
    site3 = Wifisite.query.filter_by(unifi_id='site3').first()

    #call get without ID, get all sites in account
    data = check_api_get(url_for('admin.device_api'))
    assert 3 == len(data),'Length of json data returned by AP API is not right'

    #call get on  self user id
    check_api_get(url_for('admin.device_api',id=site1.id))

    #call get with ID of client in another account
    check_api_get_error(url_for('admin.device_api',id=site3.id),'Not Authorized')
Example #10
0
def test_client_api_admin_get(session, admin1_logged):
    '''Client API get call by Admin'''

    client1 = Client.query.filter_by(email='*****@*****.**').first()
    client2 = Client.query.filter_by(email='*****@*****.**').first()
    #call get without ID, returns datatble
    check_api_get_datatable(url_for('admin.client_api'), 2)

    #call get on  id of client on same account
    check_api_get(url_for('admin.client_api', id=client1.id))

    #call get with ID of client in another account
    check_api_get_error(url_for('admin.client_api', id=client2.id),
                        'Not Authorized')
Example #11
0
def test_ap_api_client_get(session, client1_logged):
    '''Accesspoint API get call by Client'''
    site1 = Wifisite.query.filter_by(unifi_id='site1').first()
    site3 = Wifisite.query.filter_by(unifi_id='site3').first()

    #call get without ID, get all sites in account
    data = check_api_get(url_for('admin.ap_api'))
    assert 4 == len(
        data), 'Length of json data returned by AP API is not right'

    #call get on  self user id
    check_api_get(url_for('admin.ap_api', id=site1.id))

    #call get with ID of client in another account
    check_api_get_error(url_for('admin.ap_api', id=site3.id), 'Not Authorized')
Example #12
0
def test_settings_api_admin_post(session, admin1_logged):
    '''Setting API POST call by Admin'''
    new_settings = {
        'unifi_server': '192.168.1.1',
        'unifi_user': '******',
        'unifi_pass': '******',
        'id': 1
    }
    #post  form
    check_api_post(
        url_for('admin.settings_api'), {
            'unifi_server': '192.168.1.1',
            'unifi_user': '******',
            'unifi_pass': '******'
        })
    #retrieve same and verify
    check_api_get(url_for('admin.settings_api'), new_settings)