summaryrefslogtreecommitdiff
path: root/test/integration/targets/gcp_kms_crypto_key/tasks/autogen.yml
diff options
context:
space:
mode:
authorThe Magician <magic-modules@google.com>2019-10-01 15:27:03 -0700
committeransibot <ansibot@users.noreply.github.com>2019-10-01 18:27:03 -0400
commitb4d15b3040e22c88b8e508ad45a61609a2933542 (patch)
tree120b86cd21e08121c34bc9d249e24fcb3cbd647a /test/integration/targets/gcp_kms_crypto_key/tasks/autogen.yml
parentecc47b653b282efe975459514ca1236e582fabb7 (diff)
downloadansible-b4d15b3040e22c88b8e508ad45a61609a2933542.tar.gz
Bug fixes for GCP modules (#61917)
Diffstat (limited to 'test/integration/targets/gcp_kms_crypto_key/tasks/autogen.yml')
-rw-r--r--test/integration/targets/gcp_kms_crypto_key/tasks/autogen.yml73
1 files changed, 73 insertions, 0 deletions
diff --git a/test/integration/targets/gcp_kms_crypto_key/tasks/autogen.yml b/test/integration/targets/gcp_kms_crypto_key/tasks/autogen.yml
new file mode 100644
index 0000000000..ef2252c863
--- /dev/null
+++ b/test/integration/targets/gcp_kms_crypto_key/tasks/autogen.yml
@@ -0,0 +1,73 @@
+# Copyright 2019 Google Inc.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+---
+# Pre-test setup
+- name: create a key ring
+ gcp_kms_key_ring:
+ name: key-key-ring
+ location: us-central1
+ project: "{{ gcp_project }}"
+ auth_kind: "{{ gcp_cred_kind }}"
+ service_account_file: "{{ gcp_cred_file }}"
+ state: present
+ register: keyring
+- name: delete a crypto key
+ gcp_kms_crypto_key:
+ name: "{{ resource_name }}"
+ key_ring: projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring
+ project: "{{ gcp_project }}"
+ auth_kind: "{{ gcp_cred_kind }}"
+ service_account_file: "{{ gcp_cred_file }}"
+ state: absent
+#----------------------------------------------------------
+- name: create a crypto key
+ gcp_kms_crypto_key:
+ name: "{{ resource_name }}"
+ key_ring: projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring
+ project: "{{ gcp_project }}"
+ auth_kind: "{{ gcp_cred_kind }}"
+ service_account_file: "{{ gcp_cred_file }}"
+ state: present
+ register: result
+- name: assert changed is true
+ assert:
+ that:
+ - result.changed == true
+- name: verify that crypto_key was created
+ gcp_kms_crypto_key_info:
+ key_ring: "projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring"
+ project: "{{ gcp_project }}"
+ auth_kind: "{{ gcp_cred_kind }}"
+ service_account_file: "{{ gcp_cred_file }}"
+ scopes:
+ - https://www.googleapis.com/auth/cloudkms
+ register: results
+- name: verify that command succeeded
+ assert:
+ that:
+ - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1
+# ----------------------------------------------------------------------------
+- name: create a crypto key that already exists
+ gcp_kms_crypto_key:
+ name: "{{ resource_name }}"
+ key_ring: projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring
+ project: "{{ gcp_project }}"
+ auth_kind: "{{ gcp_cred_kind }}"
+ service_account_file: "{{ gcp_cred_file }}"
+ state: present
+ register: result
+- name: assert changed is false
+ assert:
+ that:
+ - result.changed == false