Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test cases for PR #222 #227

Merged
merged 5 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/happy_mapper_tools/benchmark.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,17 @@ class Ident
content :ident, String
def initialize(ident_str)
@ident = ident_str
if ident_str =~ /^(CCI-[0-9]{6})$/
if ident_str =~ /^(CCI-[0-9]{6})$/
# Match CCI IDs; e.g. CCI-123456
@system = 'http://cyber.mil/cci'
else
elsif ident_str =~ /^(S?V-[0-9]{5})$/
# Match SV- IDs; e.g. SV-12345
# Match V- IDs; e.g. V-12345
@system = 'http://cyber.mil/legacy'
end
else
# for all other ident_str, use the old identifier
@system = 'https://public.cyber.mil/stigs/cci/'
end
end
end

Expand Down
21 changes: 21 additions & 0 deletions test/unit/inspec_tools/happymapper_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'minitest/spec'
require 'minitest/autorun'

describe "HappyMapperTools::Benchmark::Ident correctly determines the system for each identifier" do
# test values (tv); tv[0] == identifier, tv[1] == system
tvList = {
'CCI-000213' => 'http://cyber.mil/cci',
'V-72859' => 'http://cyber.mil/legacy',
'SV-87511' => 'http://cyber.mil/legacy',
'CCI-00213' => 'https://public.cyber.mil/stigs/cci/',
'CCI-0000213' => 'https://public.cyber.mil/stigs/cci/',
}

tvList.each do |identifier, system|
it identifier do
# Ident.new automatically determines ident.system
ident = HappyMapperTools::Benchmark::Ident.new identifier
assert_equal(system, ident.system)
end
end
end