Skip to content

Commit

Permalink
First steps to providing HTTPS testing as-per BCP003-01
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbonney committed Mar 13, 2019
1 parent d0f70f9 commit 472a7b2
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
4 changes: 4 additions & 0 deletions Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
# 0 = unlimited for a really thorough test!
MAX_TEST_ITERATIONS = 0

# Test using HTTPS rather than HTTP as-per AMWA BCP003-01
# WARNING: This setting is currently not fully implemented and classed as experimental.
ENABLE_HTTPS = False

# Definition of each API specification and its versions.
SPECIFICATIONS = {
"is-04": {
Expand Down
7 changes: 5 additions & 2 deletions IS0401Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from TestResult import Test
from GenericTest import GenericTest, NMOSTestException
from IS04Utils import IS04Utils
from Config import ENABLE_DNS_SD, QUERY_API_HOST, QUERY_API_PORT, DNS_SD_MODE, DNS_SD_ADVERT_TIMEOUT, HEARTBEAT_INTERVAL
from Config import ENABLE_DNS_SD, QUERY_API_HOST, QUERY_API_PORT, DNS_SD_MODE, DNS_SD_ADVERT_TIMEOUT, HEARTBEAT_INTERVAL, ENABLE_HTTPS

NODE_API_KEY = "node"

Expand Down Expand Up @@ -224,7 +224,10 @@ def get_registry_resource(self, res_type, res_id):
found_resource = resource[1]["payload"]["data"]
else:
# Look up data from a configured Query API
url = "http://" + QUERY_API_HOST + ":" + str(QUERY_API_PORT) + "/x-nmos/query/" + \
protocol = "http"
if ENABLE_HTTPS:
protocol = "https"
url = protocol + "://" + QUERY_API_HOST + ":" + str(QUERY_API_PORT) + "/x-nmos/query/" + \
self.apis[NODE_API_KEY]["version"] + "/" + res_type + "s/" + res_id
try:
valid, r = self.do_request("GET", url)
Expand Down
6 changes: 5 additions & 1 deletion Node.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import netifaces

from flask import Blueprint, make_response, abort
from Config import ENABLE_HTTPS


class Node(object):
Expand All @@ -25,6 +26,9 @@ def __init__(self):
def get_sender(self, stream_type="video"):
default_gw_interface = netifaces.gateways()['default'][netifaces.AF_INET][1]
default_ip = netifaces.ifaddresses(default_gw_interface)[netifaces.AF_INET][0]['addr']
protocol = "http"
if ENABLE_HTTPS:
protocol = "https"
# TODO: Provide the means to downgrade this to a <v1.2 JSON representation
sender = {
"id": str(uuid.uuid4()),
Expand All @@ -33,7 +37,7 @@ def get_sender(self, stream_type="video"):
"version": "50:50",
"caps": {},
"tags": {},
"manifest_href": "http://{}:5000/{}.sdp".format(default_ip, stream_type),
"manifest_href": "{}://{}:5000/{}.sdp".format(protocol, default_ip, stream_type),
"flow_id": str(uuid.uuid4()),
"transport": "urn:x-nmos:transport:rtp.mcast",
"device_id": str(uuid.uuid4()),
Expand Down
7 changes: 5 additions & 2 deletions nmos-test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from GenericTest import NMOSInitException
from TestResult import TestStates
from Node import NODE, NODE_API
from Config import CACHE_PATH, SPECIFICATIONS, ENABLE_DNS_SD, DNS_SD_MODE
from Config import CACHE_PATH, SPECIFICATIONS, ENABLE_DNS_SD, DNS_SD_MODE, ENABLE_HTTPS
from DNS import DNS
from datetime import datetime, timedelta
from junit_xml import TestSuite, TestCase
Expand Down Expand Up @@ -243,9 +243,12 @@ def index_page():
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 = "http://{}:{}".format(endpoints[index]["ip"], str(endpoints[index]["port"]))
base_url = "{}://{}:{}".format(protocol, endpoints[index]["ip"], str(endpoints[index]["port"]))
spec_key = spec["spec_key"]
api_key = spec["api_key"]
apis[api_key] = {
Expand Down

0 comments on commit 472a7b2

Please sign in to comment.