|  | 
|  | 1 | +--- | 
|  | 2 | + | 
|  | 3 | +# Copyright 2023 Cloudera, Inc. All Rights Reserved. | 
|  | 4 | +# | 
|  | 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 6 | +# you may not use this file except in compliance with the License. | 
|  | 7 | +# You may obtain a copy of the License at | 
|  | 8 | +# | 
|  | 9 | +#      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 10 | +# | 
|  | 11 | +# Unless required by applicable law or agreed to in writing, software | 
|  | 12 | +# distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 14 | +# See the License for the specific language governing permissions and | 
|  | 15 | +# limitations under the License. | 
|  | 16 | + | 
|  | 17 | +- name: Describe Credential | 
|  | 18 | +  cloudera.cloud.env_cred_info: | 
|  | 19 | +    name: "{{ xaccount }}" | 
|  | 20 | +  register: __cred | 
|  | 21 | + | 
|  | 22 | +- name: Test for Credential existence | 
|  | 23 | +  ansible.builtin.assert: | 
|  | 24 | +    that: __cred.credentials | length == 0 | 
|  | 25 | +    fail_msg: "Test credential already exists: {{ xaccount }}" | 
|  | 26 | + | 
|  | 27 | +- name: Construct a Credential | 
|  | 28 | +  cloudera.cloud.env_cred: | 
|  | 29 | +    name: "{{ xaccount }}" | 
|  | 30 | +    cloud: "{{ network.type }}" | 
|  | 31 | +    role: "{{ identity.xaccount_role }}" | 
|  | 32 | +    description: "Integration test" | 
|  | 33 | +  register: __cred | 
|  | 34 | + | 
|  | 35 | +- name: Test for Credential creation | 
|  | 36 | +  ansible.builtin.assert: | 
|  | 37 | +    that: | 
|  | 38 | +      - __cred.credential | length > 0 | 
|  | 39 | +      - __cred.credential.cloudPlatform == (network.type | upper) | 
|  | 40 | +      - __cred.credential.credentialName == xaccount | 
|  | 41 | + | 
|  | 42 | +- name: Test idempotent creation of a Credential | 
|  | 43 | +  cloudera.cloud.env_cred: | 
|  | 44 | +    name: "{{ xaccount }}" | 
|  | 45 | +    cloud: "{{ network.type }}" | 
|  | 46 | +    role: "{{ identity.xaccount_role }}" | 
|  | 47 | +    description: "Integration test" | 
|  | 48 | +  register: __cred_idempotent | 
|  | 49 | + | 
|  | 50 | +- name: Test for Credential idempotent state | 
|  | 51 | +  ansible.builtin.assert: | 
|  | 52 | +    that: | 
|  | 53 | +      - __cred_idempotent.credential | length > 0 | 
|  | 54 | +      - __cred.credential.crn == __cred_idempotent.credential.crn | 
|  | 55 | +      - not __cred_idempotent.changed | 
|  | 56 | + | 
|  | 57 | +- name: Destroy Credential | 
|  | 58 | +  cloudera.cloud.env_cred: | 
|  | 59 | +    name: "{{ xaccount }}" | 
|  | 60 | +    state: absent | 
|  | 61 | +  register: __cred | 
|  | 62 | + | 
|  | 63 | +- name: Describe Credential after destruction | 
|  | 64 | +  cloudera.cloud.env_cred_info: | 
|  | 65 | +    name: "{{ xaccount }}" | 
|  | 66 | +  register: __cred | 
|  | 67 | + | 
|  | 68 | +- name: Test for Credential existence | 
|  | 69 | +  ansible.builtin.assert: | 
|  | 70 | +    that: __cred.credentials | length == 0 | 
0 commit comments