mirror of
https://github.com/gravitational/teleport.git
synced 2026-10-25 10:40:02 +08:00
* Initial implementation of an HTTP Proxy implementation for TBot * Added caching feature, caching config option & tests * Rework httpClient; Rework insecureSkipVerify; Remove whitelist; Improved Error Handling; * Move proxyPing to startProxy * Remove old Application whitelist reference * Review comments * fix header issue, improve tests a bit * Fix passing path; Improve testing * add query passing; add tests for it * Merge contexts of request * Use service ctx as base context for http server * Simplify creation of upstream request * Add TODO around determing correct URL to use when connecting upstream * Add TODO on checking ALPN upgrade * Block CONNECT requests * Add TODO around caching whole http client * Add note on public address of app * Fix upstream request host/scheme * Tidy * Fix logging to guidelines * Add support for ALPN upgrade * A little tidying * Add GoDocs for the service config * Setup fncache with correct interval * Add GoDoc * Remove redundant otel tracer * Add tests for config * Fix lint issues * Update config golden file * Fix test * Add license headers * proxy_service_config.go -> proxy_config.go * Update lib/tbot/services/application/proxy_service_test.go Co-authored-by: Dan Upton <daniel.upton@goteleport.com> * Add note on h2c/http2 * Remove spurious line * Add godocs * Replace context.Background() with t.Context() in test * Add GoDOc for ProxyServiceType * Update ports in example to not clash with postgres * Add CLI command --------- Co-authored-by: Thijs Cramer <thijs.cramer@gmail.com> Co-authored-by: Dan Upton <daniel.upton@goteleport.com>
57 lines
1.7 KiB
Go
57 lines
1.7 KiB
Go
/*
|
|
* Teleport
|
|
* Copyright (C) 2025 Gravitational, Inc.
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package cli
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/gravitational/teleport/lib/tbot/config"
|
|
"github.com/gravitational/teleport/lib/tbot/services/application"
|
|
)
|
|
|
|
// TestApplicationTunnelCommand tests that the ApplicationProxyCommand
|
|
// properly parses its arguments and applies as expected onto a BotConfig.
|
|
func TestApplicationProxyCommand(t *testing.T) {
|
|
testStartConfigureCommand(t, NewApplicationProxyCommand, []startConfigureTestCase{
|
|
{
|
|
name: "success",
|
|
args: []string{
|
|
"start",
|
|
"application-proxy",
|
|
"--token=foo",
|
|
"--join-method=github",
|
|
"--proxy-server=example.com:443",
|
|
"--listen=tcp://0.0.0.0:8000",
|
|
},
|
|
assertConfig: func(t *testing.T, cfg *config.BotConfig) {
|
|
require.Len(t, cfg.Services, 1)
|
|
|
|
// It must configure an app tunnel service
|
|
svc := cfg.Services[0]
|
|
appSvc, ok := svc.(*application.ProxyServiceConfig)
|
|
require.True(t, ok)
|
|
|
|
require.Equal(t, "tcp://0.0.0.0:8000", appSvc.Listen)
|
|
},
|
|
},
|
|
})
|
|
}
|