From b4d15b3040e22c88b8e508ad45a61609a2933542 Mon Sep 17 00:00:00 2001 From: The Magician Date: Tue, 1 Oct 2019 15:27:03 -0700 Subject: Bug fixes for GCP modules (#61917) --- .../targets/gcp_kms_crypto_key/tasks/autogen.yml | 73 ++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 test/integration/targets/gcp_kms_crypto_key/tasks/autogen.yml (limited to 'test/integration/targets/gcp_kms_crypto_key/tasks/autogen.yml') 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 -- cgit v1.2.1