Skip to content

Commit bc34089

Browse files
ycombinatormergify[bot]
authored andcommitted
[Integration Testing] Allow tests to declare themselves as needing a FIPS environment (#8083)
* Define FIPS requirement field * Implement FIPS filter in testmain (cherry picked from commit 89902d1)
1 parent 3ff21a4 commit bc34089

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

pkg/testing/define/define.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ func runOrSkip(t *testing.T, req Requirements, local bool, kubernetes bool) *Inf
155155
t.Skipf("sudo requirement %t not matching sudo filter %t. Skipping", req.Sudo, *SudoFilter.value)
156156
}
157157

158+
if FipsFilter.value != nil && req.FIPS != *FipsFilter.value {
159+
t.Skipf("FIPS requirement %t not matching FIPS filter %t. Skipping.", req.FIPS, *FipsFilter.value)
160+
}
161+
158162
// record autodiscover after filtering by group and sudo and before validating against the actual environment
159163
if AutoDiscover {
160164
discoverTest(t, req)

pkg/testing/define/define_flags.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ var (
5050
GroupsFilter stringArrayFlag
5151
PlatformsFilter stringArrayFlag
5252
SudoFilter optionalBoolFlag
53+
FipsFilter optionalBoolFlag
5354
AutoDiscover bool
5455
AutoDiscoveryOutput string
5556
)
@@ -59,6 +60,7 @@ func RegisterFlags(prefix string, set *flag.FlagSet) {
5960
set.Var(&GroupsFilter, prefix+"groups", "test groups, comma-separated")
6061
set.Var(&PlatformsFilter, prefix+"platforms", "test platforms, comma-separated")
6162
set.Var(&SudoFilter, prefix+"sudo", "Filter tests by sudo requirements")
63+
set.Var(&FipsFilter, prefix+"fips", "Filter tests by FIPS requirement")
6264
set.BoolVar(&AutoDiscover, prefix+"autodiscover", false, "Auto discover tests (should be used together with -dry-run). Output will be a file that can be set with -autodiscoveryoutput")
6365
set.StringVar(&AutoDiscoveryOutput, prefix+"autodiscoveryoutput", "discovered_tests.yaml", "Set the file location where the structured output for the discovered tests will be stored")
6466
}

pkg/testing/define/requirements.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ type Requirements struct {
121121
// Sudo defines that this test must run under superuser permissions. On Mac and Linux the
122122
// test gets executed under sudo and on Windows it gets run under Administrator.
123123
Sudo bool `json:"sudo"`
124+
125+
// FIPS defines that this test must be run in an environment that is configured for FIPS,
126+
// e.g. a Linux VM with OpenSSL configured with the FIPS provider.
127+
FIPS bool `json:"fips"`
124128
}
125129

126130
// Validate returns an error if not valid.

0 commit comments

Comments
 (0)