Update tests to inject modules instead of relying on modulestest.SetTestModules (#65976)

This is a pass on replacing modulestest.SetTestModules with supplying modules
where already possible. Some additional uses of modules.GetModules were also
replaced with localized modules injection to permit the removal of
modulestest.SetTestModules in tests. Most of the changes here are mechanical,
the one notable change is in TestSSHCommands. The test was not passing locally
because the shell (fish) builtin echo behaves differently. The easiest way
to produce expected output was to change the command invocation to use
/bin/echo to bypass any shell builtins for consistent behavior.

Inject modules into tool tests

Inject modules into integration tests

Inject modules into join server

Remove superflous enterprise modules in TestAuthenticationConfig_Parse_deviceTrustPB

Inject modules into signature algorithm config tests

Inject modules into TestGithubConnectorCRUDEventsEmitted

Inject modules into TestGetHierarchyForUser

Inject modules into kube proxy tests

Inject modules into controller tests

make fix-imports

add integration/app/fixture as test package
This commit is contained in:
rosstimothy
2026-04-22 17:38:51 +00:00
committed by GitHub
parent e892451c6d
commit fc72fdcdc2
42 changed files with 189 additions and 219 deletions
+2 -2
View File
@@ -190,7 +190,7 @@ func (p *CheckGithubIDTokenParams) checkAndSetDefaults() error {
// CheckGithubIDToken checks a Github OIDC token against a provision token.
// If the token is valid and its claims match at least one allow rule, the
// claims are returned.
func CheckGithubIDToken(ctx context.Context, params *CheckGithubIDTokenParams) (*IDTokenClaims, error) {
func CheckGithubIDToken(ctx context.Context, m modules.Modules, params *CheckGithubIDTokenParams) (*IDTokenClaims, error) {
if err := params.checkAndSetDefaults(); err != nil {
return nil, trace.AccessDenied("%s", err.Error())
}
@@ -205,7 +205,7 @@ func CheckGithubIDToken(ctx context.Context, params *CheckGithubIDTokenParams) (
enterpriseOverride := token.Spec.GitHub.EnterpriseServerHost
enterpriseSlug := token.Spec.GitHub.EnterpriseSlug
if enterpriseOverride != "" || enterpriseSlug != "" {
if modules.GetModules().BuildType() != modules.BuildEnterprise {
if m.BuildType() != modules.BuildEnterprise {
return nil, trace.Wrap(services.ErrRequiresEnterprise, "github enterprise server joining")
}
}