Files
wlan-testing/tests/controller_tests/ucentral_gateway/test_provisionservice.py
Shivam Thakur 516358d1b5 Wifi 7868 restructuring sanity suite to cover golden coverage of suites (#529)
* WIFI-7868: Added ow_sanity_lf suite for sanity restructuring

Added client connectivity tests under the ow_sanity_lf

Signed-off-by: shivam <shivam.thakur@candelatech.com>

* [WIFI-7869] Fix: regression testing AWS variables placement

Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>

* [WIFI-7779] Add: helm deploy support for mailer envs (#517)

Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>

* Also pin kubectl version when destroying namespace

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* [WIFI-7604] Add workflows to test deployment upgrade paths (#471)

* Create and switch to composite action for Docker Compose in Kubernetes deployment

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Add missing inputs to composite action

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Add input for hashed password and adapt variable names

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Fix input variable names

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Add Docker Compose upgrade test workflow

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Get deploy script according to deployment_version input

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Hard-code branch for testing

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Re-add RTTY_TOKEN for testing previous release upgrades

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* [WIFI-7697] Move deploy related files from wlan-testing to wlan-cloud-ucentral-deploy (#472)

* Change composite actions and workflows to use wlan-cloud-ucentral-deploy repo

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Checkout target branch matching with deployment version

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Remove working-directory option

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Rename image version variables to enable search and replace in deploy script

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Remove defaults from action inputs

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Try removing owsub and owanalytics ports for 2.4 deployment

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Actually remove ports since commenting out doesn't work

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* [WIFI-7766] Switch Docker Compose testing workflow to deployment on EC2 (#499)

* Switch from Kubernetes pod to EC2 instance deployment

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Fix indentation

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Add VPC subnet ID to use existing security group

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Move env variable definition to executed SSH command

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Remove defaults from inputs to avoid overwriting deployment_version

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Fix syntax

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Fix variable syntax

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Add my own SSH key for debugging

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Revert "Add my own SSH key for debugging"

This reverts commit e4a9fee140.

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Increase AWS instance size

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Update package lists before installing

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Add curl insecure option and append self-signed REST API cert to AP cert trust store

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Pass FLAGS variable to clustersysteminfo Docker container

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Switch to github.run_number for uniqueness

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Start Docker manually on instance

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Install Docker using the repository

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Do not destroy created instances for debugging

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Quote selfsigned_restapi_ca

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Split SSH commands into multiple lines for better readability

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Fix syntax

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Fix typo

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Revert "Split SSH commands into multiple lines for better readability"

This reverts commit c08ec026cfe3915e36cef3215226b41dd0319ed8.

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Revert "Fix syntax"

This reverts commit f408cfd19f5cf01d6b1d1f78c930897f9442c7de.

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Add debugging output for REST API CA cert

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Add: RTTY_TOKEN env for older versions support

Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>

* Download self-signed REST API CA cert directly to virtual AP

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Switch to self-signed certs

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Fix variable name

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Fix step name

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Change hostname and use sudo to add hosts entry

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Fix syntax

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Actually add IP to hosts entry

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Fix missing hostname in AP hosts entry

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Adapt Docker Compose upgrade workflow to EC2 instance deployment

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Configure Docker to log to logstash input

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Fix Docker daemon config

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Add missing EOF

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Fix indentation

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Fix syntax

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Try to fix syntax again

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Use different delimiter

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Fix conflict after rebase

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Fix workflow syntax

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Disable StrictHostKeyChecking in workflow

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

Co-authored-by: Dmitry Dunaev <dmitry@opsfleet.com>

* Remove obsolete inputs and add RTTY_TOKEN to other workflows as well

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Fix value file names

Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>

* Wifi 7858 (#518)

* Crated a new file for FMS related testcases

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

* Removed Fms system ifo test case from gateway service file

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

* Added Location related test cases of Prov UI

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

* Added Location related functions for support

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

* Changed the function name

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

* Changed the allure attachment names on edit functions

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

* WIFI-7868: Added multivlan scenarios in ow_sanity and removed Some of the rate limiting as they take a long time to complete

Added few up, dw, up+dw in rate limit for ow_sanity_lf

Signed-off-by: shivam <shivam.thakur@candelatech.com>

* WIFI-7868 : Added dvlan and rate limit from radius in sanity suite and reduced the rate limiting tests as they are taking alot of time

Signed-off-by: shivam <shivam.thakur@candelatech.com>

* WIFI-7868 Adding some marker improvements to reduce number of test cases and increase coverage

optimised rate limiting, added dvlan, added rate limit with radius

Signed-off-by: shivam <shivam.thakur@candelatech.com>

Co-authored-by: Dmitry Dunaev <dmitry@opsfleet.com>
Co-authored-by: Dmitry Dunaev <83591011+dunaev-opsfleet@users.noreply.github.com>
Co-authored-by: Johann Hoffmann <johann.hoffmann@mailbox.org>
Co-authored-by: Haricharan Jaka <87761091+haricharan-jaka@users.noreply.github.com>
2022-05-17 01:32:12 +05:30

435 lines
18 KiB
Python

"""
Provision Services Rest API Tests
"""
import string
import random
import pytest
import json
import allure
@pytest.mark.ow_sanity_lf
@pytest.mark.uc_sanity
@pytest.mark.owprov_api_tests
@allure.feature("SDK PROV REST API")
class TestUcentralProvisionService(object):
@pytest.mark.sdk_restapi
@pytest.mark.prov_api
def test_provservice_inventorylist(self, setup_prov_controller, get_configuration):
"""
Test the device present in Provisioning UI
"""
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_edit_delete_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 create device", body=body)
if resp.status_code != 200:
assert False
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
# This is for Edititng the information fo device in Inventory
editing_payload = {
"description": "For testing API through automation after editing",
"devClass": "any",
"deviceType": "edgecore_eap101",
"entity": "",
"name": "Testing_to_add_device_through_automation",
"notes": [],
"rrm": "inherit",
"venue": ""
}
print(json.dumps(editing_payload))
resp = setup_prov_controller.edit_device_from_inventory(device_name, editing_payload)
allure.attach(name="response: ", body=str(resp.json()))
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov edited device", body=body)
if resp.status_code != 200:
assert False
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 edited device-verify", body=body)
if resp.status_code != 200:
assert False
resp = setup_prov_controller.delete_device_from_inventory(device_name)
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
@pytest.mark.prov_api_entity_test
def test_prov_service_create_edit_delete_entity(self, setup_prov_controller, testbed):
"""
Test the create Entity in provision Inventory
"""
payload = {"name": "Testing_prov",
"rrm": "inherit",
"description": "For testing Purposes through Automation",
"notes": [{"note": "For testing Purposes through Automation"}],
"parent": "0000-0000-0000"
}
print(json.dumps(payload))
resp = setup_prov_controller.add_entity(payload)
allure.attach(name="response: ", body=str(resp.json()))
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov create entity", body=body)
if resp.status_code != 200:
assert False
entitiy = json.loads(resp.text)
print(entitiy)
entity_id = entitiy['id']
resp = setup_prov_controller.get_entity_by_id(entity_id)
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
# This to edit Entity
editing_payload = {
"description": "For testing Purposes through Automation after edit",
"deviceConfiguration": [],
"name": "Testing_prov",
"notes": [],
"rrm": "inherit",
"sourceIP": [],
"uuid": entity_id
}
print(json.dumps(editing_payload))
resp = setup_prov_controller.edit_entity(editing_payload, entity_id)
allure.attach(name="response: ", body=str(resp.json()))
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov edited entity", body=body)
if resp.status_code != 200:
assert False
entitiy = json.loads(resp.text)
print(entitiy)
resp = setup_prov_controller.get_entity_by_id(entity_id)
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov edited device-verify", body=body)
if resp.status_code != 200:
assert False
resp = setup_prov_controller.delete_entity(entity_id)
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.prov_api_entity
def test_get_entities(self, setup_prov_controller):
resp = setup_prov_controller.get_entity()
print(resp.json())
allure.attach(name="Entities", body=str(resp.json()), attachment_type=allure.attachment_type.JSON)
assert resp.status_code == 200
# Contact related Test cases
@pytest.mark.prov_api_contact
def test_get_contacts(self, setup_prov_controller):
resp = setup_prov_controller.get_contact()
print(resp.json())
allure.attach(name="Contacts", body=str(resp.json()), attachment_type=allure.attachment_type.JSON)
assert resp.status_code == 200
@pytest.mark.prov_api_contact_test
def test_prov_service_create_edit_delete_contact(self, setup_prov_controller, testbed):
"""
Test the create Contact in provision Inventory
"""
payload = {
"name": "Prov-Testing-through-Automation",
"type": "USER",
"title": "Testing_contact",
"salutation": "",
"firstname": "ProvTesting",
"lastname": "Through Automation",
"initials": "",
"visual": "",
"phones": [],
"mobiles": [],
"primaryEmail": "tip@ucentral.com",
"secondaryEmail": "",
"accessPIN": "",
"description": "",
"initialNote": "",
"entity": "0000-0000-0000",
"notes": [{"note": ""}]
}
print(json.dumps(payload))
resp = setup_prov_controller.add_contact(payload)
allure.attach(name="response: ", body=str(resp.json()))
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov create contact", body=body)
if resp.status_code != 200:
assert False
contact = json.loads(resp.text)
print(contact)
contact_id = contact['id']
resp = setup_prov_controller.get_contact_by_id(contact_id)
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov create contact-verify", body=body)
if resp.status_code != 200:
assert False
# This to edit Entity
editing_payload = {
"accessPIN": "",
"description": "",
"entity": "0000-0000-0000",
"firstname": "ProvTesting",
"initials": "",
"lastname": "Through Automation",
"mobiles": [],
"name": "Prov-Testing-Automation API's",
"notes": [],
"phones": [],
"primaryEmail": "tip@ucentral.com",
"salutation": "",
"secondaryEmail": "",
"title": "Testing_contact",
"type": "USER"
}
print(json.dumps(editing_payload))
resp = setup_prov_controller.edit_contact(editing_payload, contact_id)
allure.attach(name="response: ", body=str(resp.json()))
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov edited contact", body=body)
if resp.status_code != 200:
assert False
entitiy = json.loads(resp.text)
print(entitiy)
resp = setup_prov_controller.get_contact_by_id(contact_id)
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov edited contact-verify", body=body)
if resp.status_code != 200:
assert False
resp = setup_prov_controller.delete_contact(contact_id)
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov created contact-delete", body=body)
if resp.status_code != 200:
assert False
# Location related Test cases
@pytest.mark.prov_api_location
def test_get_locations(self, setup_prov_controller):
resp = setup_prov_controller.get_location()
print(resp.json())
allure.attach(name="location", body=str(resp.json()), attachment_type=allure.attachment_type.JSON)
assert resp.status_code == 200
@pytest.mark.prov_api_location_test
def test_prov_service_create_edit_delete_location(self, setup_prov_controller, testbed):
"""
Test the create location in provision Inventory
"""
payload = {
"name": "TIP",
"type": "AUTO",
"buildingName": "",
"addressLines": ["Pedda Rushikonda"],
"city": "Visakhapatnam",
"state": "Andhra pradesh",
"postal": "530045",
"country": "IN",
"phones": [],
"mobiles": [],
"geoCode": "",
"description": "For Testing through Automation",
"initialNote": "Testing purposes through Automation",
"entity": "0000-0000-0000",
"notes": [{"note": "Testing purposes"}]
}
print(json.dumps(payload))
resp = setup_prov_controller.add_location(payload)
allure.attach(name="response: ", body=str(resp.json()))
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov create location", body=body)
if resp.status_code != 200:
assert False
location = json.loads(resp.text)
print(location)
location_id = location['id']
resp = setup_prov_controller.get_location_by_id(location_id)
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov create location-verify", body=body)
if resp.status_code != 200:
assert False
# This to edit Entity
editing_payload = {
"addressLines": [
"Madhurawada",
""
],
"buildingName": "",
"city": "Visakhapatnam",
"country": "IN",
"description": "Candela Testing",
"entity": "0000-0000-0000",
"geoCode": "",
"mobiles": [],
"name": "Candela IND",
"notes": [],
"phones": [],
"postal": "530048",
"state": "Andhra Pradesh",
"type": "SERVICE"
}
print(json.dumps(editing_payload))
resp = setup_prov_controller.edit_location(editing_payload, location_id)
allure.attach(name="response: ", body=str(resp.json()))
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov edited location", body=body)
if resp.status_code != 200:
assert False
entitiy = json.loads(resp.text)
print(entitiy)
resp = setup_prov_controller.get_location_by_id(location_id)
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov edited location-verify", body=body)
if resp.status_code != 200:
assert False
resp = setup_prov_controller.delete_location(location_id)
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov created location-delete", body=body)
if resp.status_code != 200:
assert False
# Venue related Test cases
@pytest.mark.prov_api_venue
def test_get_venue(self, setup_prov_controller):
resp = setup_prov_controller.get_venue()
print(resp.json())
allure.attach(name="venue", body=str(resp.json()), attachment_type=allure.attachment_type.JSON)
assert resp.status_code == 200
@pytest.mark.prov_api_venue_test
def test_prov_service_create_edit_delete_venue(self, setup_prov_controller, testbed):
"""
Test the create venue in provision Inventory
"""
payload = {
"description": "For testing Purposes",
"entity": "6a657863-9940-4303-ac68-4cc10d3078ec",
"location": "",
"name": "Testing Prov",
"notes": [
{
"note": "For testing Purposes"
}
],
"parent": "",
"rrm": "inherit"
}
print(json.dumps(payload))
resp = setup_prov_controller.add_venue(payload)
allure.attach(name="response: ", body=str(resp.json()))
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov create venue", body=body)
if resp.status_code != 200:
assert False
venue = json.loads(resp.text)
print(venue)
venue_id = venue['id']
resp = setup_prov_controller.get_venue_by_id(venue_id)
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov create venue-verify", body=body)
if resp.status_code != 200:
assert False
# This to edit venue
editing_payload = {
"description": "For testing Purposes through Automation",
"location": "",
"name": "Testing Prov",
"notes": [],
"rrm": "inherit",
"sourceIP": []
}
print(json.dumps(editing_payload))
resp = setup_prov_controller.edit_venue(editing_payload, venue_id)
allure.attach(name="response: ", body=str(resp.json()))
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov edited venue", body=body)
if resp.status_code != 200:
assert False
entitiy = json.loads(resp.text)
print(entitiy)
resp = setup_prov_controller.get_venue_by_id(venue_id)
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov edited venue-verify", body=body)
if resp.status_code != 200:
assert False
resp = setup_prov_controller.delete_venue(venue_id)
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="Prov created venue-delete", body=body)
if resp.status_code != 200:
assert False