/* * 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 . */ package modules_test import ( "context" "os" "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 TestMain(m *testing.M) { modules.SetInsecureTestMode(true) os.Exit(m.Run()) } 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, err := testServer.AuthServer.UpsertAuthPreference(ctx, types.DefaultAuthPreference()) require.NoError(t, err) authPref.SetSecondFactor(constants.SecondFactorOff) _, err = testServer.AuthServer.UpdateAuthPreference(ctx, authPref) require.EqualError(t, err, "cannot disable two-factor authentication") } 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.UpsertSessionRecordingConfig(ctx, recConfig) require.NoError(t, err) recConfig.SetMode(types.RecordAtProxy) _, err = testServer.AuthServer.UpsertSessionRecordingConfig(ctx, recConfig) require.EqualError(t, err, "cannot set proxy recording mode on Cloud") }