-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ansible changes for Image Verification and GPG key installation (#380)
* Ansible changes for Image Verification * add fragments * resolve build issues * resolve pep8 issues * resolve pep8 issues * code coverage fix * version changes * update log * Update 380-sonic-image-verification.yaml * fix pylint issue * Update lldp_global.py * Address comments * Address comments * address comments * address comments * modify image name
- Loading branch information
1 parent
e500d90
commit 14a07d4
Showing
7 changed files
with
392 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minor_changes: | ||
- sonic_image_management - Add support for image GPG Key installation and verification feature in sonic_image_management module (https://github.com/ansible-collections/dellemc.enterprise_sonic/pull/380). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
tests/regression/roles/sonic_image_management/tasks/image_gpg.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
- name: Test case - image gpg-key - Installs GPG key | ||
dellemc.enterprise_sonic.sonic_image_management: | ||
image: | ||
command: 'gpg-key' | ||
keyserver: 'hkp://keyserver.ubuntu.com:80' | ||
pubkeyid: 'DC6E36CC7FDA043B' | ||
register: result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.failed == false | ||
- result.status is defined | ||
- result.status == 'Installed public GPG key successfully.' | ||
register: assert_result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.include_tasks: image_management.test.facts.report.yml | ||
vars: | ||
test_case_name: 'image_gpg_key_01' | ||
test_case_input: | ||
image: | ||
command: 'gpg-key' | ||
keyserver: 'hkp://keyserver.ubuntu.com:80' | ||
pubkeyid: 'DC6E36CC7FDA043B' | ||
|
||
- name: Test case - image gpg-key - Installs GPG key | ||
dellemc.enterprise_sonic.sonic_image_management: | ||
image: | ||
command: 'gpg-key' | ||
keyserver: 'hkp://keyserver.ubuntu.com:80' | ||
pubkeyid: 'DC6E36CC7FDA043A' | ||
register: result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.set_fact: | ||
result_msg: "{{ result.msg | from_yaml }}" | ||
when: result.msg is defined | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.failed == true | ||
- result.msg is defined | ||
- result_msg['code'] == 400 | ||
- result_msg['ietf-restconf:errors']['error'][0]['error-type'] == 'application' | ||
- result_msg['ietf-restconf:errors']['error'][0]['error-tag'] == 'invalid-value' | ||
register: assert_result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.include_tasks: image_management.test.facts.report.yml | ||
vars: | ||
test_case_name: 'image_gpg_key_02' | ||
test_case_input: | ||
image: | ||
command: 'gpg-key' | ||
keyserver: 'hkp://keyserver.ubuntu.com:80' | ||
pubkeyid: 'DC6E36CC7FDA043A' |
130 changes: 130 additions & 0 deletions
130
tests/regression/roles/sonic_image_management/tasks/image_verify.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
--- | ||
- name: Test case - image verify - Verifies image using GPG-01 | ||
dellemc.enterprise_sonic.sonic_image_management: | ||
image: | ||
command: 'verify' | ||
verifymethod: 'gpg' | ||
path: 'home://sonic-verify.bin' | ||
signaturefile: 'home://sign.gpg' | ||
register: result | ||
ignore_errors: yes | ||
|
||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.failed == false | ||
- result.status is defined | ||
- result.status == 'GPG validation succeeded.' | ||
register: assert_result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.include_tasks: image_management.test.facts.report.yml | ||
vars: | ||
test_case_name: 'image_verify_gpg_01' | ||
test_case_input: | ||
image: | ||
command: 'verify' | ||
verifymethod: 'gpg' | ||
path: 'home://sonic-verify.bin' | ||
signaturefile: 'home://sign.gpg' | ||
|
||
- name: Test case - image verify - Verifies image using GPG-02 | ||
dellemc.enterprise_sonic.sonic_image_management: | ||
image: | ||
command: 'verify' | ||
verifymethod: 'gpg' | ||
path: 'home://sonic-verify.bin' | ||
signaturefile: 'home://sign.sig' | ||
register: result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.set_fact: | ||
result_msg: "{{ result.msg | from_yaml }}" | ||
when: result.msg is defined | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.failed == true | ||
- result.msg is defined | ||
- result_msg['code'] == 400 | ||
- result_msg['ietf-restconf:errors']['error'][0]['error-type'] == 'application' | ||
- result_msg['ietf-restconf:errors']['error'][0]['error-tag'] == 'invalid-value' | ||
register: assert_result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.include_tasks: image_management.test.facts.report.yml | ||
vars: | ||
test_case_name: 'image_verify_gpg_02' | ||
test_case_input: | ||
image: | ||
command: 'verify' | ||
verifymethod: 'gpg' | ||
path: 'home://sonic-verify.bin' | ||
signaturefile: 'home://sign.sig' | ||
|
||
- name: Test case - image verify - Verifies image using PKI | ||
dellemc.enterprise_sonic.sonic_image_management: | ||
image: | ||
command: 'verify' | ||
verifymethod: 'pki' | ||
path: 'home://sonic-verify.bin' | ||
signaturefile: 'home://sign.sig' | ||
pubkeyfilename: 'home://DellOS10.cert.pem' | ||
register: result | ||
ignore_errors: yes | ||
|
||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.failed == false | ||
- result.status is defined | ||
- result.status == 'PKI validation succeeded.' | ||
register: assert_result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.include_tasks: image_management.test.facts.report.yml | ||
vars: | ||
test_case_name: 'image_verify_pki_01' | ||
test_case_input: | ||
image: | ||
command: 'verify' | ||
verifymethod: 'pki' | ||
path: 'home://sonic-verify.bin' | ||
signaturefile: 'home://sign.sig' | ||
pubkeyfilename: 'home://DellOS10.cert.pem' | ||
|
||
- name: Test case - image verify - Verifies image using PKI | ||
dellemc.enterprise_sonic.sonic_image_management: | ||
image: | ||
command: 'verify' | ||
verifymethod: 'pki' | ||
path: 'home://sonic-verify.bin' | ||
signaturefile: 'home://sign.gpg' | ||
pubkeyfilename: 'home://DellOS10.cert.pem' | ||
register: result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.set_fact: | ||
result_msg: "{{ result.msg | from_yaml }}" | ||
when: result.msg is defined | ||
|
||
- ansible.builtin.assert: | ||
that: | ||
- result.failed == true | ||
- result.msg is defined | ||
- result_msg['code'] == 400 | ||
- result_msg['ietf-restconf:errors']['error'][0]['error-type'] == 'application' | ||
- result_msg['ietf-restconf:errors']['error'][0]['error-tag'] == 'invalid-value' | ||
register: assert_result | ||
ignore_errors: yes | ||
|
||
- ansible.builtin.include_tasks: image_management.test.facts.report.yml | ||
vars: | ||
test_case_name: 'image_verify_pki_02' | ||
test_case_input: | ||
image: | ||
command: 'verify' | ||
verifymethod: 'pki' | ||
path: 'home://sonic-verify.bin' | ||
signaturefile: 'home://sign.gpg' | ||
pubkeyfilename: 'home://DellOS10.cert.pem' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.