(#20607) Fix mode test on windows

File.stat on MRI ruby on windows can only distinguish between readable and
readonly files (0644 vs 0444), causing the test to fail, since it's
expecting 0664.

This commit updates the test to use Puppet's Security.get_mode method on
Windows, which preserves the file mode fidelity.

It also removes the expect { .. }.to_not raise_error, since we can just
execute the statement. Also made sure we actually fail due to an invalid
file mode, and not some other error.