-
Notifications
You must be signed in to change notification settings - Fork 150
Allow TLS certificate to authenticate against the named certificate role #875
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
Conversation
spencergibb
left a comment
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.
Thank you for you contribution! Please add a test.
Fixes spring-cloud#874 Signed-off-by: Issam El-atif <[email protected]>
| public void contextLoads() { | ||
| assertThat(this.configValue).isEqualTo("foo"); | ||
| void authenticateUsingTlsCertificate() { | ||
| ConfigurableApplicationContext context = this.app.run("--spring.cloud.vault.authentication=cert", |
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.
Looking at the repetitions, would you mind introducing an abstraction that removes duplications?
A possible design could be a context runner utility that accepts reactive, bootstrap and test class details (basically everything that is changing across individual test methods while hiding everything that remains the same) and then invokes app.run(…)?
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.
Thanks @mp911de for your review.
A possible design could be a context runner utility that accepts reactive, bootstrap and test class details (basically everything that is changing across individual test methods while hiding everything that remains the same) and then invokes app.run(…)?
Are you considering a generic solution for all Vault tests or a specific abstraction for TLS authentication tests?
However, i can remove the duplications by configuring the SpringApplication app with shared properties
SpringApplication app = new SpringApplicationBuilder().sources(TestConfig.class)
.web(WebApplicationType.NONE)
.properties("spring.cloud.vault.authentication=cert",
"spring.cloud.vault.ssl.key-store=file:../work/client-cert.jks",
"spring.cloud.vault.ssl.key-store-password=changeit",
"spring.cloud.vault.application-name=VaultConfigTlsCertAuthenticationTests",
"spring.cloud.vault.reactive.enabled=false", "spring.cloud.bootstrap.enabled=true")
.build();Then add specific properties when running tests :
ConfigurableApplicationContext context = this.app.run("--spring.cloud.vault.ssl.role=my-role");
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.
Are you considering a generic solution for all Vault tests or a specific abstraction for TLS authentication tests?
Going forward, I'd like to have a consistent approach for all tests, however in the scope of this ticket, let's only focus on this test class to keep the scope rather focussed. In any case, appreciate your view outside of the box :-)
I think that SpringApplicationBuilder is a fine abstraction for the low-level part. By putting the aspect in front what is relevant for the actual test turns the entire property handling (names, values) rather into noise. I'm thinking about a functional design approach along the lines of:
VaultTestContextRuner.of(this.app).testClass(getClass()).sources(…).property("spring.cloud.vault.ssl.role", "my-role").run()
We would pick it then up for other tests and extend it to:
VaultTestContextRuner.of(this.app).sources(…).config(c -> c.reactive(true/false).boostrap(true/false)).run()
This is mostly an idea for now, when we introduce the broader notion of VaultTestContextRuner, we might refine the API as needed and based on how it makes the most sense.
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 like the idea. I can explore it further in a separate PR
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.
@mp911de I had some time this weekend, so I gave your idea a try.
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.
Thanks a lot. Let us take this PR from here.
Signed-off-by: Issam El-atif <[email protected]>
Signed-off-by: Issam El-atif <[email protected]>
|
@mp911de while working on #751 I discovred that What do you think? |
|
|
|
I completely agree with this assessment about Testcontainers. |
…ole. Also, introduce VaultTestContextRunner. Fixes gh-874 Original pull request: gh-875 Signed-off-by: Issam El-atif <[email protected]>
|
Thank you for your contribution. That's merged and polished now. |
Indeed! |
|
Likewise, you might want to have a look at the polishing commits that follow your contribution commit to get an idea how the context runner has evolved. |
|
I Love it! More robust more fluent a master touch! :) |
Fixes #874