From df3323015005e10f17688bb2b6127884cb2020e4 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Tue, 8 Oct 2019 23:20:58 -0500 Subject: tests: Add some more tests, and note reqs for each test --- tests/fixtures/0024-numeric-hostname.installfile | 5 ++ tests/fixtures/0025-jumbo-hostname.installfile | 5 ++ .../fixtures/0026-jumbo-part-hostname.installfile | 5 ++ tests/spec/validator.rb | 55 ++++++++++++++++++++-- 4 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 tests/fixtures/0024-numeric-hostname.installfile create mode 100644 tests/fixtures/0025-jumbo-hostname.installfile create mode 100644 tests/fixtures/0026-jumbo-part-hostname.installfile diff --git a/tests/fixtures/0024-numeric-hostname.installfile b/tests/fixtures/0024-numeric-hostname.installfile new file mode 100644 index 0000000..2dc9176 --- /dev/null +++ b/tests/fixtures/0024-numeric-hostname.installfile @@ -0,0 +1,5 @@ +network true +hostname 123lonelycorgi.street +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / diff --git a/tests/fixtures/0025-jumbo-hostname.installfile b/tests/fixtures/0025-jumbo-hostname.installfile new file mode 100644 index 0000000..e1a2fba --- /dev/null +++ b/tests/fixtures/0025-jumbo-hostname.installfile @@ -0,0 +1,5 @@ +network true +hostname nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow.usherworld.com +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / diff --git a/tests/fixtures/0026-jumbo-part-hostname.installfile b/tests/fixtures/0026-jumbo-part-hostname.installfile new file mode 100644 index 0000000..898f879 --- /dev/null +++ b/tests/fixtures/0026-jumbo-part-hostname.installfile @@ -0,0 +1,5 @@ +network true +hostname nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow-nice-and-slow.usherworld.com +pkginstall adelie-base +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +mount /dev/sda1 / diff --git a/tests/spec/validator.rb b/tests/spec/validator.rb index 1c3657e..4ad5544 100644 --- a/tests/spec/validator.rb +++ b/tests/spec/validator.rb @@ -24,6 +24,9 @@ RSpec.describe 'HorizonScript Validation Utility', :type => :aruba do end end context "on invalid keys" do + # No requirement - but was noted in the original draft vision doc as + # desireable because it allows future expansion while retaining some + # compatibility. it "warns on invalid keys by default" do use_fixture '0016-invalid-key.installfile' run_validate @@ -36,16 +39,19 @@ RSpec.describe 'HorizonScript Validation Utility', :type => :aruba do end end context "parsing" do + # obvious... it "successfully reads a basic installfile" do use_fixture '0001-basic.installfile' run_validate expect(last_command_started).to have_output(SUCCESS_OUTPUT) end + # HorizonScript Specification, ch 3. it "handles comments" do use_fixture '0002-basic-commented.installfile' run_validate expect(last_command_started).to have_output(SUCCESS_OUTPUT) end + # HorizonScript Specification, ch 3. it "handles blank lines and indentation" do use_fixture '0003-basic-whitespace.installfile' run_validate @@ -56,32 +62,43 @@ RSpec.describe 'HorizonScript Validation Utility', :type => :aruba do run_validate ' --keep-going' expect(last_command_started).to have_output(/2 error\(s\)/) end + # XXX: no requirement. it "fails on lines over maximum line length" do use_fixture '0017-line-too-long.installfile' run_validate expect(last_command_started).to have_output(/error: .*length/) end context "required keys" do + # Runner.Validate.Required. + # Runner.Validate.network. it "fails without a 'network' key" do use_fixture '0006-no-network.installfile' run_validate expect(last_command_started).to have_output(/error: .*network.*/) end + # Runner.Validate.Required. + # Runner.Validate.hostname. it "fails without a 'hostname' key" do use_fixture '0007-no-hostname.installfile' run_validate expect(last_command_started).to have_output(/error: .*hostname.*/) end + # Runner.Validate.Required. + # Runner.Validate.pkginstall. it "fails without a 'pkginstall' key" do use_fixture '0008-no-pkginstall.installfile' run_validate expect(last_command_started).to have_output(/error: .*pkginstall.*/) end + # Runner.Validate.Required. + # Runner.Validate.rootpw. it "fails without a 'rootpw' key" do use_fixture '0009-no-rootpw.installfile' run_validate expect(last_command_started).to have_output(/error: .*rootpw.*/) end + # Runner.Validate.Required. + # Runner.Validate.mount. it "fails without a 'mount' key" do use_fixture '0010-no-mount.installfile' run_validate @@ -89,21 +106,47 @@ RSpec.describe 'HorizonScript Validation Utility', :type => :aruba do end end context "values" do + # Runner.Validate.network. it "fails with an invalid 'network' value" do use_fixture '0011-invalid-network.installfile' run_validate expect(last_command_started).to have_output(/error: .*network.*/) end - it "fails with an invalid 'hostname' value" do - use_fixture '0012-invalid-hostname.installfile' - run_validate - expect(last_command_started).to have_output(/error: .*hostname.*/) + # Runner.Validate.hostname. + context "fails with an invalid 'hostname' value" do + # Runner.Validate.hostname.Chars. + it "with invalid characters" do + use_fixture '0012-invalid-hostname.installfile' + run_validate + expect(last_command_started).to have_output(/error: .*hostname.*/) + end + # Runner.Validate.hostname.Begin. + it "with non-alphabetical first character" do + use_fixture '0024-numeric-hostname.installfile' + run_validate + expect(last_command_started).to have_output(/error: .*hostname.*/) + end + # Runner.Validate.hostname.Length + it "with >320 characters" do + use_fixture '0025-jumbo-hostname.installfile' + run_validate + expect(last_command_started).to have_output(/error: .*hostname.*/) + end + # Runner.Validate.hostname.PartLength + it "with >64 characters in a single part" do + use_fixture '0026-jumbo-part-hostname.installfile' + run_validate + expect(last_command_started).to have_output(/error: .*hostname.*/) + end end + # Runner.Validate.rootpw. + # Runner.Validate.rootpw.Crypt. it "fails with an invalid 'rootpw' value" do use_fixture '0013-invalid-rootpw.installfile' run_validate expect(last_command_started).to have_output(/error: .*rootpw.*/) end + # Runner.Validate.mount. it "fails with an invalid 'mount' value" do use_fixture '0014-invalid-mount.installfile' run_validate @@ -111,16 +154,19 @@ RSpec.describe 'HorizonScript Validation Utility', :type => :aruba do end end context "unique keys" do + # Runner.Validate.network. it "fails with a duplicate 'network' key" do use_fixture '0018-duplicate-network.installfile' run_validate expect(last_command_started).to have_output(/error: .*duplicate.*network/) end + # Runner.Validate.hostname. it "fails with a duplicate 'hostname' key" do use_fixture '0019-duplicate-hostname.installfile' run_validate expect(last_command_started).to have_output(/error: .*duplicate.*hostname/) end + # Runner.Validate.rootpw. it "fails with a duplicate 'rootpw' key" do use_fixture '0020-duplicate-rootpw.installfile' run_validate @@ -128,6 +174,7 @@ RSpec.describe 'HorizonScript Validation Utility', :type => :aruba do end end context "package specifications" do + # no requirements for these, but I think obvious. it "works with all types of package atoms" do use_fixture '0022-all-kinds-of-atoms.installfile' run_validate -- cgit v1.2.3-60-g2f50