Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/jenkins_credential/tasks/edit.yml

raw
1 # Copyright (c) Ansible Project
2 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
3 # SPDX-License-Identifier: GPL-3.0-or-later
4
5 - name: Generate token
6 community.general.jenkins_credential:
7 id: "{{ tokenUuid}}"
8 name: "test-token-2"
9 jenkins_user: "{{ jenkins_username }}"
10 jenkins_password: "{{ jenkins_password }}"
11 type: "token"
12 force: true
13 register: token_result
14
15 - name: Set token in vars
16 set_fact:
17 token: "{{ token_result.token }}"
18 tokenUuid: "{{ token_result.token_uuid }}"
19
20 - name: Edit CUSTOM scope credential
21 community.general.jenkins_credential:
22 id: "CUSTOM"
23 type: "scope"
24 jenkins_user: "{{ jenkins_username }}"
25 token: "{{ token }}"
26 description: "New custom scope credential"
27 inc_path:
28 - "new_include/path"
29 - "new_include/path2"
30 exc_path:
31 - "new_exclude/path"
32 - "new_exclude/path2"
33 inc_hostname:
34 - "new_included-hostname"
35 - "new_included-hostname2"
36 exc_hostname:
37 - "new_excluded-hostname"
38 - "new_excluded-hostname2"
39 schemes:
40 - "new_http"
41 - "new_https"
42 inc_hostname_port:
43 - "new_included-hostname:7000"
44 - "new_included-hostname2:7000"
45 exc_hostname_port:
46 - "new_excluded-hostname:7000"
47 - "new_excluded-hostname2:7000"
48 force: true
49 register: custom_scope
50
51 - name: Assert CUSTOM scope changed value
52 assert:
53 that:
54 - custom_scope.changed == true
55 fail_msg: "CUSTOM scope changed status when it shouldn't"
56 success_msg: "CUSTOM scope behaved correctly"
57
58 - name: Edit user_and_pass credential
59 community.general.jenkins_credential:
60 id: "userpass-id"
61 type: "user_and_pass"
62 jenkins_user: "{{ jenkins_username }}"
63 token: "{{ token }}"
64 description: "new user and password credential"
65 username: "user2"
66 password: "pass2"
67 force: true
68 register: userpass_cred
69
70 - name: Assert user_and_pass changed value
71 assert:
72 that:
73 - userpass_cred.changed == true
74 fail_msg: "user_and_pass credential changed status incorrect"
75 success_msg: "user_and_pass credential behaved correctly"
76
77 - name: Edit file credential to custom scope
78 community.general.jenkins_credential:
79 id: "file-id"
80 type: "file"
81 jenkins_user: "{{ jenkins_username }}"
82 token: "{{ token }}"
83 scope: "CUSTOM"
84 description: "New file credential"
85 file_path: "{{ output_dir }}/my-secret.pem"
86 force: true
87 register: file_cred
88
89 - name: Assert file credential changed value
90 assert:
91 that:
92 - file_cred.changed == true
93 fail_msg: "file credential changed status incorrect"
94 success_msg: "file credential behaved correctly"
95
96 - name: Edit text credential to folder
97 community.general.jenkins_credential:
98 id: "text-id"
99 type: "text"
100 jenkins_user: "{{ jenkins_username }}"
101 token: "{{ token }}"
102 description: "New text credential"
103 secret: "mynewsecrettext"
104 location: "folder"
105 url: "http://localhost:8080/job/test"
106 force: true
107 register: text_cred
108
109 - name: Assert text credential changed value
110 assert:
111 that:
112 - text_cred.changed == true
113 fail_msg: "text credential changed status incorrect"
114 success_msg: "text credential behaved correctly"
115
116 - name: Edit githubApp credential
117 community.general.jenkins_credential:
118 id: "githubapp-id"
119 type: "github_app"
120 jenkins_user: "{{ jenkins_username }}"
121 token: "{{ token }}"
122 description: "New GitHub app credential"
123 appID: "12345678"
124 private_key_path: "{{ output_dir }}/github.pem"
125 owner: "new_github_owner"
126 force: true
127 register: githubapp_cred
128
129 - name: Assert githubApp credential changed value
130 assert:
131 that:
132 - githubapp_cred.changed == true
133 fail_msg: "githubApp credential changed status incorrect"
134 success_msg: "githubApp credential behaved correctly"
135
136 - name: Edit sshKey credential
137 community.general.jenkins_credential:
138 id: "sshkey-id"
139 type: "ssh_key"
140 jenkins_user: "{{ jenkins_username }}"
141 token: "{{ token }}"
142 description: "New SSH key credential"
143 username: "new_sshuser"
144 private_key_path: "{{ output_dir }}/ssh_key"
145 passphrase: 1234
146 force: true
147 register: sshkey_cred
148
149 - name: Assert sshKey credential changed value
150 assert:
151 that:
152 - sshkey_cred.changed == true
153 fail_msg: "sshKey credential changed status incorrect"
154 success_msg: "sshKey credential behaved correctly"
155
156 - name: Edit certificate credential (p12)
157 community.general.jenkins_credential:
158 id: "certificate-id"
159 type: "certificate"
160 jenkins_user: "{{ jenkins_username }}"
161 token: "{{ token }}"
162 description: "New certificate credential"
163 password: "12345678901234"
164 file_path: "{{ output_dir }}/certificate.p12"
165 force: true
166 register: cert_p12_cred
167
168 - name: Assert certificate (p12) credential changed value
169 assert:
170 that:
171 - cert_p12_cred.changed == true
172 fail_msg: "certificate (p12) credential changed status incorrect"
173 success_msg: "certificate (p12) credential behaved correctly"
174
175 - name: Edit certificate credential (pem)
176 community.general.jenkins_credential:
177 id: "certificate-id-pem"
178 type: "certificate"
179 jenkins_user: "{{ jenkins_username }}"
180 token: "{{ token }}"
181 description: "New certificate credential (pem)"
182 file_path: "{{ output_dir }}/cert.pem"
183 private_key_path: "{{ output_dir }}/private.key"
184 force: true
185 register: cert_pem_cred
186
187 - name: Assert certificate (pem) credential changed value
188 assert:
189 that:
190 - cert_pem_cred.changed == true
191 fail_msg: "certificate (pem) credential changed status incorrect"
192 success_msg: "certificate (pem) credential behaved correctly"