-
-
Notifications
You must be signed in to change notification settings - Fork 251
Allow initialising nats server with no credentials set #1077
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
george-of-croton
wants to merge
6
commits into
testcontainers:main
from
george-of-croton:allow-no-credentials-nats
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c3cd667
Update nats-container.ts
george-of-croton cf96b47
allow no credentials in nats module
george-of-croton 476b4ab
remove object assign and lint
george-of-croton 4542bbd
add docs
george-of-croton 109fc79
style fix
george-of-croton 8570b79
refactor: update connection options assertions in NatsContainer tests
george-of-croton File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -10,6 +10,7 @@ const PASS_ARGUMENT_KEY = "--pass"; | |||||||||
| export class NatsContainer extends GenericContainer { | ||||||||||
| private args = new Set<string>(); | ||||||||||
| private values = new Map<string, string | undefined>(); | ||||||||||
| private useCredentials = true; | ||||||||||
|
|
||||||||||
| constructor(image: string) { | ||||||||||
| super(image); | ||||||||||
|
|
@@ -42,6 +43,18 @@ export class NatsContainer extends GenericContainer { | |||||||||
| return this; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| public withCredentials(useCredentials: boolean): this { | ||||||||||
| this.useCredentials = useCredentials; | ||||||||||
| if (!useCredentials) { | ||||||||||
| this.args.delete(USER_ARGUMENT_KEY); | ||||||||||
| this.args.delete(PASS_ARGUMENT_KEY); | ||||||||||
| } else { | ||||||||||
| this.withUsername("test"); | ||||||||||
| this.withPass("test"); | ||||||||||
cristianrgreco marked this conversation as resolved.
Show resolved
Hide resolved
cristianrgreco marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||
| } | ||||||||||
| return this; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| public withArg(name: string, value: string): this; | ||||||||||
| public withArg(name: string): this; | ||||||||||
| public withArg(...args: [string, string] | [string]): this { | ||||||||||
|
|
@@ -69,7 +82,11 @@ export class NatsContainer extends GenericContainer { | |||||||||
|
|
||||||||||
| public override async start(): Promise<StartedNatsContainer> { | ||||||||||
| this.withCommand(this.getNormalizedCommand()); | ||||||||||
| return new StartedNatsContainer(await super.start(), this.getUser(), this.getPass()); | ||||||||||
| return new StartedNatsContainer( | ||||||||||
| await super.start(), | ||||||||||
| (this.useCredentials && this.getUser()) || undefined, | ||||||||||
| (this.useCredentials && this.getPass()) || undefined | ||||||||||
cristianrgreco marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+87
to
+88
|
||||||||||
| (this.useCredentials && this.getUser()) || undefined, | |
| (this.useCredentials && this.getPass()) || undefined | |
| this.useCredentials ? this.getUser() : undefined, | |
| this.useCredentials ? this.getPass() : undefined |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@george-of-croton Need to handle this scenario: