summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/network_cli
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/network_cli')
-rw-r--r--test/integration/targets/network_cli/aliases3
-rw-r--r--test/integration/targets/network_cli/passworded_user.yml14
-rwxr-xr-xtest/integration/targets/network_cli/runme.sh27
-rw-r--r--test/integration/targets/network_cli/setup.yml14
-rw-r--r--test/integration/targets/network_cli/teardown.yml14
5 files changed, 72 insertions, 0 deletions
diff --git a/test/integration/targets/network_cli/aliases b/test/integration/targets/network_cli/aliases
new file mode 100644
index 0000000..6a739c9
--- /dev/null
+++ b/test/integration/targets/network_cli/aliases
@@ -0,0 +1,3 @@
+# Keeping incidental for efficiency, to avoid spinning up another VM
+shippable/vyos/incidental
+network/vyos
diff --git a/test/integration/targets/network_cli/passworded_user.yml b/test/integration/targets/network_cli/passworded_user.yml
new file mode 100644
index 0000000..5538684
--- /dev/null
+++ b/test/integration/targets/network_cli/passworded_user.yml
@@ -0,0 +1,14 @@
+- hosts: vyos
+ gather_facts: false
+
+ tasks:
+ - name: Run whoami
+ vyos.vyos.vyos_command:
+ commands:
+ - whoami
+ register: whoami
+
+ - assert:
+ that:
+ - whoami is successful
+ - whoami.stdout_lines[0][0] == 'atester'
diff --git a/test/integration/targets/network_cli/runme.sh b/test/integration/targets/network_cli/runme.sh
new file mode 100755
index 0000000..156674f
--- /dev/null
+++ b/test/integration/targets/network_cli/runme.sh
@@ -0,0 +1,27 @@
+#!/usr/bin/env bash
+set -eux
+export ANSIBLE_ROLES_PATH=../
+
+function cleanup {
+ ansible-playbook teardown.yml -i "$INVENTORY_PATH" "$@"
+}
+
+trap cleanup EXIT
+
+ansible-playbook setup.yml -i "$INVENTORY_PATH" "$@"
+
+# We need a nonempty file to override key with (empty file gives a
+# lovely "list index out of range" error)
+foo=$(mktemp)
+echo hello > "$foo"
+
+# We want to ensure that passwords make it to the network connection plugins
+# because they follow a different path than the rest of the codebase.
+# In setup.yml, we create a passworded user, and now we connect as that user
+# to make sure the password we pass here successfully makes it to the plugin.
+ansible-playbook \
+ -i "$INVENTORY_PATH" \
+ -e ansible_user=atester \
+ -e ansible_password=testymctest \
+ -e ansible_ssh_private_key_file="$foo" \
+ passworded_user.yml
diff --git a/test/integration/targets/network_cli/setup.yml b/test/integration/targets/network_cli/setup.yml
new file mode 100644
index 0000000..d862406
--- /dev/null
+++ b/test/integration/targets/network_cli/setup.yml
@@ -0,0 +1,14 @@
+- hosts: vyos
+ connection: ansible.netcommon.network_cli
+ become: true
+ gather_facts: false
+
+ tasks:
+ - name: Create user with password
+ register: result
+ vyos.vyos.vyos_config:
+ lines:
+ - set system login user atester full-name "Ansible Tester"
+ - set system login user atester authentication plaintext-password testymctest
+ - set system login user jsmith level admin
+ - delete service ssh disable-password-authentication
diff --git a/test/integration/targets/network_cli/teardown.yml b/test/integration/targets/network_cli/teardown.yml
new file mode 100644
index 0000000..c47f3e8
--- /dev/null
+++ b/test/integration/targets/network_cli/teardown.yml
@@ -0,0 +1,14 @@
+- hosts: vyos
+ connection: ansible.netcommon.network_cli
+ become: true
+ gather_facts: false
+
+ tasks:
+ - name: Get rid of user (undo everything from setup.yml)
+ register: result
+ vyos.vyos.vyos_config:
+ lines:
+ - delete system login user atester full-name "Ansible Tester"
+ - delete system login user atester authentication plaintext-password testymctest
+ - delete system login user jsmith level admin
+ - set service ssh disable-password-authentication