From d625e22103caccf48c77f4d455d2c2b6518137fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Cie=C5=9Blak?= Date: Wed, 18 Jan 2023 16:04:17 +0100 Subject: [PATCH] Integ tests: Use address of web UI as Proxy.PublicAddrs 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] https://github.com/gravitational/teleport/pull/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 --- integration/helpers/instance.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration/helpers/instance.go b/integration/helpers/instance.go index 795d63ef34fc4..0d21ca3228030 100644 --- a/integration/helpers/instance.go +++ b/integration/helpers/instance.go @@ -498,7 +498,7 @@ func (i *TeleInstance) GenerateConfig(t *testing.T, trustedSecrets []*InstanceSe tconf.Proxy.PublicAddrs = []utils.NetAddr{ { AddrNetwork: "tcp", - Addr: i.Hostname, + Addr: i.Web, }, { AddrNetwork: "tcp",