Skip to content

test: FIPS does not setup bind mounts#4566

Draft
angelcerveraroldan wants to merge 2 commits into
coreos:mainfrom
angelcerveraroldan:fips-bind-mount-test
Draft

test: FIPS does not setup bind mounts#4566
angelcerveraroldan wants to merge 2 commits into
coreos:mainfrom
angelcerveraroldan:fips-bind-mount-test

Conversation

@angelcerveraroldan

Copy link
Copy Markdown
Member

On RHEL10, fips-mode-setup was removed. If the FIPS dracut module
doesn't call update-crypto-policies directly, the fips-crypto-policies
dracut module falls back to setting up read-only bind mounts over
/etc/crypto-policies, leading to issues.

Add a test assertion to verify that /etc/crypto-policies is configured
on-disk and not via bind mounts, ensuring the fix[1] in
rhel-coreos-config is working correctly.

[1] coreos/rhel-coreos-config#259

Add a helper function that checks that a commands stdout does not
contain a substring.
On RHEL10, fips-mode-setup was removed. If the FIPS dracut module
doesn't call update-crypto-policies directly, the fips-crypto-policies
dracut module falls back to setting up read-only bind mounts over
/etc/crypto-policies, leading to issues.

Add a test assertion to verify that /etc/crypto-policies is configured
on-disk and not via bind mounts, ensuring the fix[1] in
rhel-coreos-config is working correctly.

[1] coreos/rhel-coreos-config#259

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new helper method AssertCmdOutputDoesNotContain to TestCluster and utilizes it in the FIPS test to verify that there are no mounts over crypto-policies. A review comment suggests improving the helper's failure message by including the command output and using %q formatting for better debuggability.

Comment on lines +212 to +220
// AssertCmdOutputDoesNotContain runs cmd via SSH and panics if stdout contains unexpected
func (t *TestCluster) AssertCmdOutputDoesNotContain(m platform.Machine, cmd string, unexpected string) {
t.LogJournal(m, "+ "+cmd)
outputBuf := t.MustSSH(m, cmd)
output := string(outputBuf)
if strings.Contains(output, unexpected) {
t.Fatalf("cmd %s unexpectedly contained %s", cmd, unexpected)
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve debuggability when a test assertion fails, it is highly recommended to include the actual command output in the failure message. Additionally, using %q instead of %s for the command and unexpected string arguments is a Go best practice to clearly demarcate them (especially if they contain spaces or special characters).

func (t *TestCluster) AssertCmdOutputDoesNotContain(m platform.Machine, cmd string, unexpected string) {
	t.LogJournal(m, "+ "+cmd)
	outputBuf := t.MustSSH(m, cmd)
	output := string(outputBuf)
	if strings.Contains(output, unexpected) {
		t.Fatalf("cmd %q unexpectedly contained %q; output:\n%s", cmd, unexpected, output)
	}
}

@angelcerveraroldan angelcerveraroldan marked this pull request as draft May 28, 2026 10:57
@angelcerveraroldan angelcerveraroldan changed the title Fips bind mount test test: FIPS does not setup bind mounts May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant