def __init__(self, apis): GenericTest.__init__(self, apis) if not ENABLE_HTTPS: raise NMOSInitException( "BCP-003-01 can only be tested when ENABLE_HTTPS is set to True in Config.py" ) self.report_json = {}
def run_tests(test, endpoints, test_selection=["all"]): if test in TEST_DEFINITIONS: test_def = TEST_DEFINITIONS[test] protocol = "http" if ENABLE_HTTPS: protocol = "https" apis = {} for index, spec in enumerate(test_def["specs"]): base_url = "{}://{}:{}".format(protocol, endpoints[index]["host"], str(endpoints[index]["port"])) spec_key = spec["spec_key"] api_key = spec["api_key"] try: ipaddress.ip_address(endpoints[index]["host"]) ip_address = endpoints[index]["host"] except ValueError: ip_address = socket.gethostbyname(endpoints[index]["host"]) apis[api_key] = { "base_url": base_url, "hostname": endpoints[index]["host"], "ip": ip_address, "port": int(endpoints[index]["port"]), "url": "{}/x-nmos/{}/{}/".format(base_url, api_key, endpoints[index]["version"]), "version": endpoints[index]["version"], "spec": None # Used inside GenericTest } if SPECIFICATIONS[spec_key][ "repo"] is not None and api_key in SPECIFICATIONS[ spec_key]["apis"]: apis[api_key]["spec_path"] = CACHE_PATH + '/' + spec_key apis[api_key]["raml"] = SPECIFICATIONS[spec_key]["apis"][ api_key]["raml"] # Instantiate the test class if test == "IS-04-01": # This test has an unusual constructor as it requires a registry instance test_obj = test_def["class"](apis, REGISTRIES, NODE, DNS_SERVER) else: test_obj = test_def["class"](apis) core_app.config['TEST_ACTIVE'] = True try: result = test_obj.run_tests(test_selection) except Exception as ex: print(" * ERROR: {}".format(ex)) raise ex finally: core_app.config['TEST_ACTIVE'] = False return {"result": result, "def": test_def, "base_url": base_url} else: raise NMOSInitException("This test definition does not exist")
def __init__(self, apis): super(IS1001Test, self).__init__(apis) if not ENABLE_HTTPS: raise NMOSInitException("IS-10 can only be tested when ENABLE_HTTPS is set to True in Config.py") self.url = self.apis[AUTH_API_KEY]["url"] self.bearer_tokens = [] self.client_data = {} self.auth_codes = [] self.clients = [] # List of all registered clients for deleting during clean-up self.zc = Zeroconf() self.zc_listener = MdnsListener(self.zc)
def run_tests(test, endpoints, test_selection=["all"]): if test in TEST_DEFINITIONS: test_def = TEST_DEFINITIONS[test] apis = {} for index, spec in enumerate(test_def["specs"]): base_url = "http://{}:{}".format(endpoints[index]["ip"], str(endpoints[index]["port"])) spec_key = spec["spec_key"] api_key = spec["api_key"] apis[api_key] = { "raml": SPECIFICATIONS[spec_key]["apis"][api_key]["raml"], "base_url": base_url, "url": "{}/x-nmos/{}/{}/".format(base_url, api_key, endpoints[index]["version"]), "spec_path": CACHE_PATH + '/' + spec_key, "version": endpoints[index]["version"], "spec": None # Used inside GenericTest } # Instantiate the test class if test == "IS-04-01": # This test has an unusual constructor as it requires a registry instance test_obj = test_def["class"](apis, REGISTRIES, NODE, DNS_SERVER) else: test_obj = test_def["class"](apis) core_app.config['TEST_ACTIVE'] = True try: result = test_obj.run_tests(test_selection) except Exception as ex: print(" * ERROR: {}".format(ex)) raise ex finally: core_app.config['TEST_ACTIVE'] = False return { "result": result, "name": test_def["name"], "base_url": base_url } else: raise NMOSInitException("This test definition does not exist")