| Total Complexity | 2 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import multiprocessing |
||
| 2 | from fuzzer.cli.args import cli_args |
||
| 3 | from fuzzer.rest_fuzzer import fuzz |
||
| 4 | from fuzzer.rest_fuzzer.json_schema import make_schema_object |
||
| 5 | |||
| 6 | # |
||
| 7 | # server_host = cli_args.host |
||
| 8 | # server_port = cli_args.port |
||
| 9 | # api_list = cli_args.api_json |
||
| 10 | |||
| 11 | # expect like in example: |
||
| 12 | server_host = 'http://localhost' |
||
| 13 | server_port = 3000 |
||
| 14 | api_list = [{ |
||
| 15 | 'url': '/', |
||
| 16 | 'method': 'POST', |
||
| 17 | 'body': {} |
||
| 18 | }, { |
||
| 19 | 'url': '/test', |
||
| 20 | 'method': 'POST', |
||
| 21 | 'body': { |
||
| 22 | 'messageObject': { |
||
| 23 | 'message': 'hello world' |
||
| 24 | } |
||
| 25 | } |
||
| 26 | }, { |
||
| 27 | 'url': '/string-match', |
||
| 28 | 'method': 'POST', |
||
| 29 | 'body': { |
||
| 30 | 'reference': '', |
||
| 31 | 'hypothesis': '' |
||
| 32 | } |
||
| 33 | }] |
||
| 34 | |||
| 35 | |||
| 36 | process_args = [{ |
||
| 37 | 'host': server_host, |
||
| 38 | 'port': server_port, |
||
| 39 | 'req_body': api_object, |
||
| 40 | 'req_body_schema': make_schema_object(api_object['body']) |
||
| 41 | } for api_object in api_list] |
||
| 42 | |||
| 43 | |||
| 44 | def test_apis(): |
||
| 45 | with multiprocessing.Pool(multiprocessing.cpu_count()) as proc: |
||
| 46 | proc.map(fuzz.api_nx, process_args) |
||
| 47 | |||
| 48 | |||
| 49 | if __name__ == '__main__': |
||
| 50 | test_apis() |
||
| 51 |