summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-11-06 16:47:19 -0600
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-11-06 16:52:36 -0600
commite4d2dfda526402b1cd4623ea473ab655ea421de5 (patch)
treebf4e293dda2025366061f662a7890c3fbfa2df54
parentd3f9715777ee32b7c3d38f8b520597eea2d79a79 (diff)
downloadhorizon-e4d2dfda526402b1cd4623ea473ab655ea421de5.tar.gz
horizon-e4d2dfda526402b1cd4623ea473ab655ea421de5.tar.bz2
horizon-e4d2dfda526402b1cd4623ea473ab655ea421de5.tar.xz
horizon-e4d2dfda526402b1cd4623ea473ab655ea421de5.zip
tests: Add more nameserver behavioural tests
-rw-r--r--hscript/script_e.cc15
-rw-r--r--tests/fixtures/0201-nameserver-max.installfile9
-rw-r--r--tests/fixtures/0202-nameserver-bad4.installfile6
-rw-r--r--tests/fixtures/0203-nameserver-bad6.installfile6
-rw-r--r--tests/spec/simulator_spec.rb5
-rw-r--r--tests/spec/validator_spec.rb15
6 files changed, 53 insertions, 3 deletions
diff --git a/hscript/script_e.cc b/hscript/script_e.cc
index b494698..32c1c69 100644
--- a/hscript/script_e.cc
+++ b/hscript/script_e.cc
@@ -432,12 +432,15 @@ bool Script::execute() const {
output_info("internal", "initialising APK");
if(opts.test(Simulate)) {
std::cout << "apk --root /target --initdb add" << std::endl;
- } else {
+ }
+#ifdef HAS_INSTALL_ENV
+ else {
if(system("apk --root /target --initdb add") != 0) {
EXECUTE_FAILURE("pkginstall");
return false;
}
}
+#endif /* HAS_INSTALL_ENV */
/* REQ: Runner.Execute.pkginstall */
output_info("internal", "installing packages to target");
@@ -448,7 +451,9 @@ bool Script::execute() const {
if(opts.test(Simulate)) {
std::cout << "apk --root /target update" << std::endl;
std::cout << "apk --root /target add " << pkg_list.str() << std::endl;
- } else {
+ }
+#ifdef HAS_INSTALL_ENV
+ else {
if(system("apk --root /target update") != 0) {
EXECUTE_FAILURE("pkginstall");
return false;
@@ -459,6 +464,7 @@ bool Script::execute() const {
return false;
}
}
+#endif /* HAS_INSTALL_ENV */
output_step_end("pkgdb");
@@ -476,7 +482,9 @@ bool Script::execute() const {
<< " /target/etc/runlevels/default/net." << iface
<< std::endl;
}
- } else {
+ }
+#ifdef HAS_INSTALL_ENV
+ else {
for(auto &iface : ifaces) {
fs::create_symlink("/etc/init.d/net.lo",
"/target/etc/init.d/net." + iface, ec);
@@ -494,6 +502,7 @@ bool Script::execute() const {
}
}
}
+#endif /* HAS_INSTALL_ENV */
}
if(!internal->rootpw->execute(opts)) {
diff --git a/tests/fixtures/0201-nameserver-max.installfile b/tests/fixtures/0201-nameserver-max.installfile
new file mode 100644
index 0000000..b078e47
--- /dev/null
+++ b/tests/fixtures/0201-nameserver-max.installfile
@@ -0,0 +1,9 @@
+network false
+hostname test.machine
+pkginstall adelie-base
+rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/
+mount /dev/sda1 /
+nameserver 9.9.9.10
+nameserver 149.112.112.10
+nameserver 2620:fe::10
+nameserver 2620:fe::fe:10
diff --git a/tests/fixtures/0202-nameserver-bad4.installfile b/tests/fixtures/0202-nameserver-bad4.installfile
new file mode 100644
index 0000000..12934e5
--- /dev/null
+++ b/tests/fixtures/0202-nameserver-bad4.installfile
@@ -0,0 +1,6 @@
+network false
+hostname test.machine
+pkginstall adelie-base
+rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/
+mount /dev/sda1 /
+nameserver 9.9.9.10.123
diff --git a/tests/fixtures/0203-nameserver-bad6.installfile b/tests/fixtures/0203-nameserver-bad6.installfile
new file mode 100644
index 0000000..365b070
--- /dev/null
+++ b/tests/fixtures/0203-nameserver-bad6.installfile
@@ -0,0 +1,6 @@
+network false
+hostname test.machine
+pkginstall adelie-base
+rootpw $6$gumtLGmHwOVIRpQR$2M9PUO24hy5mofzWWf9a.YLbzOgOlUby1g0hDj.wG67E2wrrvys59fq02PPdxBdbgkLZFtjfEx6MHZwMBamwu/
+mount /dev/sda1 /
+nameserver 2620:fe::10::10::10
diff --git a/tests/spec/simulator_spec.rb b/tests/spec/simulator_spec.rb
index be684a1..e5eeb52 100644
--- a/tests/spec/simulator_spec.rb
+++ b/tests/spec/simulator_spec.rb
@@ -179,6 +179,7 @@ printf '%s\\t%s\\t%s\\t%s\\t0\\t0\\n' /dev/gwyn/source /usr/src auto noatime >>
run_simulate
expect(last_command_started.stdout).to_not include ("/target/etc/init.d/net")
end
+ # Runner.Execute.netaddress.OpenRC
it "performs OpenRC configuration when netifrc is installed" do
use_fixture '0200-netaddress-openrc.installfile'
run_simulate
@@ -228,6 +229,7 @@ printf '%s\\t%s\\t%s\\t%s\\t0\\t0\\n' /dev/gwyn/source /usr/src auto noatime >>
end
end
context "simulating 'language' execution" do
+ # Runner.Execute.language
it "doesn't configure language by default" do
use_fixture '0001-basic.installfile'
run_simulate
@@ -246,6 +248,7 @@ printf '%s\\t%s\\t%s\\t%s\\t0\\t0\\n' /dev/gwyn/source /usr/src auto noatime >>
end
end
context "simulating 'keymap' execution" do
+ # Runner.Execute.keymap
it "configures the system keymap correctly" do
use_fixture '0178-keymap-basic.installfile'
run_simulate
@@ -253,11 +256,13 @@ printf '%s\\t%s\\t%s\\t%s\\t0\\t0\\n' /dev/gwyn/source /usr/src auto noatime >>
end
end
context "simulating 'timezone' execution" do
+ # Runner.Execute.timezone.Missing
it "configures UTC by default" do
use_fixture '0001-basic.installfile'
run_simulate
expect(last_command_started.stdout).to include("ln -s /usr/share/zoneinfo/UTC /target/etc/localtime")
end
+ # Runner.Execute.timezone
it "configures the system timezone correctly" do
use_fixture '0134-timezone-subtz.installfile'
run_simulate
diff --git a/tests/spec/validator_spec.rb b/tests/spec/validator_spec.rb
index e950a97..a0b67df 100644
--- a/tests/spec/validator_spec.rb
+++ b/tests/spec/validator_spec.rb
@@ -220,6 +220,21 @@ RSpec.describe 'HorizonScript validation', :type => :aruba do
run_validate
expect(last_command_started).to have_output(/nameserver.*brackets/)
end
+ it "warns with more than MAXNS nameservers" do
+ use_fixture '0201-nameserver-max.installfile'
+ run_validate
+ expect(last_command_started).to have_output(/warning: .*nameserver.*more/)
+ end
+ it "fails with an invalid IPv4 address" do
+ use_fixture '0202-nameserver-bad4.installfile'
+ run_validate
+ expect(last_command_started).to have_output(/error: .*nameserver.*valid IPv4/)
+ end
+ it "fails with an invalid IPv6 address" do
+ use_fixture '0203-nameserver-bad6.installfile'
+ run_validate
+ expect(last_command_started).to have_output(/error: .*nameserver.*valid IPv6/)
+ end
end
context "for 'firmware' key" do
it "always supports 'false' value" do