From b50eb79ce746b4adf5988b99abdc50d875e82035 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Thu, 8 Aug 2024 16:56:22 -0400 Subject: [PATCH 1/6] Run tests against stable OpenSearch 2.16. (#484) Signed-off-by: dblock --- .github/workflows/test-spec.yml | 12 ++++++------ .github/workflows/test-tools-integ.yml | 2 +- spec/_info.yaml | 2 +- tools/tests/tester/fixtures/evals/passed.yaml | 2 +- .../tests/tester/fixtures/evals/skipped/semver.yaml | 2 +- tools/tests/tester/helpers.ts | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test-spec.yml b/.github/workflows/test-spec.yml index 3fa404483..b0014a322 100644 --- a/.github/workflows/test-spec.yml +++ b/.github/workflows/test-spec.yml @@ -27,17 +27,17 @@ jobs: admin_password: admin - version: 2.0.0 admin_password: admin - - version: 2.15.0 - - version: 2.15.0 + - version: 2.16.0 + - version: 2.16.0 tests: plugins/index_state_management - - version: 2.15.0 - tests: snapshot - version: 2.16.0 + tests: snapshot + - version: 2.17.0 hub: opensearchstaging - ref: '@sha256:bcd7f5d5d30231f24f266064248cc8d3306574948190f7bf93016dff29acf17e' + ref: '@sha256:6398c27d7560626ed6b0ba28b3d6b20b7f00c6d94abf45ad3a820f8eeb3d61a3' - version: 3.0.0 hub: opensearchstaging - ref: '@sha256:db1918b2b8f7ef6c22dd6ff54a0640877c3d395a392a53864745024933981e3b' + ref: '@sha256:101681eea630393f8caf5987dd023a975a9656b63090a07bfdfe6ad2f73f0640' name: test-opensearch-spec (version=${{ matrix.entry.version }}, hub=${{ matrix.entry.hub || 'opensearchproject' }}, tests=${{ matrix.entry.tests || 'default' }}) runs-on: ubuntu-latest diff --git a/.github/workflows/test-tools-integ.yml b/.github/workflows/test-tools-integ.yml index 660a55e7e..5bb9ac5d8 100644 --- a/.github/workflows/test-tools-integ.yml +++ b/.github/workflows/test-tools-integ.yml @@ -24,7 +24,7 @@ jobs: test: runs-on: ubuntu-latest env: - OPENSEARCH_VERSION: 2.15.0 + OPENSEARCH_VERSION: 2.16.0 OPENSEARCH_PASSWORD: myStrongPassword123! OPENSEARCH_URL: https://localhost:9200 steps: diff --git a/spec/_info.yaml b/spec/_info.yaml index 2454ecb55..d8d63d088 100644 --- a/spec/_info.yaml +++ b/spec/_info.yaml @@ -2,4 +2,4 @@ $schema: ./json_schemas/_info.schema.yaml title: OpenSearch API Specification version: 1.0.0 -x-api-version: 2.15.0 +x-api-version: 2.16.0 diff --git a/tools/tests/tester/fixtures/evals/passed.yaml b/tools/tests/tester/fixtures/evals/passed.yaml index bb74087e8..12c1b2c32 100644 --- a/tools/tests/tester/fixtures/evals/passed.yaml +++ b/tools/tests/tester/fixtures/evals/passed.yaml @@ -175,7 +175,7 @@ chapters: - title: This GET /_cat/health should be skipped (> 2.999.0). overall: result: SKIPPED - message: Skipped because version 2.15.0 does not satisfy >= 2.999.0. + message: Skipped because version 2.16.0 does not satisfy >= 2.999.0. epilogues: - title: DELETE /books overall: diff --git a/tools/tests/tester/fixtures/evals/skipped/semver.yaml b/tools/tests/tester/fixtures/evals/skipped/semver.yaml index b39460dcb..30709742d 100644 --- a/tools/tests/tester/fixtures/evals/skipped/semver.yaml +++ b/tools/tests/tester/fixtures/evals/skipped/semver.yaml @@ -3,5 +3,5 @@ full_path: tools/tests/tester/fixtures/stories/skipped/semver.yaml result: SKIPPED description: This story should be skipped because of version. -message: Skipped because version 2.15.0 does not satisfy >= 2.999.0. +message: Skipped because version 2.16.0 does not satisfy >= 2.999.0. diff --git a/tools/tests/tester/helpers.ts b/tools/tests/tester/helpers.ts index 9e4cf2d46..ce11b6ad8 100644 --- a/tools/tests/tester/helpers.ts +++ b/tools/tests/tester/helpers.ts @@ -141,5 +141,5 @@ export async function load_actual_evaluation (evaluator: StoryEvaluator, name: s full_path, display_path: `${name}.yaml`, story: read_yaml(full_path) - }, process.env.OPENSEARCH_VERSION ?? '2.15.0')) + }, process.env.OPENSEARCH_VERSION ?? '2.16.0')) } From 6cdd8b7e86e2a2a08c07929f049d3ed17231b646 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Thu, 8 Aug 2024 17:04:32 -0400 Subject: [PATCH 2/6] Fix: durations are not always integers. (#479) Signed-off-by: dblock --- CHANGELOG.md | 3 ++- spec/schemas/_common.yaml | 2 +- tools/tests/tester/fixtures/specs/excerpt.yaml | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5590437d..a0ecf4f75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -107,7 +107,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Fixed `/_mapping` with `index` in query ([#385](https://github.com/opensearch-project/opensearch-api-specification/pull/385)) - Fixed duplicate `/_nodes/{node_id}` path ([#416](https://github.com/opensearch-project/opensearch-api-specification/pull/416)) - Fixed `_source` accepting an array of fields in `/_search` ([#430](https://github.com/opensearch-project/opensearch-api-specification/pull/430)) -- Fixed `_update_by_query` with a simple term ([451](https://github.com/opensearch-project/opensearch-api-specification/pull/451)) +- Fixed `_update_by_query` with a simple term ([#451](https://github.com/opensearch-project/opensearch-api-specification/pull/451)) +- Fixed `Duration` to allow for non-integers ([#479](https://github.com/opensearch-project/opensearch-api-specification/pull/479)) ### Security diff --git a/spec/schemas/_common.yaml b/spec/schemas/_common.yaml index 1c20ad16b..5b645eed4 100644 --- a/spec/schemas/_common.yaml +++ b/spec/schemas/_common.yaml @@ -38,7 +38,7 @@ components: description: |- A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value. - pattern: ^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$ + pattern: ^([0-9\.]+)(?:d|h|m|s|ms|micros|nanos)$ type: string Metadata: type: object diff --git a/tools/tests/tester/fixtures/specs/excerpt.yaml b/tools/tests/tester/fixtures/specs/excerpt.yaml index 64ad01d39..244e7e466 100644 --- a/tools/tests/tester/fixtures/specs/excerpt.yaml +++ b/tools/tests/tester/fixtures/specs/excerpt.yaml @@ -286,5 +286,5 @@ components: description: |- A duration. Units can be `nanos`, `micros`, `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours) and `d` (days). Also accepts "0" without a unit and "-1" to indicate an unspecified value. - pattern: ^([0-9]+)(?:d|h|m|s|ms|micros|nanos)$ + pattern: ^([0-9\.]+)(?:d|h|m|s|ms|micros|nanos)$ type: string \ No newline at end of file From ecf39215e18d9edeba1d048b2ba22a172844ae6c Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Thu, 8 Aug 2024 17:06:34 -0400 Subject: [PATCH 3/6] Fix: refresh index to get a consistent total. (#480) Signed-off-by: dblock --- tests/default/_core/reindex.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/default/_core/reindex.yaml b/tests/default/_core/reindex.yaml index 86d4fccb4..71567b7a9 100644 --- a/tests/default/_core/reindex.yaml +++ b/tests/default/_core/reindex.yaml @@ -39,6 +39,8 @@ chapters: - synopsis: Reindex a subset of documents (match). path: /_reindex method: POST + parameters: + refresh: true request: payload: source: @@ -82,7 +84,7 @@ chapters: response: status: 200 payload: - total: 1 + total: 2 - synopsis: Reindex only unique documents. path: /_reindex method: POST From d7e6971222d70f0219a01ba2ebb4941092d680de Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Sun, 11 Aug 2024 18:17:59 -0400 Subject: [PATCH 4/6] Double the RAM in the test container. (#486) Signed-off-by: dblock --- .github/workflows/test-spec.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-spec.yml b/.github/workflows/test-spec.yml index b0014a322..72a8d7601 100644 --- a/.github/workflows/test-spec.yml +++ b/.github/workflows/test-spec.yml @@ -47,7 +47,7 @@ jobs: OPENSEARCH_DOCKER_REF: ${{ matrix.entry.ref }} OPENSEARCH_VERSION: ${{ matrix.entry.version }} OPENSEARCH_PASSWORD: ${{ matrix.entry.admin_password || 'myStrongPassword123!' }} - OPENSEARCH_JAVA_OPTS: ${{ matrix.entry.opts }} -Xms2g -Xmx2g + OPENSEARCH_JAVA_OPTS: ${{ matrix.entry.opts }} -Xms8g -Xmx8g steps: - name: Checkout Repo From 56a5a224562d465f77c6e1712a266d1d11ba8a5c Mon Sep 17 00:00:00 2001 From: Andy Wick Date: Sun, 11 Aug 2024 18:42:31 -0400 Subject: [PATCH 5/6] Document fielddata.yaml fail, ignore vim swp files (#473) * Document fielddata.yaml fail, ignore vim swp files * Ignore test files that start with . so vim swp files are ignored * fielddata.yaml test files if opensearch cluster was stopped with docker kill instead of docker stop, document the issue * upgrade remaining actions/checkout@v3 to v4 to stop warnings Signed-off-by: Andy Wick * fixed FAILED placment Signed-off-by: Andy Wick * switch to only processing .yaml files Signed-off-by: Andy Wick * Remove EXCLUDED_FILES instead only process .yaml Signed-off-by: Andy Wick --------- Signed-off-by: Andy Wick --- .github/workflows/changelog.yml | 2 +- .github/workflows/test-spec.yml | 2 +- TESTING_GUIDE.md | 4 ++++ tools/src/tester/TestRunner.ts | 11 ++++------- .../tester/fixtures/stories/ignore.wrong.extension | 1 + 5 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 tools/tests/tester/fixtures/stories/ignore.wrong.extension diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 23a1e0502..c6994060d 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -7,7 +7,7 @@ jobs: verify-changelog: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: token: ${{ secrets.GITHUB_TOKEN }} ref: ${{ github.event.pull_request.head.sha }} diff --git a/.github/workflows/test-spec.yml b/.github/workflows/test-spec.yml index 72a8d7601..d9ed81aea 100644 --- a/.github/workflows/test-spec.yml +++ b/.github/workflows/test-spec.yml @@ -95,7 +95,7 @@ jobs: if: github.event_name == 'pull_request' needs: test-opensearch-spec steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Download Spec Coverage Data uses: actions/download-artifact@v4 diff --git a/TESTING_GUIDE.md b/TESTING_GUIDE.md index 5c066549e..61f6c2828 100644 --- a/TESTING_GUIDE.md +++ b/TESTING_GUIDE.md @@ -6,6 +6,7 @@ - [Common Errors](#common-errors) - [401 Unauthorized](#401-unauthorized) - [FORBIDDEN/10/cluster create-index blocked (api)](#forbidden10cluster-create-index-blocked-api) + - [FAILED Cat with a json response (from security-analytics).](#failed--cat-with-a-json-response-from-security-analytics) - [Writing Spec Tests](#writing-spec-tests) - [Simple Test Story](#simple-test-story) - [Using Output from Previous Chapters](#using-output-from-previous-chapters) @@ -85,6 +86,9 @@ curl -k -X PUT --user "admin:${OPENSEARCH_PASSWORD}" https://localhost:9200/_clu ' ``` +#### FAILED Cat with a json response (from security-analytics). +The cluster is not loading plugins correctly, maybe it was stopped using `docker kill` instead of `docker stop`. Recreating the cluster should fix the issue: `docker compose up --force-recreate -d`. + ## Writing Spec Tests The spec tests reside in the [tests/](tests) directory. Tests are organized in suites ([default](tests/default/), etc.), and subsequently in folders that match [namespaces](spec/namespaces). For example, tests for APIs defined in [spec/namespaces/indices.yaml](spec/namespaces/indices.yaml) can be found in [tests/default/indices/index.yaml](tests/default/indices/index.yaml) (for `/{index}`), and [tests/default/indices/doc.yaml](tests/default/indices/doc.yaml) (for `/{index}/_doc`). diff --git a/tools/src/tester/TestRunner.ts b/tools/src/tester/TestRunner.ts index fdde53791..0c0f3c4ff 100644 --- a/tools/src/tester/TestRunner.ts +++ b/tools/src/tester/TestRunner.ts @@ -20,10 +20,6 @@ import { OpenSearchHttpClient } from 'OpenSearchHttpClient' import * as ansi from './Ansi' import _ from 'lodash' -const EXCLUDED_FILES = [ - 'docker-compose.yml' -] - export default class TestRunner { private readonly _http_client: OpenSearchHttpClient private readonly _story_validator: StoryValidator @@ -69,6 +65,9 @@ export default class TestRunner { const path = file === '' ? folder : `${folder}/${file}` const next_prefix = prefix === '' ? file : `${prefix}/${file}` if (fs.statSync(path).isFile()) { + if (!path.endsWith('.yaml')) { + return [] + } const story: Story = read_yaml(path) return [{ display_path: next_prefix === '' ? basename(path) : next_prefix, @@ -77,9 +76,7 @@ export default class TestRunner { }] } else { return _.compact(fs.readdirSync(path).flatMap(next_file => { - if (!EXCLUDED_FILES.includes(next_file)) { - return this.#collect_story_files(path, next_file, next_prefix) - } + return this.#collect_story_files(path, next_file, next_prefix) })) } } diff --git a/tools/tests/tester/fixtures/stories/ignore.wrong.extension b/tools/tests/tester/fixtures/stories/ignore.wrong.extension new file mode 100644 index 000000000..a649676ae --- /dev/null +++ b/tools/tests/tester/fixtures/stories/ignore.wrong.extension @@ -0,0 +1 @@ +Not a .yaml file, should be ignored From 00711ea55e7317840a6617bae872997ca4a14e63 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Sun, 11 Aug 2024 19:20:56 -0400 Subject: [PATCH 6/6] Allow overwriting the Authorization header. (#488) Signed-off-by: dblock --- package-lock.json | 49 +++++++++++++++ package.json | 1 + tools/src/OpenSearchHttpClient.ts | 20 +++--- .../tests/tester/OpenSearchHttpClient.test.ts | 62 +++++++++++-------- 4 files changed, 98 insertions(+), 34 deletions(-) diff --git a/package-lock.json b/package-lock.json index e1156510e..00b73c87a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,6 +28,7 @@ "ajv-formats": "^3.0.1", "aws4-axios": "^3.3.7", "axios": "^1.7.1", + "axios-mock-adapter": "^2.0.0", "cbor": "^9.0.2", "commander": "^12.0.0", "eslint": "^8.57.0", @@ -3935,6 +3936,18 @@ "proxy-from-env": "^1.1.0" } }, + "node_modules/axios-mock-adapter": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/axios-mock-adapter/-/axios-mock-adapter-2.0.0.tgz", + "integrity": "sha512-D/K0J5Zm6KvaMTnsWrBQZWLzKN9GxUFZEa0mx2qeEHXDeTugCoplWehy8y36dj5vuSjhe1u/Dol8cZ8lzzmDew==", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "is-buffer": "^2.0.5" + }, + "peerDependencies": { + "axios": ">= 0.17.0" + } + }, "node_modules/babel-jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz", @@ -6423,6 +6436,28 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-buffer": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz", + "integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "engines": { + "node": ">=4" + } + }, "node_modules/is-builtin-module": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.1.tgz", @@ -12467,6 +12502,15 @@ "proxy-from-env": "^1.1.0" } }, + "axios-mock-adapter": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/axios-mock-adapter/-/axios-mock-adapter-2.0.0.tgz", + "integrity": "sha512-D/K0J5Zm6KvaMTnsWrBQZWLzKN9GxUFZEa0mx2qeEHXDeTugCoplWehy8y36dj5vuSjhe1u/Dol8cZ8lzzmDew==", + "requires": { + "fast-deep-equal": "^3.1.3", + "is-buffer": "^2.0.5" + } + }, "babel-jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz", @@ -14192,6 +14236,11 @@ "has-tostringtag": "^1.0.0" } }, + "is-buffer": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz", + "integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==" + }, "is-builtin-module": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.1.tgz", diff --git a/package.json b/package.json index 22d798e13..5ffe41341 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "@types/titlecase": "^1.1.2", "@types/tmp": "^0.2.6", "@typescript-eslint/eslint-plugin": "^6.21.0", + "axios-mock-adapter": "^2.0.0", "ajv": "^8.13.0", "ajv-errors": "^3.0.0", "ajv-formats": "^3.0.1", diff --git a/tools/src/OpenSearchHttpClient.ts b/tools/src/OpenSearchHttpClient.ts index f81656074..afbb7d5fa 100644 --- a/tools/src/OpenSearchHttpClient.ts +++ b/tools/src/OpenSearchHttpClient.ts @@ -133,18 +133,23 @@ export class OpenSearchHttpClient { this._opts = opts this._logger = opts?.logger ?? new Logger() - let auth = undefined - let sigv4_interceptor = undefined + let auth_middleware = undefined if (opts?.basic_auth !== undefined) { this._logger.info(`Authenticating with ${opts.basic_auth.username} ...`) - auth = opts.basic_auth + auth_middleware = ((request: any): any => { + if (request.headers.Authorization === undefined) { + const base64 = Buffer.from(`${opts.basic_auth?.username}:${opts.basic_auth?.password}`, 'utf8').toString('base64'); + request.headers.Authorization = `Basic ${base64}` + } + return request + }) } else if (opts?.aws_auth !== undefined) { this._logger.info(`Authenticating using SigV4 with ${opts.aws_auth.aws_access_key_id} (${opts.aws_auth.aws_region}) ...`) - sigv4_interceptor = aws4Interceptor({ + auth_middleware = aws4Interceptor({ options: { region: opts.aws_auth.aws_region, - service: 'es' + service: opts.aws_auth.aws_service }, credentials: { accessKeyId: opts.aws_auth.aws_access_key_id, @@ -158,13 +163,12 @@ export class OpenSearchHttpClient { this._axios = axios.create({ baseURL: opts?.url ?? DEFAULT_URL, - auth, httpsAgent: new https.Agent({ rejectUnauthorized: !(opts?.insecure ?? DEFAULT_INSECURE) }), responseType: opts?.responseType, }) - if (sigv4_interceptor !== undefined) { - this._axios.interceptors.request.use(sigv4_interceptor) + if (auth_middleware !== undefined) { + this._axios.interceptors.request.use(auth_middleware) } } diff --git a/tools/tests/tester/OpenSearchHttpClient.test.ts b/tools/tests/tester/OpenSearchHttpClient.test.ts index e2687e7fd..85c62af05 100644 --- a/tools/tests/tester/OpenSearchHttpClient.test.ts +++ b/tools/tests/tester/OpenSearchHttpClient.test.ts @@ -9,58 +9,68 @@ import axios from "axios"; import { OpenSearchHttpClient } from "OpenSearchHttpClient" - -jest.mock('axios') +import AxiosMockAdapter from "axios-mock-adapter"; describe('OpenSearchHttpClient', () => { - let mocked_axios: jest.Mocked = axios as jest.Mocked + var mock = new AxiosMockAdapter(axios) - beforeEach(() => { - mocked_axios.create.mockReturnThis() - mocked_axios.interceptors.request.use = jest.fn().mockReturnValue({ headers: {} }) + afterEach(() => { + mock.reset() }) - afterEach(() => { - jest.clearAllMocks() + it('adds a Basic auth header', async () => { + let client = new OpenSearchHttpClient({ + url: 'https://localhost:9200', + basic_auth: { + username: 'u', + password: 'p' + } + }) + + mock.onAny().reply((config) => { + expect(config.headers?.Authorization).toMatch(/^Basic /) + return [200, { called: true }] + }) + + expect((await client.get('/')).data).toEqual({ called: true }) }) - it('uses password authentication', () => { - new OpenSearchHttpClient({ + it('allows to overwrite Authorization', async () => { + let client = new OpenSearchHttpClient({ url: 'https://localhost:9200', basic_auth: { - username: 'admin', - password: 'password' + username: 'u', + password: 'p' } }) - expect(mocked_axios.create.mock.calls[0][0]).toMatchObject({ - auth: { - username: 'admin', - password: 'password' - }, - baseURL: 'https://localhost:9200' + mock.onAny().reply((config) => { + expect(config.headers?.Authorization).toEqual('custom') + return [200, { called: true }] }) - expect(mocked_axios.interceptors.request.use).not.toHaveBeenCalled() + expect((await client.get('/', { headers: { Authorization: 'custom' } })).data).toEqual({ called: true }) }) - it('assigns a request interceptor with SigV4 authentication', () => { - new OpenSearchHttpClient({ + it('adds a Sigv4 header', async () => { + let client = new OpenSearchHttpClient({ url: 'https://localhost:9200', aws_auth: { aws_access_key_id: 'key id', aws_access_secret_key: 'secret key', aws_access_session_token: 'session token', - aws_region: 'us-west-2', + aws_region: 'us-west-42', aws_service: 'aoss' } }) - expect(mocked_axios.create.mock.calls[0][0]).toMatchObject({ - auth: undefined, - baseURL: 'https://localhost:9200' + mock.onAny().reply((config) => { + expect(config.headers?.Authorization).toMatch( + /^AWS4-HMAC-SHA256 Credential=key id\/\d*\/us-west-42\/aoss\/aws4_request/ + ) + return [200, { called: true }] }) - expect(mocked_axios.interceptors.request.use).toHaveBeenCalled() + expect((await client.get('/')).data).toEqual({ called: true }) }) })