Skip to content
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

Add TLS support for proxytest #4745

Merged
merged 4 commits into from
May 20, 2024
Merged

Conversation

pchila
Copy link
Contributor

@pchila pchila commented May 14, 2024

What does this PR do?

This PR introduces TLS configuration for testing/proxytest in order to be able to configure mTLS.
No TLS, basic TLS (certificate server-side, no client auth) and mTLS (certificates for both client and server, common trusted CA) are tested via unit tests

Why is it important?

testing/proxytest is going to be used to test (m)TLS proxy settings for elastic-agent

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • [ ] I have added an entry in ./changelog/fragments using the changelog tool
  • [ ] I have added an integration test or an E2E test

Disruptive User Impact

How to test this PR locally

Related issues

Questions to ask yourself

  • How are we going to support this in production?
  • How are we going to measure its adoption?
  • How are we going to debug this?
  • What are the metrics I should take care of?
  • ...

@pchila pchila added enhancement New feature or request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team Team:Elastic-Agent Label for the Agent team Testing labels May 14, 2024
@pchila pchila self-assigned this May 14, 2024
Copy link
Contributor

mergify bot commented May 14, 2024

This pull request does not have a backport label. Could you fix it @pchila? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v./d./d./d is the label to automatically backport to the 8./d branch. /d is the digit

NOTE: backport-skip has been added to this pull request.

@pchila pchila force-pushed the support-mTLS-in-proxytest branch from c199b8e to 81ebe66 Compare May 14, 2024 16:32
@pchila pchila marked this pull request as ready for review May 14, 2024 16:35
@pchila pchila requested a review from a team as a code owner May 14, 2024 16:35
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@pchila pchila requested review from cmacknz and blakerouse and removed request for rdner May 14, 2024 16:38
@pchila pchila mentioned this pull request May 16, 2024
5 tasks
Copy link
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just a questions on the panic not a blocker.

p.Server.Start()
u, err := url.Parse(p.URL)
if err != nil {
panic(fmt.Sprintf("could parse fleet-server URL: %v", err))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not make this return an error and let the caller handle it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally the Start() and StartTLS() methods were not defined for the Proxy struct as it exposed the ones from *httptest.Server. It wasn't even used in tests as the server was created and started in one go.
Now that we are overriding those methods we can return what we want, will add a small commit for that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 979217c

p.Server.StartTLS()
u, err := url.Parse(p.URL)
if err != nil {
panic(fmt.Sprintf("could parse fleet-server URL: %v", err))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 979217c

Copy link

@pchila pchila merged commit 29d5108 into elastic:main May 20, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-skip enhancement New feature or request skip-changelog Team:Elastic-Agent Label for the Agent team Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team Testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend testing/proxytest to support mTLS
3 participants