Files
teleport/lib/tbot/cli/start_application_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

63 lines
1.9 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/bot/destination"
"github.com/gravitational/teleport/lib/tbot/config"
"github.com/gravitational/teleport/lib/tbot/services/application"
)
// TestApplicationCommand tests that the ApplicationCommand properly parses its
// arguments and applies as expected onto a BotConfig.
func TestApplicationCommand(t *testing.T) {
testStartConfigureCommand(t, NewApplicationCommand, []startConfigureTestCase{
{
name: "success",
args: []string{
"start",
"application",
"--destination=/bar",
"--token=foo",
"--join-method=github",
"--proxy-server=example.com:443",
"--app=foo",
"--specific-tls-extensions",
},
assertConfig: func(t *testing.T, cfg *config.BotConfig) {
// It must configure a app output with a directory destination.
svc := cfg.Services[0]
appSvc, ok := svc.(*application.OutputConfig)
require.True(t, ok)
require.Equal(t, "foo", appSvc.AppName)
require.True(t, appSvc.SpecificTLSExtensions)
dir, ok := appSvc.Destination.(*destination.Directory)
require.True(t, ok)
require.Equal(t, "/bar", dir.Path)
},
},
})
}