summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/apt_key/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/apt_key/tasks')
-rw-r--r--test/integration/targets/apt_key/tasks/apt_key.yml25
-rw-r--r--test/integration/targets/apt_key/tasks/apt_key_binary.yml12
-rw-r--r--test/integration/targets/apt_key/tasks/apt_key_inline_data.yml5
-rw-r--r--test/integration/targets/apt_key/tasks/file.yml52
-rw-r--r--test/integration/targets/apt_key/tasks/main.yml29
5 files changed, 123 insertions, 0 deletions
diff --git a/test/integration/targets/apt_key/tasks/apt_key.yml b/test/integration/targets/apt_key/tasks/apt_key.yml
new file mode 100644
index 0000000..0e01723
--- /dev/null
+++ b/test/integration/targets/apt_key/tasks/apt_key.yml
@@ -0,0 +1,25 @@
+- name: Ensure key is not there to start with.
+ apt_key:
+ id: 36A1D7869245C8950F966E92D8576A8BA88D21E9
+ state: absent
+
+- name: run first docs example
+ apt_key:
+ keyserver: keyserver.ubuntu.com
+ id: 36A1D7869245C8950F966E92D8576A8BA88D21E9
+ register: apt_key_test0
+
+- debug: var=apt_key_test0
+
+- name: re-run first docs example
+ apt_key:
+ keyserver: keyserver.ubuntu.com
+ id: 36A1D7869245C8950F966E92D8576A8BA88D21E9
+ register: apt_key_test1
+
+- name: validate results
+ assert:
+ that:
+ - 'apt_key_test0.changed is defined'
+ - 'apt_key_test0.changed'
+ - 'not apt_key_test1.changed'
diff --git a/test/integration/targets/apt_key/tasks/apt_key_binary.yml b/test/integration/targets/apt_key/tasks/apt_key_binary.yml
new file mode 100644
index 0000000..b120bd5
--- /dev/null
+++ b/test/integration/targets/apt_key/tasks/apt_key_binary.yml
@@ -0,0 +1,12 @@
+---
+
+- name: Ensure import of binary key downloaded using URLs works
+ apt_key:
+ url: https://ci-files.testing.ansible.com/test/integration/targets/apt_key/apt-key-example-binary.gpg
+ register: apt_key_binary_test
+
+- name: Validate the results
+ assert:
+ that:
+ - 'apt_key_binary_test.changed is defined'
+ - 'apt_key_binary_test.changed'
diff --git a/test/integration/targets/apt_key/tasks/apt_key_inline_data.yml b/test/integration/targets/apt_key/tasks/apt_key_inline_data.yml
new file mode 100644
index 0000000..916fa5a
--- /dev/null
+++ b/test/integration/targets/apt_key/tasks/apt_key_inline_data.yml
@@ -0,0 +1,5 @@
+- name: "Ensure import of a deliberately corrupted downloaded GnuPG binary key results in an 'inline data' occurence in the message"
+ apt_key:
+ url: https://ci-files.testing.ansible.com/test/integration/targets/apt_key/apt-key-corrupt-zeros-2k.gpg
+ register: gpg_inline_result
+ failed_when: "not ('inline data' in gpg_inline_result.msg)"
diff --git a/test/integration/targets/apt_key/tasks/file.yml b/test/integration/targets/apt_key/tasks/file.yml
new file mode 100644
index 0000000..c22f3a4
--- /dev/null
+++ b/test/integration/targets/apt_key/tasks/file.yml
@@ -0,0 +1,52 @@
+- name: Get Fedora GPG Key
+ get_url:
+ url: https://ci-files.testing.ansible.com/test/integration/targets/apt_key/fedora.gpg
+ dest: /tmp/fedora.gpg
+
+- name: Ensure clean slate
+ apt_key:
+ id: 1161AE6945719A39
+ state: absent
+
+- name: Run apt_key with both file and keyserver
+ apt_key:
+ file: /tmp/fedora.gpg
+ keyserver: keys.gnupg.net
+ id: 97A1AE57C3A2372CCA3A4ABA6C13026D12C944D0
+ register: both_file_keyserver
+ ignore_errors: true
+
+- name: Run apt_key with file only
+ apt_key:
+ file: /tmp/fedora.gpg
+ register: only_file
+
+- name: Run apt_key with keyserver only
+ apt_key:
+ keyserver: keys.gnupg.net
+ id: 97A1AE57C3A2372CCA3A4ABA6C13026D12C944D0
+ register: only_keyserver
+
+- name: validate results
+ assert:
+ that:
+ - 'both_file_keyserver is failed'
+ - 'only_file.changed'
+ - 'not only_keyserver.changed'
+
+- name: remove fedora.gpg
+ apt_key:
+ id: 1161AE6945719A39
+ state: absent
+ register: remove_fedora
+
+- name: add key from url
+ apt_key:
+ url: https://ci-files.testing.ansible.com/test/integration/targets/apt_key/fedora.gpg
+ register: apt_key_url
+
+- name: verify key from url
+ assert:
+ that:
+ - remove_fedora is changed
+ - apt_key_url is changed
diff --git a/test/integration/targets/apt_key/tasks/main.yml b/test/integration/targets/apt_key/tasks/main.yml
new file mode 100644
index 0000000..ffb89b2
--- /dev/null
+++ b/test/integration/targets/apt_key/tasks/main.yml
@@ -0,0 +1,29 @@
+# Test code for the apt_key module.
+# (c) 2017, James Tanner <tanner.jc@gmail.com>
+
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+- import_tasks: 'apt_key.yml'
+ when: ansible_distribution in ('Ubuntu', 'Debian')
+
+- import_tasks: 'apt_key_inline_data.yml'
+ when: ansible_distribution in ('Ubuntu', 'Debian')
+
+- import_tasks: 'file.yml'
+ when: ansible_distribution in ('Ubuntu', 'Debian')
+
+- import_tasks: 'apt_key_binary.yml'
+ when: ansible_distribution in ('Ubuntu', 'Debian')