mirror of
https://github.com/gravitational/teleport.git
synced 2026-10-31 03:27:49 +08:00
84 lines
2.5 KiB
Go
84 lines
2.5 KiB
Go
/*
|
|
* Teleport
|
|
* Copyright (C) 2023 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 modules_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/gravitational/teleport/api/constants"
|
|
"github.com/gravitational/teleport/api/types"
|
|
"github.com/gravitational/teleport/lib/auth"
|
|
"github.com/gravitational/teleport/lib/modules"
|
|
)
|
|
|
|
func TestOSSModules(t *testing.T) {
|
|
require.False(t, modules.GetModules().IsBoringBinary())
|
|
require.Equal(t, modules.BuildOSS, modules.GetModules().BuildType())
|
|
}
|
|
|
|
func TestValidateAuthPreferenceOnCloud(t *testing.T) {
|
|
ctx := context.Background()
|
|
testServer, err := auth.NewTestAuthServer(auth.TestAuthServerConfig{
|
|
Dir: t.TempDir(),
|
|
})
|
|
require.NoError(t, err)
|
|
|
|
modules.SetTestModules(t, &modules.TestModules{
|
|
TestBuildType: modules.BuildEnterprise,
|
|
TestFeatures: modules.Features{
|
|
Cloud: true,
|
|
},
|
|
})
|
|
|
|
authPref := types.DefaultAuthPreference()
|
|
err = testServer.AuthServer.SetAuthPreference(ctx, authPref)
|
|
require.NoError(t, err)
|
|
|
|
authPref.SetSecondFactor(constants.SecondFactorOff)
|
|
err = testServer.AuthServer.SetAuthPreference(ctx, authPref)
|
|
require.EqualError(t, err, "cannot disable two-factor authentication on Cloud")
|
|
}
|
|
|
|
func TestValidateSessionRecordingConfigOnCloud(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
testServer, err := auth.NewTestAuthServer(auth.TestAuthServerConfig{
|
|
Dir: t.TempDir(),
|
|
})
|
|
require.NoError(t, err)
|
|
|
|
modules.SetTestModules(t, &modules.TestModules{
|
|
TestBuildType: modules.BuildEnterprise,
|
|
TestFeatures: modules.Features{
|
|
Cloud: true,
|
|
},
|
|
})
|
|
|
|
recConfig := types.DefaultSessionRecordingConfig()
|
|
err = testServer.AuthServer.SetSessionRecordingConfig(ctx, recConfig)
|
|
require.NoError(t, err)
|
|
|
|
recConfig.SetMode(types.RecordAtProxy)
|
|
err = testServer.AuthServer.SetSessionRecordingConfig(ctx, recConfig)
|
|
require.EqualError(t, err, "cannot set proxy recording mode on Cloud")
|
|
}
|