Integ tests: Use address of web UI as Proxy.PublicAddrs#20328
Merged
Integ tests: Use address of web UI as Proxy.PublicAddrs#20328
Conversation
i.Web is also used as tconf.Proxy.WebAddr.Addr a couple of lines below. When pinging the proxy, TeleportClient takes the response and updates a couple of values based on that response. If proxySettings.SSH.PublicAddr is not empty, it tries to parse the address and then set it as tc.WebProxyAddr. [1] If it cannot parse the port number, it uses the default (3080). What is getting returned as `proxySettings.SSH.PublicAddr`? That's determined by setProxyPublicAddressesSettings in lib/service/proxy_settings.go. [2] It uses the first element from Proxy.PublicAddrs. Now, the integration test helpers set up the Teleport instance in such way that the first Proxy.PublicAddrs is set to i.Hostname which resolves to just "localhost" in tests. So if any test pings the proxy first and then tries to make another request with the same TeleportClient, the subsequent request will try to reach out to localhost:3080. This happened to me when trying to add a new test. [3] This PR fixes this by making sure that the first element of Proxy.PublicAddrs actually points at the address of the web UI. See also the message from Marek about backwards compatibility of SSHProxyHostPort. [4] [5] [1] https://github.com/gravitational/teleport/blob/885d7397ab3746154342712bec86bcdb3ea93eab/lib/client/api.go#L3666-L3673 [2] https://github.com/gravitational/teleport/blob/806a568ada7c640a64eb60f718e7d56be34049ad/lib/service/proxy_settings.go#L112 [3] #20263 [4] https://gravitational.slack.com/archives/C0DF0TPMY/p1673895327794379?thread_ts=1673891288.249809&cid=C0DF0TPMY [5] https://github.com/gravitational/teleport/blob/db7fdff8097bcc883af8d9dde6a271d07e418550/api/client/webclient/webclient.go#L490
3 tasks
EdwardDowling
approved these changes
Jan 18, 2023
Member
Author
|
@espadolini I'd appreciate if you could take a look at this, it's a one line change in integration test setup which doesn't seem to break the tests. It would allow me to push a PR which adds a test that depends on this change. |
espadolini
approved these changes
Jan 19, 2023
Member
Author
|
Thanks! |
Contributor
|
@ravicious See the table below for backport results.
|
This was referenced Jan 20, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When pinging the proxy, TeleportClient takes the response and updates a couple of values based on that response. If proxySettings.SSH.PublicAddr is not empty, it tries to parse the address and then set it as tc.WebProxyAddr.
If it cannot parse the port number, it uses the default (3080).
What is getting returned as
proxySettings.SSH.PublicAddr? That's determined by setProxyPublicAddressesSettings in lib/service/proxy_settings.go. It uses the first element from Proxy.PublicAddrs.teleport/lib/service/proxy_settings.go
Line 112 in 806a568
Now, the integration test helpers set up the Teleport instance in such way that the first Proxy.PublicAddrs is set to i.Hostname which resolves to just "localhost" in tests. So if any test pings the proxy first and then tries to make another request with the same TeleportClient, the subsequent request will try to reach out to localhost:3080. This happened to me when trying to add a new test (#20263).
This PR fixes this by making sure that the first element of Proxy.PublicAddrs actually points at the address of the web UI. i.Web is also used as tconf.Proxy.WebAddr.Addr a couple of lines below.
See also the message from Marek about backwards compatibility of SSHProxyHostPort.