From bbe669b761db4cb03fca2dbf9a7890d5a7e120af Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Tue, 17 Mar 2020 00:52:38 -0500 Subject: hscript: Add new netconfigtype key and associated tests Not wired up to netaddress et al, but does parse properly. --- .../fixtures/0226-netconfigtype-netifrc.installfile | 20 ++++++++++++++++++++ tests/fixtures/0227-netconfigtype-eni.installfile | 20 ++++++++++++++++++++ .../fixtures/0228-netconfigtype-invalid.installfile | 20 ++++++++++++++++++++ tests/spec/validator_spec.rb | 19 +++++++++++++++++++ 4 files changed, 79 insertions(+) create mode 100644 tests/fixtures/0226-netconfigtype-netifrc.installfile create mode 100644 tests/fixtures/0227-netconfigtype-eni.installfile create mode 100644 tests/fixtures/0228-netconfigtype-invalid.installfile (limited to 'tests') diff --git a/tests/fixtures/0226-netconfigtype-netifrc.installfile b/tests/fixtures/0226-netconfigtype-netifrc.installfile new file mode 100644 index 0000000..3b7cace --- /dev/null +++ b/tests/fixtures/0226-netconfigtype-netifrc.installfile @@ -0,0 +1,20 @@ +hostname horizon-netifrc-test +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +network true +netconfigtype netifrc +netaddress eth0 dhcp +netaddress eth0 slaac +nameserver 9.9.9.10 +diskid /dev/sda QEMU_HARDDISK +disklabel /dev/sda gpt +partition /dev/sda 1 fill +fs /dev/sda1 ext4 +mount /dev/sda1 / +repository https://distfiles.adelielinux.org/adelie/current/system +repository https://distfiles.adelielinux.org/adelie/current/user +signingkey /etc/apk/keys/packages@adelielinux.org.pub +pkginstall adelie-base-posix dash-binsh easy-kernel-power8 easy-kernel-power8-modules grub-ieee1275 netifrc openrc s6-linux-init +keymap us +language en_GB.UTF-8 +timezone America/Chicago +firmware false diff --git a/tests/fixtures/0227-netconfigtype-eni.installfile b/tests/fixtures/0227-netconfigtype-eni.installfile new file mode 100644 index 0000000..2eb6712 --- /dev/null +++ b/tests/fixtures/0227-netconfigtype-eni.installfile @@ -0,0 +1,20 @@ +hostname horizon-netifrc-test +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +network true +netconfigtype eni +netaddress eth0 dhcp +netaddress eth0 slaac +nameserver 9.9.9.10 +diskid /dev/sda QEMU_HARDDISK +disklabel /dev/sda gpt +partition /dev/sda 1 fill +fs /dev/sda1 ext4 +mount /dev/sda1 / +repository https://distfiles.adelielinux.org/adelie/current/system +repository https://distfiles.adelielinux.org/adelie/current/user +signingkey /etc/apk/keys/packages@adelielinux.org.pub +pkginstall adelie-base-posix dash-binsh easy-kernel easy-kernel-modules grub-ieee1275 openrc s6-linux-init +keymap us +language en_GB.UTF-8 +timezone America/Chicago +firmware false diff --git a/tests/fixtures/0228-netconfigtype-invalid.installfile b/tests/fixtures/0228-netconfigtype-invalid.installfile new file mode 100644 index 0000000..fcb29df --- /dev/null +++ b/tests/fixtures/0228-netconfigtype-invalid.installfile @@ -0,0 +1,20 @@ +hostname horizon-netifrc-test +rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/ +network true +netconfigtype netbsd-rcconf +netaddress eth0 dhcp +netaddress eth0 slaac +nameserver 9.9.9.10 +diskid /dev/sda QEMU_HARDDISK +disklabel /dev/sda gpt +partition /dev/sda 1 fill +fs /dev/sda1 ext4 +mount /dev/sda1 / +repository https://distfiles.adelielinux.org/adelie/current/system +repository https://distfiles.adelielinux.org/adelie/current/user +signingkey /etc/apk/keys/packages@adelielinux.org.pub +pkginstall adelie-base-posix dash-binsh easy-kernel-power8 easy-kernel-power8-modules grub-ieee1275 netifrc openrc s6-linux-init +keymap us +language en_GB.UTF-8 +timezone America/Chicago +firmware false diff --git a/tests/spec/validator_spec.rb b/tests/spec/validator_spec.rb index 971b91d..963eecf 100644 --- a/tests/spec/validator_spec.rb +++ b/tests/spec/validator_spec.rb @@ -221,6 +221,25 @@ RSpec.describe 'HorizonScript validation', :type => :aruba do expect(last_command_started).to have_output(/error: .*arch.*expected/) end end + context "for 'netconfigtype' key" do + it "succeeds with netifrc specified" do + use_fixture '0226-netconfigtype-netifrc.installfile' + run_validate + expect(last_command_started).to have_output(PARSER_SUCCESS) + expect(last_command_started).to have_output(VALIDATOR_SUCCESS) + end + it "succeeds with /etc/network/interfaces specified" do + use_fixture '0227-netconfigtype-eni.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 an invalid value" do + use_fixture '0228-netconfigtype-invalid.installfile' + run_validate + expect(last_command_started).to have_output(/error: .*netconfigtype.*valid/) + end + end context "for 'nameserver' key" do it "succeeds with IPv4 and IPv6 addresses" do use_fixture '0183-nameserver-basic.installfile' -- cgit v1.2.3-60-g2f50