Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
# Many thanks to Steven Danna (@ssd) for making this 100x more awesome.
FAKE_STDOUT = <<-EOX
Client Version: v1.10.9
Server Version: v1.10.10
EOX
control 'kube-1.0' do
title 'CVE-2018-1002105'
impact 1.0
cmd_stdout = FAKE_STDOUT # Should be `command('kubectl version --short').stdout`
version = cmd_stdout.match(/Server Version: v(.*)/)[1]
expected_version = case version
when /1.[0-9]\./
'1.10.10'
when /1\.10/
'1.10.10'
when /1\.11/
'1.11.4'
when /1\.12/
'1.12.2'
else
'1.12.2'
end
describe "Kube version: #{version}" do
it "should be greater than #{expected_version}" do
expect(version).to cmp > expected_version
end
end
end
@jerryaldrichiii

This comment has been minimized.

Copy link
Owner Author

jerryaldrichiii commented Dec 7, 2018

Example output:

×  kube-1.0: CVE-2018-1002105
   ×  Kube version: 1.10.10 should be greater than 1.10.10

   expected it to be > "1.10.10"
        got: "1.10.10"

   (compared using `cmp` matcher)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.