From 011f7069677c77ee3039d94aef7bc25030ab3309 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Thu, 31 Oct 2019 21:30:06 -0500 Subject: hscript: Implement Encrypt, add tests --- tests/fixtures/0189-encrypt-basic.installfile | 9 +++++++++ tests/fixtures/0190-encrypt-duplicate.installfile | 10 ++++++++++ tests/fixtures/0191-encrypt-invalid.installfile | 9 +++++++++ tests/fixtures/0192-encrypt-pw.installfile | 9 +++++++++ tests/spec/validator_spec.rb | 24 +++++++++++++++++++++++ 5 files changed, 61 insertions(+) create mode 100644 tests/fixtures/0189-encrypt-basic.installfile create mode 100644 tests/fixtures/0190-encrypt-duplicate.installfile create mode 100644 tests/fixtures/0191-encrypt-invalid.installfile create mode 100644 tests/fixtures/0192-encrypt-pw.installfile (limited to 'tests') diff --git a/tests/fixtures/0189-encrypt-basic.installfile b/tests/fixtures/0189-encrypt-basic.installfile new file mode 100644 index 0000000..e198832 --- /dev/null +++ b/tests/fixtures/0189-encrypt-basic.installfile @@ -0,0 +1,9 @@ +network false +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +diskid /dev/sdb WDBNCE2500PNC +disklabel /dev/sdb gpt +partition /dev/sdb 1 fill +encrypt /dev/sdb1 +mount /dev/sdb1 / diff --git a/tests/fixtures/0190-encrypt-duplicate.installfile b/tests/fixtures/0190-encrypt-duplicate.installfile new file mode 100644 index 0000000..72eafec --- /dev/null +++ b/tests/fixtures/0190-encrypt-duplicate.installfile @@ -0,0 +1,10 @@ +network false +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +diskid /dev/sdb WDBNCE2500PNC +disklabel /dev/sdb gpt +partition /dev/sdb 1 fill +encrypt /dev/sdb1 +encrypt /dev/sdb1 +mount /dev/sdb1 / diff --git a/tests/fixtures/0191-encrypt-invalid.installfile b/tests/fixtures/0191-encrypt-invalid.installfile new file mode 100644 index 0000000..fc0c06f --- /dev/null +++ b/tests/fixtures/0191-encrypt-invalid.installfile @@ -0,0 +1,9 @@ +network false +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +diskid /dev/sdb WDBNCE2500PNC +disklabel /dev/sdb gpt +partition /dev/sdb 1 fill +encrypt sdb1 +mount /dev/sdb1 / diff --git a/tests/fixtures/0192-encrypt-pw.installfile b/tests/fixtures/0192-encrypt-pw.installfile new file mode 100644 index 0000000..29612e4 --- /dev/null +++ b/tests/fixtures/0192-encrypt-pw.installfile @@ -0,0 +1,9 @@ +network false +hostname test.machine +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +diskid /dev/sdb WDBNCE2500PNC +disklabel /dev/sdb gpt +partition /dev/sdb 1 fill +encrypt /dev/sdb1 shhsekrit +mount /dev/sdb1 / diff --git a/tests/spec/validator_spec.rb b/tests/spec/validator_spec.rb index 5c78f36..a9c5fd9 100644 --- a/tests/spec/validator_spec.rb +++ b/tests/spec/validator_spec.rb @@ -910,6 +910,30 @@ RSpec.describe 'HorizonScript validation', :type => :aruba do expect(last_command_started).to have_output(/error: .*lvm_lv.*volume group/) end end + context "for 'encrypt' key" do + it "succeeds with a simple value" do + use_fixture '0189-encrypt-basic.installfile' + run_validate + expect(last_command_started).to have_output(PARSER_SUCCESS) + expect(last_command_started).to have_output(VALIDATOR_SUCCESS) + end + it "fails with a duplicate block device" do + use_fixture '0190-encrypt-duplicate.installfile' + run_validate + expect(last_command_started).to have_output(/error: .*encrypt.*already/) + end + it "fails with an invalid block device" do + use_fixture '0191-encrypt-invalid.installfile' + run_validate + expect(last_command_started).to have_output(/error: .*encrypt.*expected/) + end + it "succeeds with a passphrase" do + use_fixture '0192-encrypt-pw.installfile' + run_validate + expect(last_command_started).to have_output(PARSER_SUCCESS) + expect(last_command_started).to have_output(VALIDATOR_SUCCESS) + end + end context "for 'fs' key" do it "succeeds with a simple value" do use_fixture '0179-fs-basic.installfile' -- cgit v1.2.3-60-g2f50