@testcontainers/opensearch 11.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 - 2025 Cristian Greco
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Testcontainers
2
+
3
+ [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=116414510&machine=standardLinux32gb&devcontainer_path=.devcontainer%2Fdevcontainer.json&location=EastUs)
4
+
5
+ [![Test](https://github.com/testcontainers/testcontainers-node/actions/workflows/checks.yml/badge.svg?branch=main)](https://github.com/testcontainers/testcontainers-node/actions/workflows/checks.yml)
6
+ [![npm version](https://badge.fury.io/js/testcontainers.svg)](https://www.npmjs.com/package/testcontainers)
7
+ [![npm version](https://img.shields.io/npm/dm/testcontainers.svg)](https://www.npmjs.com/package/testcontainers)
8
+
9
+ ![Testcontainers Banner](https://github.com/testcontainers/testcontainers-node/raw/main/docs/site/logo.png)
10
+
11
+ ## [📖 Documentation](https://node.testcontainers.org/)
12
+
13
+ ## License
14
+
15
+ See [LICENSE](https://github.com/testcontainers/testcontainers-node/blob/main/LICENSE).
16
+
17
+ ## Copyright
18
+
19
+ Copyright (c) 2018 - 2025 Cristian Greco and other authors.
20
+
21
+ ## Contributing
22
+
23
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for how to contribute to this repo.
24
+
25
+ See [contributors](https://github.com/testcontainers/testcontainers-node/graphs/contributors/) for all contributors.
26
+
27
+ ---
28
+
29
+ Join our [Slack workspace](https://slack.testcontainers.org/) | [Testcontainers OSS](https://java.testcontainers.org/) | [Testcontainers Cloud](https://www.testcontainers.cloud/)
@@ -0,0 +1 @@
1
+ export { OpenSearchContainer, StartedOpenSearchContainer } from "./opensearch-container";
package/build/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StartedOpenSearchContainer = exports.OpenSearchContainer = void 0;
4
+ var opensearch_container_1 = require("./opensearch-container");
5
+ Object.defineProperty(exports, "OpenSearchContainer", { enumerable: true, get: function () { return opensearch_container_1.OpenSearchContainer; } });
6
+ Object.defineProperty(exports, "StartedOpenSearchContainer", { enumerable: true, get: function () { return opensearch_container_1.StartedOpenSearchContainer; } });
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,+DAAyF;AAAhF,2HAAA,mBAAmB,OAAA;AAAE,kIAAA,0BAA0B,OAAA"}
@@ -0,0 +1,36 @@
1
+ import { AbstractStartedContainer, GenericContainer, StartedTestContainer } from "testcontainers";
2
+ export declare class OpenSearchContainer extends GenericContainer {
3
+ private securityEnabled;
4
+ private password;
5
+ private readonly username;
6
+ private readonly defaultWaitStrategy;
7
+ constructor(image: string);
8
+ /**
9
+ * Toggle OpenSearch security plugin on/off.
10
+ */
11
+ withSecurityEnabled(enabled: boolean): this;
12
+ /**
13
+ * Override the 'admin' password.
14
+ * Enforces OpenSearch’s requirement of zxcvbn score ≥ 3
15
+ */
16
+ withPassword(password: string): this;
17
+ /**
18
+ * Start the container, injecting the initial-admin-password env var,
19
+ * then wrap in our typed StartedOpenSearchContainer.
20
+ */
21
+ start(): Promise<StartedOpenSearchContainer>;
22
+ }
23
+ export declare class StartedOpenSearchContainer extends AbstractStartedContainer {
24
+ readonly startedTestContainer: StartedTestContainer;
25
+ private readonly username;
26
+ private readonly password;
27
+ constructor(startedTestContainer: StartedTestContainer, username: string, password: string);
28
+ /** Mapped HTTP(S) port */
29
+ getPort(): number;
30
+ /** HTTPS endpoint URL */
31
+ getHttpUrl(): string;
32
+ /** Admin username (always 'admin' by default) */
33
+ getUsername(): string;
34
+ /** Admin password */
35
+ getPassword(): string;
36
+ }
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.StartedOpenSearchContainer = exports.OpenSearchContainer = void 0;
7
+ const testcontainers_1 = require("testcontainers");
8
+ const zxcvbn_1 = __importDefault(require("zxcvbn"));
9
+ const OPENSEARCH_HTTP_PORT = 9200;
10
+ const OPENSEARCH_TRANSPORT_PORT = 9300;
11
+ const OPENSEARCH_PERFORMANCE_ANALYZER_PORT = 9600;
12
+ class OpenSearchContainer extends testcontainers_1.GenericContainer {
13
+ // default to security on, with a strong demo password
14
+ securityEnabled = true;
15
+ password = "yourStrong(!)P@ssw0rd";
16
+ username = "admin";
17
+ // HTTPS + Basic Auth wait strategy
18
+ defaultWaitStrategy = testcontainers_1.Wait.forHttp("/", OPENSEARCH_HTTP_PORT)
19
+ .usingTls()
20
+ .allowInsecure()
21
+ .withBasicCredentials(this.username, this.password);
22
+ constructor(image) {
23
+ super(image);
24
+ this.withExposedPorts(OPENSEARCH_HTTP_PORT, OPENSEARCH_TRANSPORT_PORT, OPENSEARCH_PERFORMANCE_ANALYZER_PORT)
25
+ .withEnvironment({
26
+ "discovery.type": "single-node",
27
+ // disable security plugin if requested
28
+ "plugins.security.disabled": (!this.securityEnabled).toString(),
29
+ })
30
+ .withWaitStrategy(this.defaultWaitStrategy)
31
+ .withStartupTimeout(120_000);
32
+ }
33
+ /**
34
+ * Toggle OpenSearch security plugin on/off.
35
+ */
36
+ withSecurityEnabled(enabled) {
37
+ this.securityEnabled = enabled;
38
+ this.withEnvironment({
39
+ "plugins.security.disabled": (!enabled).toString(),
40
+ });
41
+ return this;
42
+ }
43
+ /**
44
+ * Override the 'admin' password.
45
+ * Enforces OpenSearch’s requirement of zxcvbn score ≥ 3
46
+ */
47
+ withPassword(password) {
48
+ const { score } = (0, zxcvbn_1.default)(password);
49
+ if (score < 3) {
50
+ throw new Error(`Password "${password}" is too weak (zxcvbn score ${score}). Must score ≥ 3 to meet OpenSearch security requirements.`);
51
+ }
52
+ this.password = password;
53
+ this.defaultWaitStrategy.withBasicCredentials(this.username, this.password);
54
+ return this;
55
+ }
56
+ /**
57
+ * Start the container, injecting the initial-admin-password env var,
58
+ * then wrap in our typed StartedOpenSearchContainer.
59
+ */
60
+ async start() {
61
+ this.withEnvironment({
62
+ OPENSEARCH_INITIAL_ADMIN_PASSWORD: this.password,
63
+ });
64
+ const started = await super.start();
65
+ return new StartedOpenSearchContainer(started, this.username, this.password);
66
+ }
67
+ }
68
+ exports.OpenSearchContainer = OpenSearchContainer;
69
+ class StartedOpenSearchContainer extends testcontainers_1.AbstractStartedContainer {
70
+ startedTestContainer;
71
+ username;
72
+ password;
73
+ constructor(startedTestContainer, username, password) {
74
+ super(startedTestContainer);
75
+ this.startedTestContainer = startedTestContainer;
76
+ this.username = username;
77
+ this.password = password;
78
+ }
79
+ /** Mapped HTTP(S) port */
80
+ getPort() {
81
+ return this.getMappedPort(OPENSEARCH_HTTP_PORT);
82
+ }
83
+ /** HTTPS endpoint URL */
84
+ getHttpUrl() {
85
+ return `https://${this.getHost()}:${this.getPort()}`;
86
+ }
87
+ /** Admin username (always 'admin' by default) */
88
+ getUsername() {
89
+ return this.username;
90
+ }
91
+ /** Admin password */
92
+ getPassword() {
93
+ return this.password;
94
+ }
95
+ }
96
+ exports.StartedOpenSearchContainer = StartedOpenSearchContainer;
97
+ //# sourceMappingURL=opensearch-container.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opensearch-container.js","sourceRoot":"","sources":["../src/opensearch-container.ts"],"names":[],"mappings":";;;;;;AAAA,mDAAwG;AACxG,oDAA4B;AAE5B,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAClC,MAAM,yBAAyB,GAAG,IAAI,CAAC;AACvC,MAAM,oCAAoC,GAAG,IAAI,CAAC;AAElD,MAAa,mBAAoB,SAAQ,iCAAgB;IACvD,sDAAsD;IAC9C,eAAe,GAAG,IAAI,CAAC;IACvB,QAAQ,GAAG,uBAAuB,CAAC;IAC1B,QAAQ,GAAG,OAAO,CAAC;IAEpC,mCAAmC;IAClB,mBAAmB,GAAG,qBAAI,CAAC,OAAO,CAAC,GAAG,EAAE,oBAAoB,CAAC;SAC3E,QAAQ,EAAE;SACV,aAAa,EAAE;SACf,oBAAoB,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAEtD,YAAY,KAAa;QACvB,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,IAAI,CAAC,gBAAgB,CAAC,oBAAoB,EAAE,yBAAyB,EAAE,oCAAoC,CAAC;aACzG,eAAe,CAAC;YACf,gBAAgB,EAAE,aAAa;YAC/B,uCAAuC;YACvC,2BAA2B,EAAE,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,QAAQ,EAAE;SAChE,CAAC;aACD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CAAsB;QAC3C,aAAQ,GAAR,QAAQ,CAAQ;QAChB,aAAQ,GAAR,QAAQ,CAAQ;IAGnC,CAAC;IAED,0BAA0B;IACnB,OAAO;QACZ,OAAO,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,CAAC;IAClD,CAAC;IAED,yBAAyB;IAClB,UAAU;QACf,OAAO,WAAW,IAAI,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;IACvD,CAAC;IAED,iDAAiD;IAC1C,WAAW;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,qBAAqB;IACd,WAAW;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AA5BD,gEA4BC"}
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@testcontainers/opensearch",
3
+ "version": "11.3.0",
4
+ "license": "MIT",
5
+ "keywords": [
6
+ "opensearch",
7
+ "testing",
8
+ "docker",
9
+ "testcontainers"
10
+ ],
11
+ "description": "OpenSearch module for Testcontainers",
12
+ "homepage": "https://github.com/testcontainers/testcontainers-node#readme",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/testcontainers/testcontainers-node.git"
16
+ },
17
+ "bugs": {
18
+ "url": "https://github.com/testcontainers/testcontainers-node/issues"
19
+ },
20
+ "main": "build/index.js",
21
+ "files": [
22
+ "build"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "scripts": {
28
+ "prepack": "shx cp ../../../README.md . && shx cp ../../../LICENSE .",
29
+ "build": "tsc --project tsconfig.build.json"
30
+ },
31
+ "devDependencies": {
32
+ "@opensearch-project/opensearch": "^3.5.1",
33
+ "@types/zxcvbn": "^4.4.5"
34
+ },
35
+ "dependencies": {
36
+ "testcontainers": "^11.3.0",
37
+ "zxcvbn": "^4.4.2"
38
+ }
39
+ }