From dbaddaf8591b0b03300d345412b40988bc62114c Mon Sep 17 00:00:00 2001 From: Liam Toozer Date: Thu, 25 Apr 2024 11:57:40 +0100 Subject: [PATCH 1/5] Update to v2 business launch payload --- runner_benchmark/token_generator.py | 40 +++++++++++++++-------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/runner_benchmark/token_generator.py b/runner_benchmark/token_generator.py index 5c3addb1..95d2f19e 100644 --- a/runner_benchmark/token_generator.py +++ b/runner_benchmark/token_generator.py @@ -14,25 +14,27 @@ KEYS_FOLDER = './jwt-test-keys' PAYLOAD = { - 'user_id': 'benchmark-user', - 'period_str': 'July 2019', - 'period_id': '201907', - 'collection_exercise_sid': str(uuid4()), - 'case_id': str(uuid4()), - 'case_type': 'HI', - 'display_address': '68 Abingdon Road, Goathill', - 'ru_ref': '123456789012A', - 'ru_name': 'Integration Testing', - 'ref_p_start_date': '2019-04-01', - 'ref_p_end_date': '2019-11-30', - 'return_by': '2019-12-06', - 'trad_as': 'Benchmark Tests', - 'employment_date': '1983-06-02', - 'region_code': 'GB-ENG', - 'language_code': 'en', - 'roles': [], + 'version': 'v2', 'account_service_url': 'http://upstream.url', - 'variant_flags': {'sexual_identity': 'false'}, + 'case_id': str(uuid4()), + 'collection_exercise_sid': str(uuid4()), + 'response_id': str(uuid4()), + "survey_metadata": { + "data": { + "case_ref": '1000000000000001', + "form_type": '0001', + 'period_id': '201907', + 'period_str': 'July 2019', + 'ref_p_start_date': '2019-04-01', + 'ref_p_end_date': '2019-11-30', + 'ru_name': 'Integration Testing', + 'ru_ref': '123456789012A', + 'trad_as': 'Benchmark Tests', + 'user_id': 'benchmark-user', + 'survey_id': "0", + "employment_date": "2019-04-01", + } + }, } @@ -81,7 +83,7 @@ def _get_payload_with_params(schema_name, schema_url=None, **extra_payload): datetime.now(tz=timezone.utc) + timedelta(days=7) ).isoformat() # 7 days from now in ISO 8601 format for key, value in extra_payload.items(): - payload_vars[key] = value + payload_vars["survey_metadata"]["data"][key] = value return payload_vars From d1ddaf88d38cb2c25e5b18109a89c9ed256e11ae Mon Sep 17 00:00:00 2001 From: Liam Toozer Date: Thu, 25 Apr 2024 12:22:09 +0100 Subject: [PATCH 2/5] Formatting --- runner_benchmark/token_generator.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/runner_benchmark/token_generator.py b/runner_benchmark/token_generator.py index 95d2f19e..43ecd72d 100644 --- a/runner_benchmark/token_generator.py +++ b/runner_benchmark/token_generator.py @@ -19,10 +19,10 @@ 'case_id': str(uuid4()), 'collection_exercise_sid': str(uuid4()), 'response_id': str(uuid4()), - "survey_metadata": { - "data": { - "case_ref": '1000000000000001', - "form_type": '0001', + 'survey_metadata': { + 'data': { + 'case_ref': '1000000000000001', + 'form_type': '0001', 'period_id': '201907', 'period_str': 'July 2019', 'ref_p_start_date': '2019-04-01', @@ -31,8 +31,8 @@ 'ru_ref': '123456789012A', 'trad_as': 'Benchmark Tests', 'user_id': 'benchmark-user', - 'survey_id': "0", - "employment_date": "2019-04-01", + 'survey_id': '0', + 'employment_date': '2019-04-01', } }, } @@ -83,7 +83,7 @@ def _get_payload_with_params(schema_name, schema_url=None, **extra_payload): datetime.now(tz=timezone.utc) + timedelta(days=7) ).isoformat() # 7 days from now in ISO 8601 format for key, value in extra_payload.items(): - payload_vars["survey_metadata"]["data"][key] = value + payload_vars['survey_metadata']['data'][key] = value return payload_vars From 8fc6542a50b6d26b1e2e009fd9397a38d5f6c5a1 Mon Sep 17 00:00:00 2001 From: Liam Toozer Date: Thu, 25 Apr 2024 13:25:40 +0100 Subject: [PATCH 3/5] Update with TOP_LEVEL_METADATA_KEYS for use with top level and arbitrary survey metadata keyvals --- runner_benchmark/token_generator.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/runner_benchmark/token_generator.py b/runner_benchmark/token_generator.py index 43ecd72d..2986bf68 100644 --- a/runner_benchmark/token_generator.py +++ b/runner_benchmark/token_generator.py @@ -13,12 +13,35 @@ KEYS_FOLDER = './jwt-test-keys' +# "version" is excluded here as it is handled independently +TOP_LEVEL_METADATA_KEYS = [ + "exp", + "jti", + "iat", + "tx_id", + "account_service_url", + "case_id", + "collection_exercise_sid", + "response_id", + "response_expires_at", + "language_code", + "schema_name", + "schema_url", + "cir_instrument_id", + "channel", + "region_code", + "roles", +] + PAYLOAD = { 'version': 'v2', 'account_service_url': 'http://upstream.url', 'case_id': str(uuid4()), 'collection_exercise_sid': str(uuid4()), 'response_id': str(uuid4()), + 'language_code': 'en', + 'region_code': 'GB-ENG', + 'roles': [], 'survey_metadata': { 'data': { 'case_ref': '1000000000000001', @@ -82,8 +105,12 @@ def _get_payload_with_params(schema_name, schema_url=None, **extra_payload): payload_vars['response_expires_at'] = ( datetime.now(tz=timezone.utc) + timedelta(days=7) ).isoformat() # 7 days from now in ISO 8601 format + for key, value in extra_payload.items(): - payload_vars['survey_metadata']['data'][key] = value + if key in TOP_LEVEL_METADATA_KEYS: + payload_vars[key] = value + else: + payload_vars['survey_metadata']['data'][key] = value return payload_vars From 041d45c7255de8d1678ac6c5c1223bb450bf7ad4 Mon Sep 17 00:00:00 2001 From: Liam Toozer Date: Thu, 25 Apr 2024 13:36:28 +0100 Subject: [PATCH 4/5] Add missing example field to survey_metadata --- runner_benchmark/token_generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runner_benchmark/token_generator.py b/runner_benchmark/token_generator.py index 2986bf68..aaccd30f 100644 --- a/runner_benchmark/token_generator.py +++ b/runner_benchmark/token_generator.py @@ -13,7 +13,6 @@ KEYS_FOLDER = './jwt-test-keys' -# "version" is excluded here as it is handled independently TOP_LEVEL_METADATA_KEYS = [ "exp", "jti", @@ -53,6 +52,7 @@ 'ru_name': 'Integration Testing', 'ru_ref': '123456789012A', 'trad_as': 'Benchmark Tests', + 'display_address': '68 Abingdon Road, Goathill', 'user_id': 'benchmark-user', 'survey_id': '0', 'employment_date': '2019-04-01', From c851356ea5d29779e3aa703149b24e52c2ce4199 Mon Sep 17 00:00:00 2001 From: Liam Toozer Date: Thu, 25 Apr 2024 14:08:59 +0100 Subject: [PATCH 5/5] Tweak ru_name --- runner_benchmark/token_generator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runner_benchmark/token_generator.py b/runner_benchmark/token_generator.py index aaccd30f..382a5b15 100644 --- a/runner_benchmark/token_generator.py +++ b/runner_benchmark/token_generator.py @@ -49,7 +49,7 @@ 'period_str': 'July 2019', 'ref_p_start_date': '2019-04-01', 'ref_p_end_date': '2019-11-30', - 'ru_name': 'Integration Testing', + 'ru_name': 'Benchmark Testing', 'ru_ref': '123456789012A', 'trad_as': 'Benchmark Tests', 'display_address': '68 Abingdon Road, Goathill',