diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/README.md b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/README.md index 66159b817..ca72584d8 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/README.md +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/README.md @@ -10,6 +10,7 @@ - [Metadata Migration](#metadata-migration) - [Replay](#replay) - [Kafka](#kafka) + - [Client Options](#client-options) - [Usage](#usage) - [Library](#library) - [CLI](#cli) @@ -82,6 +83,8 @@ metadata_migration: kafka: broker_endpoints: "kafka:9092" standard: +client_options: + user_agent_extra: "test-user-agent-v1.0" ``` ## Services.yaml spec @@ -225,13 +228,19 @@ Exactly one of the following blocks must be present: A Kafka cluster is used in the capture and replay stage of the migration to store recorded requests and responses before they're replayed. While it's not necessary for a user to directly interact with the Kafka cluster in most cases, there are a handful of commands that can be helpful for checking on the status or resetting state that are exposed by the Console CLI. -- `broker_endpoints`: required, comma-separated list of kafaka broker endpoints +- `broker_endpoints`: required, comma-separated list of kafka broker endpoints Exactly one of the following keys must be present, but both are nullable (they don't have or need any additional parameters). - `msk`: the Kafka instance is deployed as AWS Managed Service Kafka - `standard`: the Kafka instance is deployed as a standard Kafka cluster (e.g. on Docker) +### Client Options + +Client options are global settings that are applied to different clients used throughout this library + +- `user_agent_extra`: optional, a user agent string that will be appended to the `User-Agent` header of all requests from this library + ## Usage ### Library diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/osi_utils.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/osi_utils.py index dd2e21843..bb9f5cdcc 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/osi_utils.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/console_link/models/osi_utils.py @@ -285,7 +285,7 @@ def create_pipeline_from_env(osi_client, # Target endpoints for OSI are not currently allowed a port target_endpoint_clean = sanitize_endpoint(target_cluster.endpoint, True) source_auth_secret = None - if source_cluster.auth_details and source_cluster.auth_details["password_from_secret_arn"]: + if source_cluster.auth_details and "password_from_secret_arn" in source_cluster.auth_details: source_auth_secret = source_cluster.auth_details["password_from_secret_arn"] pipeline_config_string = construct_pipeline_config(pipeline_config_file_path=pipeline_template_path, source_endpoint=source_endpoint_clean, diff --git a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_utils.py b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_utils.py index 40102d8dc..0771b9f5c 100644 --- a/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_utils.py +++ b/TrafficCapture/dockerSolution/src/main/docker/migrationConsole/lib/console_link/tests/test_utils.py @@ -1,4 +1,4 @@ -from console_link.models.utils import append_user_agent_header_for_requests, create_boto3_client +from console_link.models.utils import append_user_agent_header_for_requests import requests.utils USER_AGENT_EXTRA = "test-user-agent-v1.0" @@ -9,6 +9,7 @@ def test_append_user_agent_header_for_requests_no_headers(): result_headers = append_user_agent_header_for_requests(headers=None, user_agent_extra=USER_AGENT_EXTRA) assert result_headers == expected_headers + def test_append_user_agent_header_for_requests_existing_headers(): existing_headers = {"Accept": "/*", "Host": "macosx"} expected_headers = dict(existing_headers) @@ -16,6 +17,7 @@ def test_append_user_agent_header_for_requests_existing_headers(): result_headers = append_user_agent_header_for_requests(headers=existing_headers, user_agent_extra=USER_AGENT_EXTRA) assert result_headers == expected_headers + def test_append_user_agent_header_for_requests_existing_headers_with_user_agent(): existing_headers = {"Accept": "/*", "Host": "macosx", "User-Agent": "pyclient"} expected_headers = dict(existing_headers) diff --git a/deployment/cdk/opensearch-service-migration/test/createApp.test.ts b/deployment/cdk/opensearch-service-migration/test/createApp.test.ts index 9d8906f71..e0271643c 100644 --- a/deployment/cdk/opensearch-service-migration/test/createApp.test.ts +++ b/deployment/cdk/opensearch-service-migration/test/createApp.test.ts @@ -39,7 +39,7 @@ describe('createApp', () => { process.env.CDK_DEFAULT_ACCOUNT = 'test-account'; process.env.CDK_DEFAULT_REGION = 'test-region'; process.env.MIGRATIONS_APP_REGISTRY_ARN = 'test-arn'; - process.env.CUSTOM_REPLAYER_USER_AGENT = 'test-user-agent'; + process.env.MIGRATIONS_USER_AGENT = 'test-user-agent'; const consoleSpy = jest.spyOn(console, 'info').mockImplementation(); const mockAddTag = jest.fn(); @@ -58,7 +58,7 @@ describe('createApp', () => { expect.any(Object), { migrationsAppRegistryARN: 'test-arn', - customReplayerUserAgent: 'test-user-agent', + migrationsUserAgent: 'test-user-agent', migrationsSolutionVersion: '1.0.0', env: { account: 'test-account', region: 'test-region' }, } @@ -74,4 +74,4 @@ describe('createApp', () => { consoleSpy.mockRestore(); }); -}); \ No newline at end of file +});