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

Using mock-server instead of the built-in mock for msteam #513

Merged
merged 20 commits into from
Mar 2, 2024

Conversation

jespino
Copy link
Member

@jespino jespino commented Feb 27, 2024

This PR replaces the built-in mock server, that required a specific compilations and mocked the whole msteams client, with one that is external (mock-server). This allows to do a full test of 100% of our code, without testing the MSTeams side.

authClient := &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyURL(proxyUrl),
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},

Check failure

Code scanning / CodeQL

Disabled TLS certificate check High

InsecureSkipVerify should not be used in production code.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to pay attention to this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, we don't, that is totally expected for testing :)

server/msteams/client_mock.go Fixed Show fixed Hide fixed
@jespino jespino marked this pull request as ready for review February 28, 2024 09:30
@jespino jespino requested a review from enahum February 28, 2024 09:31
@enahum
Copy link
Contributor

enahum commented Feb 28, 2024

@jespino I was looking into https://github.com/microsoft/dev-proxy for mocking.. it has many other things not just mocking responses. The idea was to use that for the load tests.. in your opinion what do you think is best

  1. Keep this and use it for the load tests as well
  2. Switch to dev proxy
  3. Use both, this and load tests with dev proxy

Let me know

Copy link
Contributor

@enahum enahum left a comment

Choose a reason for hiding this comment

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

A couple of comments but this looks great

server/msteams/client.go Outdated Show resolved Hide resolved
authClient := &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyURL(proxyUrl),
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to pay attention to this?

@jespino
Copy link
Member Author

jespino commented Feb 28, 2024

@jespino I was looking into https://github.com/microsoft/dev-proxy for mocking.. it has many other things not just mocking responses. The idea was to use that for the load tests.. in your opinion what do you think is best

1. Keep this and use it for the load tests as well

2. Switch to dev proxy

3. Use both, this and load tests with dev proxy

Let me know

I don't know much about the dev-proxy, but one thing I like about the mock-server is that it is fully open-source and generalistic, so we can make it behave however we want. We can modify the mocks on the fly with the API, reset them, make assertions... I think it is very powerful. Maybe dev-proxy is equally powerful, but I don't know it. Also, mock-server is already an official testcontainers module. Also, depending on the dev-proxy capabilities, we can try to use dev-proxy instead of mock-server, I can create a testcontainers module for dev-proxy without much effort (I guess), and if that works as a proxy, probably it would be as easy to use as the one that we are using now.

Copy link
Member

@lieut-data lieut-data left a comment

Choose a reason for hiding this comment

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

Thanks, @jespino! A few questions below, but nothing strictly blocking.

server/plugin.go Outdated Show resolved Hide resolved
server/testutils/containere2e/containere2e.go Outdated Show resolved Hide resolved
server/msteams/client.go Outdated Show resolved Hide resolved
@jespino
Copy link
Member Author

jespino commented Mar 1, 2024

@lieut-data I addressed all your concerns, I think, PTAL.

@jespino jespino requested a review from lieut-data March 1, 2024 12:09
Copy link
Member

@lieut-data lieut-data left a comment

Choose a reason for hiding this comment

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

Thanks, @jespino!

@jespino jespino merged commit adf82ee into main Mar 2, 2024
7 checks passed
@jespino jespino deleted the using-mockserver branch March 2, 2024 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants