uci api test cases

Signed-off-by: shivamcandela <shivam.thakur@candelatech.com>
This commit is contained in:
shivamcandela
2021-06-25 23:19:20 +05:30
parent db3ed8d38c
commit 06abff8064
6 changed files with 47 additions and 16 deletions

View File

@@ -20,7 +20,7 @@ class ConfigureController:
self.password = controller_data["password"] self.password = controller_data["password"]
self.host = urlparse(controller_data["url"]) self.host = urlparse(controller_data["url"])
self.access_token = "" self.access_token = ""
self.login() self.login_resp = self.login()
def build_uri(self, path): def build_uri(self, path):
new_uri = 'https://%s:%d/api/v1/%s' % (self.host.hostname, self.host.port, path) new_uri = 'https://%s:%d/api/v1/%s' % (self.host.hostname, self.host.port, path)
@@ -34,6 +34,7 @@ class ConfigureController:
self.check_response("POST", resp, "", payload, uri) self.check_response("POST", resp, "", payload, uri)
token = resp.json() token = resp.json()
self.access_token = token["access_token"] self.access_token = token["access_token"]
return resp
def logout(self): def logout(self):
global access_token global access_token
@@ -41,6 +42,7 @@ class ConfigureController:
resp = requests.delete(uri, headers=self.make_headers(), verify=False) resp = requests.delete(uri, headers=self.make_headers(), verify=False)
self.check_response("DELETE", resp, self.make_headers(), "", uri) self.check_response("DELETE", resp, self.make_headers(), "", uri)
print('Logged out:', resp.status_code) print('Logged out:', resp.status_code)
return resp
def make_headers(self): def make_headers(self):
headers = {'Authorization': 'Bearer %s' % self.access_token} headers = {'Authorization': 'Bearer %s' % self.access_token}
@@ -390,8 +392,8 @@ class UProfileUtility:
# } # }
# #
controller = { controller = {
'url': "https://tip-f34.candelatech.com:16001/api/v1/oauth2", # API base url for the controller # 'url': "https://tip-f34.candelatech.com:16001/api/v1/oauth2", # API base url for the controller
# 'url': 'https://restapi-ucentral-2.cicd.lab.wlan.tip.build/api/v1/oauth2', 'url': 'https://sdk-ucentral-2.cicd.lab.wlan.tip.build:16001/api/v1/oauth2',
'username': "tip@ucentral.com", 'username': "tip@ucentral.com",
'password': 'openwifi', 'password': 'openwifi',
# 'version': "1.1.0-SNAPSHOT", # 'version': "1.1.0-SNAPSHOT",
@@ -408,19 +410,19 @@ profile_data = {
"radius": False "radius": False
} }
obj = UController(controller_data=controller) obj = UController(controller_data=controller)
print(obj.get_devices()) # print(obj.get_devices())
# print(obj.get_device_uuid(serial_number="903cb3944873"))
# obj.get_device_uuid(serial_number="c4411ef53f23") # obj.get_device_uuid(serial_number="c4411ef53f23")
# obj.get_device_uuid(serial_number="c4411ef53f23") # profile_client = UProfileUtility(sdk_client=obj)
profile_client = UProfileUtility(sdk_client=obj) # profile_client.set_radio_config()
profile_client.set_radio_config() # profile_client.set_mode(mode="VLAN")
profile_client.set_mode(mode="VLAN") # ssid_data = {"ssid_name": "ssid_wpa_test_3_vlan", "vlan": 100, "appliedRadios": ["2G", "5G"], "security_key": "something", "security": "none"}
ssid_data = {"ssid_name": "ssid_wpa_test_3", "vlan": 200, "appliedRadios": ["2G", "5G"], "security_key": "something", "security": "none"} # profile_client.add_ssid(ssid_data=ssid_data)
profile_client.add_ssid(ssid_data=ssid_data) # print(profile_client.base_profile_config)
print(profile_client.base_profile_config) # profile_client.push_config(serial_number="903cb3944873")
profile_client.push_config(serial_number="c4411ef53f23")
# print(profile_client.base_profile_config) # print(profile_client.base_profile_config)
# equipments = obj.get_devices() # equipments = obj.get_devices()
# # print(equipments) # print(equipments)
# for i in equipments: # for i in equipments:
# for j in equipments[i]: # for j in equipments[i]:
# for k in j: # for k in j:

View File

@@ -174,18 +174,18 @@ CONFIGURATION = {
'mode': 'wifi5', 'mode': 'wifi5',
'serial': 'c4411ef53f23', 'serial': 'c4411ef53f23',
'jumphost': True, 'jumphost': True,
'ip': "192.168.100.164", # localhost 'ip': "192.168.52.100", # localhost
'username': "lanforge", 'username': "lanforge",
'password': "lanforge", 'password': "lanforge",
'port': 22, # 22, 'port': 22, # 22,
'jumphost_tty': '/dev/ttyUSB0', 'jumphost_tty': '/dev/ttyAP1',
'version': "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/ecw5410/trunk/ecw5410-1.1.0.tar.gz" 'version': "https://tip.jfrog.io/artifactory/tip-wlan-ap-firmware/ecw5410/trunk/ecw5410-1.1.0.tar.gz"
} }
], ],
"traffic_generator": { "traffic_generator": {
"name": "lanforge", "name": "lanforge",
"details": { "details": {
"ip": "192.168.100.209", # localhost, "ip": "192.168.52.100", # localhost,
"port": 8080, # 8802, "port": 8080, # 8802,
"ssh_port": 22, "ssh_port": 22,
"2.4G-Radio": ["wiphy4"], "2.4G-Radio": ["wiphy4"],

View File

@@ -0,0 +1,29 @@
"""
UCI Rest API Tests: Test Login, Logout API's
"""
import pytest
class TestUCIAUTHDEAUTH(object):
"""
pytest -m "uci_login or uci_logout" --ucentral
"""
@pytest.mark.uci_login
def test_uci_auth(self, setup_controller):
"""
pytest -m "uci_login" --ucentral
"""
print(setup_controller.login_resp)
assert setup_controller.login_resp.status_code == 200
@pytest.mark.uci_logout
def test_uci_deauth(self, setup_controller):
"""
pytest -m "uci_logout" --ucentral
"""
resp = setup_controller.logout()
print(resp)
assert resp.status_code == 200