Files
teleport/lib/tbot/cli/start_application_tunnel_test.go
Dan Upton c44fc49487 MWI: Move application output and tunnel to lib/tbot/services/application (#56753)
* Move application output and tunnel to `lib/tbot/services/application`

* Use `LoggerForService` in application services

* Fix stray imports

* Remove unnecessary `bytes.NewBuffer`

* Fix ineffectual assignment
2025-07-28 09:16:41 +00:00

59 lines
1.8 KiB
Go

/*
* Teleport
* Copyright (C) 2024 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 ApplicationTunnelCommand
// properly parses its arguments and applies as expected onto a BotConfig.
func TestApplicationTunnelCommand(t *testing.T) {
testStartConfigureCommand(t, NewApplicationTunnelCommand, []startConfigureTestCase{
{
name: "success",
args: []string{
"start",
"application-tunnel",
"--token=foo",
"--join-method=github",
"--proxy-server=example.com:443",
"--app=foo",
"--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.TunnelConfig)
require.True(t, ok)
require.Equal(t, "foo", appSvc.AppName)
require.Equal(t, "tcp://0.0.0.0:8000", appSvc.Listen)
},
},
})
}