Add tests for odl user/password feature 17/73517/18
authorTaseer Ahmed <taseer94@gmail.com>
Thu, 28 Jun 2018 08:38:07 +0000 (13:38 +0500)
committerTaseer Ahmed <taseer94@gmail.com>
Wed, 18 Jul 2018 04:42:04 +0000 (09:42 +0500)
The new feature allows creating/deleting ODL users. This patchset
introduces tests to ensure everything works as expected. The tests
consists of creating and deleting the users. The verification is
done via running the CLI command and saving the output in variable.
Assertions are made whether on these variables, if the desired user
is present or absent in them.

This change also requires a new job to be added in the RelEng project.
The required RelEng patchset is:
Ib950fbb1f8952c794380af03c25f9f4987c65b73

Note: Originally cross verification via API calls was implemented.
But had to be dropped because ODL was not listening on the desired
port. This needs further debugging.

Change-Id: I702245e1456e12c5a64b4c8fe1810101edb5abce
Signed-off-by: Taseer Ahmed <taseer94@gmail.com>
tests/test-odl-users.yaml [new file with mode: 0644]
tests/vars.yaml [new file with mode: 0644]

diff --git a/tests/test-odl-users.yaml b/tests/test-odl-users.yaml
new file mode 100644 (file)
index 0000000..e258f94
--- /dev/null
@@ -0,0 +1,51 @@
+---
+
+- hosts: localhost
+  gather_facts: False
+  vars_files:
+    - vars.yaml
+  tasks:
+    - name: list initial users
+      odl_usermod:
+        state: list
+      register: init_state_users
+
+    # By default there should be an 'admin' user here
+    # However no default user in Ansible-ODL
+    # JIRA: INTPAK-193 investigates this issue
+    - name: ensure test user does not exist
+      assert:
+        that:
+          - "'init_state_users == None'"
+
+    - name: create odl user
+      odl_usermod:
+        username: "{{ test_user_username }}"
+        password: "{{ test_user_password }}"
+        state: present
+
+    - name: list users after creation
+      odl_usermod:
+        state: list
+      register: users_after_create
+
+    - name: ensure user creation
+      assert:
+        that:
+          - "'{{ test_user_username }} not None'"
+          - "'{{ test_user_username }} == users_after_create'"
+
+    - name: delete odl user
+      odl_usermod:
+        username: "{{ test_user_username }}"
+        state: absent
+
+    - name: list users after deletion
+      odl_usermod:
+        state: list
+      register: users_after_delete
+
+    - name: ensure user deletion
+      assert:
+        that:
+          - "'users_after_delete == None'"
\ No newline at end of file
diff --git a/tests/vars.yaml b/tests/vars.yaml
new file mode 100644 (file)
index 0000000..46d91d0
--- /dev/null
@@ -0,0 +1,4 @@
+---
+
+test_user_username: test_user
+test_user_password: test_pass