From 02a2ad393de6cbea726514226e3419db6517307c Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Sat, 19 Oct 2019 21:35:27 -0500 Subject: hscript: Implement Firmware, and add tests --- tests/fixtures/0111-firmware-true.installfile | 6 ++++ tests/fixtures/0112-firmware-false.installfile | 6 ++++ tests/fixtures/0113-firmware-invalid.installfile | 7 +++++ tests/fixtures/0114-firmware-duplicate.installfile | 7 +++++ tests/spec/validator.rb | 33 ++++++++++++++++++++++ 5 files changed, 59 insertions(+) create mode 100644 tests/fixtures/0111-firmware-true.installfile create mode 100644 tests/fixtures/0112-firmware-false.installfile create mode 100644 tests/fixtures/0113-firmware-invalid.installfile create mode 100644 tests/fixtures/0114-firmware-duplicate.installfile (limited to 'tests') diff --git a/tests/fixtures/0111-firmware-true.installfile b/tests/fixtures/0111-firmware-true.installfile new file mode 100644 index 0000000..a2d5ead --- /dev/null +++ b/tests/fixtures/0111-firmware-true.installfile @@ -0,0 +1,6 @@ +network false +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / +firmware true diff --git a/tests/fixtures/0112-firmware-false.installfile b/tests/fixtures/0112-firmware-false.installfile new file mode 100644 index 0000000..9abc556 --- /dev/null +++ b/tests/fixtures/0112-firmware-false.installfile @@ -0,0 +1,6 @@ +network false +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / +firmware false diff --git a/tests/fixtures/0113-firmware-invalid.installfile b/tests/fixtures/0113-firmware-invalid.installfile new file mode 100644 index 0000000..b823be1 --- /dev/null +++ b/tests/fixtures/0113-firmware-invalid.installfile @@ -0,0 +1,7 @@ +network false +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / +# Intentional misspelling +firmware fasle diff --git a/tests/fixtures/0114-firmware-duplicate.installfile b/tests/fixtures/0114-firmware-duplicate.installfile new file mode 100644 index 0000000..372c645 --- /dev/null +++ b/tests/fixtures/0114-firmware-duplicate.installfile @@ -0,0 +1,7 @@ +network false +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / +firmware false +firmware false diff --git a/tests/spec/validator.rb b/tests/spec/validator.rb index 023d49e..0a94dbf 100644 --- a/tests/spec/validator.rb +++ b/tests/spec/validator.rb @@ -166,6 +166,32 @@ RSpec.describe 'HorizonScript validation', :type => :aruba do run_validate expect(last_command_started).to have_output(/error: .*rootpw.*/) end + context "for 'firmware' key" do + it "always supports 'false' value" do + use_fixture '0112-firmware-false.installfile' + run_validate + expect(last_command_started).to have_output(PARSER_SUCCESS) + expect(last_command_started).to have_output(VALIDATOR_SUCCESS) + end + it "requires 'false' if built without support" do + use_fixture '0111-firmware-true.installfile' + run_validate + skip "This build supports firmware" if last_command_started.stdout =~ /supports non-free/ + expect(last_command_started).to have_output(/error: .*firmware/) + end + it "supports 'true' if built with support" do + use_fixture '0111-firmware-true.installfile' + run_validate + skip "This build does not support firmware" if last_command_started.stdout !~ /supports non-free/ + expect(last_command_started).to have_output(PARSER_SUCCESS) + expect(last_command_started).to have_output(VALIDATOR_SUCCESS) + end + it "requires a boolean value" do + use_fixture '0113-firmware-invalid.installfile' + run_validate + expect(last_command_started).to have_output(/error: .*firmware.*value/) + end + end context "for 'mount' key" do # Runner.Validate.mount. it "fails with an invalid value" do @@ -507,6 +533,13 @@ RSpec.describe 'HorizonScript validation', :type => :aruba do run_validate expect(last_command_started).to have_output(/error: .*duplicate.*rootpw/) end + # Runner.Validate.firmware. + it "fails with a duplicate 'firmware' key" do + use_fixture '0114-firmware-duplicate.installfile' + run_validate + skip "This build does not support firmware" if last_command_started.stdout !~ /supports non-free/ + expect(last_command_started).to have_output(/error: .*duplicate.*firmware/) + end end context "user account keys:" do context "'username'" do -- cgit v1.2.3-60-g2f50