22import sys
33import os
44import json
5- from aas_test_engines import api , file
5+ from aas_test_engines import api , config , file , http
66from enum import Enum
7+ from typing import Tuple
78
89# https://stackoverflow.com/questions/27981545
910import urllib3
@@ -26,6 +27,14 @@ class OutputFormats(Enum):
2627 HTML = "html"
2728
2829
30+ def _parse_header_value (s : str ) -> Tuple [str , str ]:
31+ try :
32+ key , value = s .split (":" , 1 )
33+ return key .strip (), value .strip ()
34+ except ValueError :
35+ raise argparse .ArgumentTypeError (f"Invalid format for header:value: '{ s } '" )
36+
37+
2938def run_file_test (argv ):
3039 parser = argparse .ArgumentParser (description = "Checks a file for compliance with the AAS meta-model" )
3140 parser .add_argument ("file" , type = argparse .FileType ("rb" ), help = "the file to check" )
@@ -66,6 +75,13 @@ def run_api_test(argv):
6675 parser = argparse .ArgumentParser (description = "Checks a server instance for compliance with the AAS api" )
6776 parser .add_argument ("server" , type = str , help = "server to run the tests against" )
6877 parser .add_argument ("suite" , type = str , help = "test suite (or substring of it)" )
78+ parser .add_argument (
79+ "--header" ,
80+ nargs = "+" ,
81+ default = [],
82+ type = _parse_header_value ,
83+ help = "Additional headers in the format header:value" ,
84+ )
6985 parser .add_argument ("--dry" , action = "store_true" , help = "dry run, do not send requests" )
7086 parser .add_argument ("--version" , type = str , default = api .latest_version ())
7187 parser .add_argument ("--no-verify" , action = "store_true" , help = "do not check TLS certificate" )
@@ -100,13 +116,19 @@ def run_api_test(argv):
100116 else :
101117 suite = suites [0 ]
102118
103- exec_conf = api .ExecConf (
104- server = args .server ,
105- dry = args .dry ,
119+ client = http .HttpClient (
120+ host = args .server ,
106121 verify = not args .no_verify ,
107122 remove_path_prefix = args .remove_path_prefix ,
123+ additional_headers = dict (args .header ),
124+ )
125+ conf = config .CheckApiConfig (
126+ suite = suite ,
127+ version = args .version ,
128+ dry = args .dry ,
108129 )
109- result , mat = api .execute_tests (exec_conf , suite , args .version )
130+
131+ result , mat = api .execute_tests (client , conf )
110132 if args .output == OutputFormats .TEXT :
111133 result .dump ()
112134 elif args .output == OutputFormats .HTML :
0 commit comments