Added system info test case of Provision UI (#474)

* Added system info test case of Provision UI

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* Added url of Provision UI in allure

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* Added Prov UI test cases for creating device in Inventory

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* Repalced = with : in allure of Prov UI url

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* changed the test case name

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* Changed the payload parameters to match Prov UI

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* Added configuration in Prov class

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* Removed the class of ProvUtils

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* Added the prov UI api testcases for adding and deleting a device

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* Removed the configuration file

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* Added prov ui fixture

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* Added Prov UI controller object and fixture

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* Added prov controller obj

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>

* Changed the allure report name for some attchments

Signed-off-by: haricharan-jaka <haricharan.jaka@candelatech.com>
This commit is contained in:
Haricharan Jaka
2022-04-25 21:28:54 +05:30
committed by GitHub
parent 9b475c392f
commit 837ba81d68
4 changed files with 116 additions and 28 deletions

View File

@@ -62,10 +62,7 @@ class ConfigureController:
print(new_uri)
return new_uri
def build_url_prov(self, path):
new_uri = 'https://%s:%d/api/v1/%s' % (self.prov_host.hostname, self.prov_host.port, path)
print(new_uri)
return new_uri
def request(self, service, command, method, params, payload):
if service == "sec":
@@ -209,12 +206,6 @@ class Controller(ConfigureController):
device_info = self.get_device_by_serial_number(serial_number=serial_number)
return device_info["UUID"]
def get_system_prov(self):
uri = self.build_url_prov("system/?command=info")
resp = requests.get(uri, headers=self.make_headers(), verify=False, timeout=100)
self.check_response("GET", resp, self.make_headers(), "", uri)
return resp
class FMSUtils:
@@ -298,22 +289,53 @@ class FMSUtils:
return "error"
class ProvUtils:
class ProvUtils(ConfigureController):
def __init__(self, sdk_client=None, controller_data=None):
if sdk_client is None:
self.sdk_client = Controller(controller_data=controller_data)
self.sdk_client = sdk_client
def __init__(self, controller_data=None):
super().__init__(controller_data)
def build_url_prov(self, path):
new_uri = 'https://%s:%d/api/v1/%s' % (self.prov_host.hostname, self.prov_host.port, path)
print(new_uri)
return new_uri
def get_inventory(self):
response = self.sdk_client.request(service="prov", command="inventory/", method="GET", params=None,
payload="")
if response.status_code == 200:
return response.json()
else:
return {}
uri = self.build_url_prov("inventory")
print(uri)
resp = requests.get(uri, headers=self.make_headers(), verify=False, timeout=100)
self.check_response("GET", resp, self.make_headers(), "", uri)
return resp
def get_inventory_by_device(self, device_name):
uri = self.build_url_prov("inventory/" + device_name)
print(uri)
resp = requests.get(uri, headers=self.make_headers(), verify=False, timeout=100)
self.check_response("GET", resp, self.make_headers(), "", uri)
return resp
def get_system_prov(self):
uri = self.build_url_prov("system/?command=info")
allure.attach(name="Url of Prov UI:", body=str(uri))
resp = requests.get(uri, headers=self.make_headers(), verify=False, timeout=100)
self.check_response("GET", resp, self.make_headers(), "", uri)
return resp
def add_device_to_inventory(self, device_name, payload):
uri = self.build_url_prov("inventory/" + device_name)
print(uri)
print(payload)
payload = json.dumps(payload)
resp = requests.post(uri, data=payload, headers=self.make_headers(), verify=False, timeout=100)
print(resp)
self.check_response("POST", resp, self.make_headers(), payload, uri)
return resp
def delete_device_from_inventory(self, device_name):
uri = self.build_url_prov("inventory/" + device_name)
print(uri)
resp = requests.delete(uri, headers=self.make_headers(), verify=False, timeout=100)
self.check_response("DELETE", resp, self.make_headers(), "", uri)
return resp
class UProfileUtility:

View File

@@ -316,6 +316,14 @@ def setup_controller(request, get_configuration, add_env_properties, fixtures_ve
request.addfinalizer(fixtures_ver.disconnect)
yield sdk_client
# Prov Controller Fixture
@pytest.fixture(scope="session")
def setup_prov_controller(request, get_configuration, add_env_properties, fixtures_ver):
"""sets up the prov controller connection and yields the sdk_client object"""
sdk_client = fixtures_ver.prov_controller_obj
request.addfinalizer(fixtures_ver.disconnect)
yield sdk_client
@pytest.fixture(scope="session")
def setup_firmware(setup_controller):

View File

@@ -13,20 +13,76 @@ import allure
@pytest.mark.uc_sanity
@pytest.mark.prov_all_api
@allure.feature("SDK PROV REST API")
class TestUcentralProvisionService(object):
@pytest.mark.sdk_restapi
@pytest.mark.prov_api
def test_provservice_inventorylist(self, setup_controller):
def test_provservice_inventorylist(self, setup_prov_controller, get_configuration):
"""
Test the list devices endpoint
WIFI-3452
Test the device present in Provisioning UI
"""
resp = setup_controller.request("prov", "inventory", "GET", None, None)
device_name = get_configuration['access_point'][0]['serial']
resp = setup_prov_controller.get_inventory_by_device(device_name)
print(resp.json())
allure.attach(name="Inventory", body=str(resp.json()),attachment_type=allure.attachment_type.JSON)
assert resp.status_code == 200
@pytest.mark.prov_api_test
def test_prov_service_create_inventory_device(self, setup_prov_controller, testbed):
"""
Test the create device in provision Inventory
"""
device_mac = "02:00:00:%02x:%02x:%02x" % (random.randint(0, 255),
random.randint(0, 255),
random.randint(0, 255))
device_name = device_mac.replace(":", "")
# device_name = "deadbeef0011" + testbed.replace("-","")
payload = {"serialNumber": device_name,
"name": "Testing_to_add_device_through_automation",
"rrm": "inherit",
"deviceType": "edgecore_eap101",
"devClass": "any",
"description": "For testing API through automation",
"entity": "",
"venue": "",
"subscriber": "",
"__newConfig":
{"rrm": "inherit",
"firmwareUpgrade": "no",
"configuration": [],
"name": "Device added through automation",
"description": "Created from the Edit Tag menu",
"deviceTypes": ["edgecore_eap101"]
}
}
print(json.dumps(payload))
resp = setup_prov_controller.add_device_to_inventory(device_name, payload)
allure.attach(name="response: ", body=str(resp.json()))
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="prov inventory list", body=body)
allure.attach(name="Prov create device", body=body)
if resp.status_code != 200:
assert False
inven = json.loads(resp.text)
print(inven)
devices = json.loads(resp.text)
print(devices)
resp = setup_prov_controller.get_inventory_by_device(device_name)
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov create device-verify", body=body)
if resp.status_code != 200:
assert False
resp = setup_prov_controller.request("prov", "inventory/" + device_name, "DELETE", None, None)
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov created device-delete", body=body)
if resp.status_code != 200:
assert False
@pytest.mark.system_info_prov
def test_system_info_prov(self, setup_prov_controller):
system_info = setup_prov_controller.get_system_prov()
print(system_info.json())
allure.attach(name="system info", body=str(system_info.json()), attachment_type=allure.attachment_type.JSON)
assert system_info.status_code == 200

View File

@@ -35,6 +35,7 @@ if 'py-json' not in sys.path:
from apnos.apnos import APNOS
from controller.controller_2x.controller import Controller
from controller.controller_2x.controller import FMSUtils
from controller.controller_2x.controller import ProvUtils
from configuration import CONFIGURATION
from configuration import RADIUS_SERVER_DATA
from configuration import RADIUS_ACCOUNTING_DATA
@@ -51,6 +52,7 @@ class Fixtures_2x:
if not run_lf:
try:
self.controller_obj = Controller(controller_data=self.lab_info["controller"])
self.prov_controller_obj = ProvUtils(controller_data=self.lab_info["controller"])
self.fw_client = FMSUtils(sdk_client=self.controller_obj)
except Exception as e:
print(e)