def test_login_refresh_ok(requests_mock): requests_mock.post(f'https://{__BASE_URL}/api/aaaLogin.json', json={ 'imdata': [{ 'aaaLogin': { 'attributes': { 'refreshTimeoutSeconds': '31', 'token': 'tokenxyz' } } }] }) requests_mock.post(f'https://{__BASE_URL}/api/aaaRefresh.json', json={ 'imdata': [{ 'aaaLogin': { 'attributes': { 'refreshTimeoutSeconds': '300', 'token': 'tokenabc' } } }] }) requests_mock.post(f'https://{__BASE_URL}/api/aaaLogout.json', json={'imdata': []}, status_code=200) aci = ACI(apicIp=__BASE_URL, apicUser='******', apicPasword='unkown', refresh=True) aci.login() token = aci.getToken() time.sleep(2) aci.logout() assert token != aci.getToken()
def test_token_ok(requests_mock): requests_mock.post(f'https://{__BASE_URL}/api/aaaLogin.json', json={'imdata': [ {'aaaLogin': {'attributes': {'token': 'tokenxyz'}}} ]}) aci = ACI(apicIp=__BASE_URL, apicUser='******', apicPasword='unkown') aci.login() token = aci.getToken() assert token == 'tokenxyz'