Files
rosstimothy ff714af486 Inject insecure mode instead of relying on global variable (#63825)
Part 1 or removing InsecureDevMode - enterprise still relies on it
so a few TODOs were left around for clean up later. This global is
mostly leveraged in tests to permit trust when self-signed certificates
are used. These tests are often spinning up multiple teleport instances
and most of the time exercise trusted clusters which makes them slow.
Due to the global nature of InsecureDevMode these tests cannot be
run in parallel.
2026-03-05 16:31:10 +00:00

71 lines
2.3 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 integration
import (
"testing"
"time"
"github.com/gravitational/trace"
"github.com/jonboulle/clockwork"
"github.com/stretchr/testify/require"
"github.com/gravitational/teleport/api/utils/retryutils"
"github.com/gravitational/teleport/integration/helpers"
"github.com/gravitational/teleport/lib/service/servicecfg"
)
// TestTimeReconciliation launches two instances with clock differences in system clock,
// to verify that global notification is created about time drifting.
func TestTimeReconciliation(t *testing.T) {
helpers.SetTestTimeouts(2 * time.Second)
ctx := t.Context()
// Start Teleport Auth and Proxy services
authProcess, proxyProcess, provisionToken := helpers.MakeTestServers(t)
authService := authProcess.GetAuthServer()
proxyAddr, err := proxyProcess.ProxyWebAddr()
require.NoError(t, err)
cfg := servicecfg.MakeDefaultConfig()
agentClock := clockwork.NewFakeClockAt(time.Now().Add(24 * time.Hour))
cfg.Clock = agentClock
agent := helpers.MakeAgentServer(t, cfg, *proxyAddr, provisionToken)
require.NotNil(t, agent)
err = retryutils.RetryStaticFor(30*time.Second, time.Second, func() error {
agentClock.Advance(time.Minute)
notifications, _, err := authService.ListGlobalNotifications(ctx, 100, "")
if err != nil {
return trace.Wrap(err)
}
var found bool
for _, notification := range notifications {
found = found || notification.GetMetadata().GetName() == "cluster-monitor-system-clock-warning"
}
if !found {
return trace.BadParameter("expected notification is not found")
}
return nil
})
require.NoError(t, err)
}