From b89d2b13160c78869114d88169a8ab008be53042 Mon Sep 17 00:00:00 2001
From: Rafael Guterres Jeffman <rjeffman@redhat.com>
Date: Thu, 20 Jan 2022 14:33:40 -0300
Subject: [PATCH] automountmap: Add client context test playbook.

The client context test playbook was missing for ipaautomountmap.
---
 tests/automount/test_automountmap.yml         |  2 +-
 .../test_automountmap_client_context.yml      | 40 +++++++++++++++++++
 2 files changed, 41 insertions(+), 1 deletion(-)
 create mode 100644 tests/automount/test_automountmap_client_context.yml

diff --git a/tests/automount/test_automountmap.yml b/tests/automount/test_automountmap.yml
index cbf5db40..da542e89 100644
--- a/tests/automount/test_automountmap.yml
+++ b/tests/automount/test_automountmap.yml
@@ -1,6 +1,6 @@
 ---
 - name: Test automountmap
-  hosts: ipaserver
+  hosts: "{{ ipa_test_host | default('ipaserver') }}"
   become: no
   gather_facts: no
 
diff --git a/tests/automount/test_automountmap_client_context.yml b/tests/automount/test_automountmap_client_context.yml
new file mode 100644
index 00000000..cec2271d
--- /dev/null
+++ b/tests/automount/test_automountmap_client_context.yml
@@ -0,0 +1,40 @@
+---
+- name: Test automountmap
+  hosts: ipaclients, ipaserver
+  become: no
+  gather_facts: no
+
+  tasks:
+  - name: Include FreeIPA facts.
+    include_tasks: ../env_freeipa_facts.yml
+
+  # Test will only be executed if host is not a server.
+  - name: Execute with server context in the client.
+    ipaautomountmap:
+      ipaadmin_password: SomeADMINpassword
+      ipaapi_context: server
+      location: default
+      name: ThisShouldNotWork
+    register: result
+    failed_when: not (result.failed and result.msg is regex("No module named '*ipaserver'*"))
+    when: ipa_host_is_client
+
+# Import basic module tests, and execute with ipa_context set to 'client'.
+# If ipaclients is set, it will be executed using the client, if not,
+# ipaserver will be used.
+#
+# With this setup, tests can be executed against an IPA client, against
+# an IPA server using "client" context, and ensure that tests are executed
+# in upstream CI.
+
+- name: Test automountmap using client context, in client host.
+  import_playbook: test_automountmap.yml
+  when: groups['ipaclients']
+  vars:
+    ipa_test_host: ipaclients
+
+- name: Test automountmap using client context, in server host.
+  import_playbook: test_automountmap.yml
+  when: groups['ipaclients'] is not defined or not groups['ipaclients']
+  vars:
+    ipa_context: client
-- 
GitLab