-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve integration tests to execute with
tsh
and tctl
Added a full-cycle integration test to verify client tools auto-updates within a test cluster by modifying AutoUpdateConfig and AutoUpdateVersion resources. The test executes the login command using alias configurations to ensure no recursive re-execution occurs. The updater binary used in integration tests has been replaced with the `Run` logic of tctl and tsh.
- Loading branch information
Showing
12 changed files
with
385 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* 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 updater | ||
|
||
import ( | ||
"context" | ||
"crypto" | ||
"fmt" | ||
"time" | ||
|
||
"github.com/gravitational/trace" | ||
|
||
"github.com/gravitational/teleport" | ||
"github.com/gravitational/teleport/api/types" | ||
"github.com/gravitational/teleport/api/types/accesslist" | ||
"github.com/gravitational/teleport/api/utils/keys" | ||
"github.com/gravitational/teleport/entitlements" | ||
"github.com/gravitational/teleport/lib/modules" | ||
"github.com/gravitational/teleport/lib/tlsca" | ||
) | ||
|
||
const ( | ||
TestPassword = "abc123def456" | ||
) | ||
|
||
var ( | ||
version = teleport.Version | ||
) | ||
|
||
type TestModules struct{} | ||
|
||
func (p *TestModules) GenerateAccessRequestPromotions(context.Context, modules.AccessResourcesGetter, types.AccessRequest) (*types.AccessRequestAllowedPromotions, error) { | ||
return &types.AccessRequestAllowedPromotions{}, nil | ||
} | ||
|
||
func (p *TestModules) GetSuggestedAccessLists(context.Context, *tlsca.Identity, modules.AccessListSuggestionClient, modules.AccessListAndMembersGetter, string) ([]*accesslist.AccessList, error) { | ||
return []*accesslist.AccessList{}, nil | ||
} | ||
|
||
// BuildType returns build type (OSS or Enterprise) | ||
func (p *TestModules) BuildType() string { | ||
return "CLI" | ||
} | ||
|
||
// IsEnterpriseBuild returns false for [TestModules]. | ||
func (p *TestModules) IsEnterpriseBuild() bool { | ||
return false | ||
} | ||
|
||
// IsOSSBuild returns false for [TestModules]. | ||
func (p *TestModules) IsOSSBuild() bool { | ||
return false | ||
} | ||
|
||
// LicenseExpiry returns the expiry date of the enterprise license, if applicable. | ||
func (p *TestModules) LicenseExpiry() time.Time { | ||
return time.Time{} | ||
} | ||
|
||
// PrintVersion prints the Teleport version. | ||
func (p *TestModules) PrintVersion() { | ||
fmt.Printf("Teleport v%v git\n", version) | ||
} | ||
|
||
// Features returns supported features | ||
func (p *TestModules) Features() modules.Features { | ||
return modules.Features{ | ||
Entitlements: map[entitlements.EntitlementKind]modules.EntitlementInfo{}, | ||
AdvancedAccessWorkflows: true, | ||
} | ||
} | ||
|
||
// IsBoringBinary checks if the binary was compiled with BoringCrypto. | ||
func (p *TestModules) IsBoringBinary() bool { | ||
return false | ||
} | ||
|
||
// AttestHardwareKey attests a hardware key. | ||
func (p *TestModules) AttestHardwareKey(context.Context, interface{}, *keys.AttestationStatement, crypto.PublicKey, time.Duration) (*keys.AttestationData, error) { | ||
return nil, trace.NotFound("no attestation data for the given key") | ||
} | ||
|
||
func (p *TestModules) EnableRecoveryCodes() {} | ||
|
||
func (p *TestModules) EnablePlugins() {} | ||
|
||
func (p *TestModules) SetFeatures(f modules.Features) {} | ||
|
||
func (p *TestModules) EnableAccessGraph() {} | ||
|
||
func (p *TestModules) EnableAccessMonitoring() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* 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 main | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/gravitational/teleport/integration/autoupdate/tools/updater" | ||
"github.com/gravitational/teleport/lib/modules" | ||
stacksignal "github.com/gravitational/teleport/lib/utils/signal" | ||
tctl "github.com/gravitational/teleport/tool/tctl/common" | ||
) | ||
|
||
func main() { | ||
ctx, cancel := stacksignal.GetSignalHandler().NotifyContext(context.Background()) | ||
defer cancel() | ||
|
||
modules.SetInsecureTestMode(true) | ||
modules.SetModules(&updater.TestModules{}) | ||
|
||
tctl.Run(ctx, tctl.Commands()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* 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 main | ||
|
||
import ( | ||
"context" | ||
"os" | ||
|
||
"github.com/gravitational/teleport/api/utils/prompt" | ||
"github.com/gravitational/teleport/integration/autoupdate/tools/updater" | ||
"github.com/gravitational/teleport/lib/modules" | ||
"github.com/gravitational/teleport/lib/utils" | ||
stacksignal "github.com/gravitational/teleport/lib/utils/signal" | ||
tsh "github.com/gravitational/teleport/tool/tsh/common" | ||
) | ||
|
||
func main() { | ||
ctx, cancel := stacksignal.GetSignalHandler().NotifyContext(context.Background()) | ||
defer cancel() | ||
|
||
modules.SetInsecureTestMode(true) | ||
modules.SetModules(&updater.TestModules{}) | ||
prompt.SetStdin(prompt.NewFakeReader().AddString(updater.TestPassword)) | ||
|
||
err := tsh.Run(ctx, os.Args[1:]) | ||
if err != nil { | ||
utils.FatalError(err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.