-
-
Notifications
You must be signed in to change notification settings - Fork 288
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
feat(#370) Added mTLS support to docker endpoint #548
feat(#370) Added mTLS support to docker endpoint #548
Conversation
4b618c7
to
1f4209f
Compare
I am not sure why few tests failed when locally run fine. I think that my code is out of test scope. What this PR miss are:
|
src/Testcontainers/Builders/TlsEndpointAuthenticationProvider.cs
Outdated
Show resolved
Hide resolved
src/Testcontainers/Configurations/Credentials/TlsCredentials.cs
Outdated
Show resolved
Hide resolved
tests/Testcontainers.Tests/Unit/Configurations/CustomConfigurationTest.cs
Outdated
Show resolved
Hide resolved
339a9c0
to
822cd9a
Compare
822cd9a
to
1fb07a3
Compare
1fb07a3
to
5ea3404
Compare
5ea3404
to
e29a896
Compare
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 would like to split this pull request into two smaller chunks. The first one should just contain the changes regarding ICustomConfiguration
(reading the custom configuration values incl. tests). The second one the TLS implementation. It makes the review easier and we can focus just on the TLS part next. What do you think? In the meantime I'll setup the TLS test environment. Thanks again.
Ok, will try to prepare it soon. |
e29a896
to
a78b3b7
Compare
We can use something like this to create a test instance: public sealed class GitHub : IAsyncLifetime
{
private const string CertsDirectoryName = "certs";
private static readonly string ContainerCertDirectoryPath = Path.Combine("/", CertsDirectoryName);
private static readonly string HostCertDirectoryPath = Path.Combine(Path.GetTempPath(), CertsDirectoryName);
private readonly ITestcontainersContainer tlsContainer = new TestcontainersBuilder<TestcontainersContainer>()
.WithImage("docker:20.10-dind")
.WithPrivileged(true)
.WithEnvironment("DOCKER_CERT_PATH", ContainerCertDirectoryPath)
.WithEnvironment("DOCKER_TLS_CERTDIR", ContainerCertDirectoryPath)
.WithEnvironment("DOCKER_TLS", "1")
.WithEnvironment("DOCKER_TLS_VERIFY", "1")
.WithBindMount(HostCertDirectoryPath, ContainerCertDirectoryPath, AccessMode.ReadWrite)
.Build();
[Fact]
public Task PullRequest548()
{
return Task.CompletedTask;
}
public Task InitializeAsync()
{
return this.tlsContainer.StartAsync();
}
public Task DisposeAsync()
{
return this.tlsContainer.DisposeAsync().AsTask();
}
} This generates the certificates too. |
Ok will try to use it. But I will update PR to latest master then will split it to two smaller chunks with tests. |
a78b3b7
to
0cde71d
Compare
0cde71d
to
751e60e
Compare
@HofmeisterAn I updated mTls implementation based on implementation of Tls in PR #597 including inheritance to not repeat code. Uou can look at implementation and chak it. Also here is a test which tests that mTls work. |
b787bfc
to
1de1d1a
Compare
tests/Testcontainers.Tests/Fixtures/Containers/Unix/DockerTlsFixture.cs
Outdated
Show resolved
Hide resolved
d8af486
to
b2db92e
Compare
1cf86c9
to
420f8e1
Compare
c2a4cb0
to
8da5ab3
Compare
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 think the pull request is on the right track. I would like to make sure that the configurations for the fixtures are correct, afterwards we can finalize the providers. Setting the fixtures explicit to tlsverify
or tls
should be the next step (dunno if that is possible via containers command args). Maybe we need to generate certificates by ourself and check them in to set the configuration explicit.
tests/Testcontainers.Tests/Fixtures/Containers/Unix/ProtectDockerDaemonSocket.cs
Outdated
Show resolved
Hide resolved
tests/Testcontainers.Tests/Fixtures/Containers/Unix/DockerMTlsFixture.cs
Show resolved
Hide resolved
tests/Testcontainers.Tests/Unit/Containers/Unix/ProtectDockerDaemonSocketTest.cs
Outdated
Show resolved
Hide resolved
src/Testcontainers/Builders/TlsEndpointAuthenticationProvider.cs
Outdated
Show resolved
Hide resolved
2e11eae
to
f159775
Compare
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.
@vlaskal Would you take a look at my recent changes? I think I just need to fix 2 tests, then we are good to merge. What do you think?
tests/Testcontainers.Tests/Unit/Configurations/DockerEndpointAuthenticationProviderTest.cs
Outdated
Show resolved
Hide resolved
src/Testcontainers/Builders/TlsEndpointAuthenticationProvider.cs
Outdated
Show resolved
Hide resolved
tests/Testcontainers.Tests/Fixtures/Containers/Unix/DockerMTlsFixture.cs
Outdated
Show resolved
Hide resolved
tests/Testcontainers.Tests/Unit/Configurations/DockerEndpointAuthenticationProviderTest.cs
Outdated
Show resolved
Hide resolved
Done. I think we are close. |
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.
It looks as final.
accecfe
to
7fd700f
Compare
…(TLS) Co-authored-by: Andre Hofmeister <[email protected]>
7fd700f
to
ed1f5ed
Compare
Closes #370. |
This PR add two options for docker endpoint authentication.
PR contains 2 commits on for each option.
This PR is draft only to review approach of implementation.