-
Notifications
You must be signed in to change notification settings - Fork 45
💥 Enable TLS if api key specified #567
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
0c8ebc7
6b8fe7c
30b8aa3
706389c
a713465
c982d45
7db5704
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hrmm, these tests may be bit too detailed/low-level. You are testing internals and only relying on us making internals visible to this test project. Note we don't have any other tests confirming the bridge options conversions. Usually we test user-facing behavior. How would a user write a test to confirm their setting of TLS disabled or API key or whatever does the right thing? Granted it's probably not very easy to do this. One approach that you may take is to alter the "Test cloud" CI test to use API key instead of mTLS to at least confirm the API key default. Regardless, not a big deal if you keep these, just a bit strange for this repo (and why there never was anything like this in the past).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably going to keep them. Changed the cloud CI workflow to use api key secret and remove the mTLS secrets |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| namespace Temporalio.Tests.Client; | ||
|
|
||
| using Temporalio.Bridge; | ||
| using Temporalio.Client; | ||
| using Xunit; | ||
|
|
||
| public unsafe class TemporalConnectionOptionsTests | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add tests for when:
|
||
| { | ||
| [Fact] | ||
| public void ToInteropOptions_AutoEnablesTls_WhenApiKeyProvidedAndTlsNotSet() | ||
| { | ||
| var options = new TemporalConnectionOptions("localhost:7233") | ||
| { | ||
| ApiKey = "test-api-key", | ||
| Identity = "test-identity", | ||
| }; | ||
|
|
||
| using var scope = new Scope(); | ||
| var interopOptions = options.ToInteropOptions(scope); | ||
|
|
||
| // TLS should be auto-enabled when API key is provided and TLS not explicitly set | ||
| Assert.NotNull(interopOptions.tls_options); | ||
|
Check failure on line 22 in tests/Temporalio.Tests/Client/TemporalConnectionOptionsTests.cs
|
||
| } | ||
|
|
||
| [Fact] | ||
| public void ToInteropOptions_RespectsExplicitTlsNull_WhenApiKeyProvided() | ||
| { | ||
| var options = new TemporalConnectionOptions("localhost:7233") | ||
| { | ||
| ApiKey = "test-api-key", | ||
| Identity = "test-identity", | ||
| Tls = null, // Explicitly disable TLS | ||
| }; | ||
|
|
||
| using var scope = new Scope(); | ||
| var interopOptions = options.ToInteropOptions(scope); | ||
|
|
||
| // TLS should remain disabled when explicitly set to null | ||
| Assert.Null(interopOptions.tls_options); | ||
|
Check failure on line 39 in tests/Temporalio.Tests/Client/TemporalConnectionOptionsTests.cs
|
||
| } | ||
|
|
||
| [Fact] | ||
| public void ToInteropOptions_TlsDisabled_WhenNoApiKeyAndTlsNotSet() | ||
| { | ||
| var options = new TemporalConnectionOptions("localhost:7233"); | ||
|
|
||
| using var scope = new Scope(); | ||
| var interopOptions = options.ToInteropOptions(scope); | ||
|
|
||
| // TLS should be disabled when no API key and TLS not set | ||
| Assert.Null(interopOptions.tls_options); | ||
|
Check failure on line 51 in tests/Temporalio.Tests/Client/TemporalConnectionOptionsTests.cs
|
||
| } | ||
|
|
||
| [Fact] | ||
| public void ToInteropOptions_TlsEnabled_WhenExplicitlySet() | ||
| { | ||
| var options = new TemporalConnectionOptions("localhost:7233") | ||
| { | ||
| Identity = "test-identity", | ||
| Tls = new TlsOptions(), | ||
| }; | ||
|
|
||
| using var scope = new Scope(); | ||
| var interopOptions = options.ToInteropOptions(scope); | ||
|
|
||
| // TLS should be enabled when explicitly set | ||
| Assert.NotNull(interopOptions.tls_options); | ||
|
Check failure on line 67 in tests/Temporalio.Tests/Client/TemporalConnectionOptionsTests.cs
|
||
| } | ||
| } | ||
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.
I don't think we should take this approach. The difference between a user manually doing
= nulland the default ofnullwould be very confusing. I think for .NET we should add abool Disabledproperty toTlsOptionsfor users that want to explicitly disable TLS.nullshould be considered unset/default (regardless of whether it's set that way)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.
Yeah, this is a bit nicer. Done