From a798380ddf41a8984530f0715fa7e3a84cdc427b Mon Sep 17 00:00:00 2001 From: Lukas Holecek Date: Jul 04 2019 10:52:37 +0000 Subject: Use unique user agent for waiverdb-cli requests Signed-off-by: Lukas Holecek --- diff --git a/tests/test_cli.py b/tests/test_cli.py index b3b2af6..9b29249 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -190,12 +190,16 @@ oidc_scopes= "comment": "This is fine", "username": None }] + headers = { + 'Content-Type': 'application/json', + 'User-Agent': f'waiverdb-cli {__version__}', + } mock_oidc_req.assert_called_once_with( url='http://localhost:5004/api/v1.0/waivers/', data=json.dumps(exp_json), scopes=['openid'], timeout=60, - headers={'Content-Type': 'application/json'}) + headers=headers) assert result.exit_code == 0 assert result.output.startswith('Created waiver 15 for result with id 123\n') diff --git a/waiverdb/cli.py b/waiverdb/cli.py index 9835208..4f799d5 100644 --- a/waiverdb/cli.py +++ b/waiverdb/cli.py @@ -243,7 +243,10 @@ def cli(username, comment, waived, product_version, testcase, subject, subject_i data = json.dumps(data_list) common_request_arguments = { 'data': data, - 'headers': {'Content-Type': 'application/json'}, + 'headers': { + 'Content-Type': 'application/json', + 'User-Agent': f'waiverdb-cli {__version__}', + }, 'timeout': 60, } if auth_method == 'OIDC':