-
Notifications
You must be signed in to change notification settings - Fork 23.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable integration tests for the crypto/ namespace
Crypto namespace contains the openssl modules. It has no integration testing as of now. This commits aims to add integration tests for the crypto namespace. This will make it easier to spot breaking changes in the future. This tests currently apply to: * openssl_privatekey * openssl_publickey * openssl_csr
- Loading branch information
Showing
20 changed files
with
152 additions
and
14 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
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
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
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 @@ | ||
posix/ci/group1 |
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 @@ | ||
dependencies: | ||
- setup_openssl |
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,11 @@ | ||
- name: Generate privatekey | ||
openssl_privatekey: | ||
path: '{{ output_dir }}/privatekey.pem' | ||
|
||
- name: Generate CSR | ||
openssl_csr: | ||
path: '{{ output_dir }}/csr.csr' | ||
privatekey_path: '{{ output_dir }}/privatekey.pem' | ||
commonName: 'www.ansible.com' | ||
|
||
- import_tasks: ../tests/validate.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,17 @@ | ||
- name: Validate CSR (test - privatekey modulus) | ||
shell: 'openssl rsa -noout -modulus -in {{ output_dir }}/privatekey.pem | openssl md5' | ||
register: privatekey_modulus | ||
|
||
- name: Validate CSR (test - Common Name) | ||
shell: "openssl req -noout -subject -in {{ output_dir }}/csr.csr -nameopt oneline,-space_eq" | ||
register: csr_cn | ||
|
||
- name: Validate CSR (test - csr modulus) | ||
shell: 'openssl req -noout -modulus -in {{ output_dir }}/csr.csr | openssl md5' | ||
register: csr_modulus | ||
|
||
- name: Validate CSR (assert) | ||
assert: | ||
that: | ||
- csr_cn.stdout.split('=')[-1] == 'www.ansible.com' | ||
- csr_modulus.stdout == privatekey_modulus.stdout |
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 @@ | ||
posix/ci/group1 |
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 @@ | ||
dependencies: | ||
- setup_openssl |
15 changes: 15 additions & 0 deletions
15
test/integration/targets/openssl_privatekey/tasks/main.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,15 @@ | ||
- name: Generate privatekey1 - standard | ||
openssl_privatekey: | ||
path: '{{ output_dir }}/privatekey1.pem' | ||
|
||
- name: Generate privatekey2 - size 2048 | ||
openssl_privatekey: | ||
path: '{{ output_dir }}/privatekey2.pem' | ||
size: 2048 | ||
|
||
- name: Generate privatekey3 - type DSA | ||
openssl_privatekey: | ||
path: '{{ output_dir }}/privatekey3.pem' | ||
type: DSA | ||
|
||
- import_tasks: ../tests/validate.yml |
28 changes: 28 additions & 0 deletions
28
test/integration/targets/openssl_privatekey/tests/validate.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,28 @@ | ||
- name: Validate privatekey1 (test) | ||
shell: "openssl rsa -noout -text -in {{ output_dir }}/privatekey1.pem | grep Private | sed 's/Private-Key: (\\(.*\\) bit)/\\1/'" | ||
register: privatekey1 | ||
|
||
- name: Validate privatekey1 (assert) | ||
assert: | ||
that: | ||
- privatekey1.stdout == '4096' | ||
|
||
|
||
- name: Validate privatekey2 (test) | ||
shell: "openssl rsa -noout -text -in {{ output_dir }}/privatekey2.pem | grep Private | sed 's/Private-Key: (\\(.*\\) bit)/\\1/'" | ||
register: privatekey2 | ||
|
||
- name: Validate privatekey2 (assert) | ||
assert: | ||
that: | ||
- privatekey2.stdout == '2048' | ||
|
||
|
||
- name: Validate privatekey3 (test) | ||
shell: "openssl dsa -noout -text -in {{ output_dir }}/privatekey3.pem | grep Private | sed 's/Private-Key: (\\(.*\\) bit)/\\1/'" | ||
register: privatekey3 | ||
|
||
- name: Validate privatekey3 (assert) | ||
assert: | ||
that: | ||
- privatekey1.stdout == '4096' |
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 @@ | ||
posix/ci/group1 |
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 @@ | ||
dependencies: | ||
- setup_openssl |
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,13 @@ | ||
- block: | ||
- name: Generate privatekey | ||
openssl_privatekey: | ||
path: '{{ output_dir }}/privatekey.pem' | ||
|
||
- name: Generate publickey | ||
openssl_publickey: | ||
path: '{{ output_dir }}/publickey.pub' | ||
privatekey_path: '{{ output_dir }}/privatekey.pem' | ||
|
||
- import_tasks: ../tests/validate.yml | ||
|
||
when: pyopenssl_version.stdout|version_compare('16.0.0', '>=') |
12 changes: 12 additions & 0 deletions
12
test/integration/targets/openssl_publickey/tests/validate.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,12 @@ | ||
- name: Validate public key (test - privatekey modulus) | ||
shell: 'openssl rsa -noout -modulus -in {{ output_dir }}/privatekey.pem | openssl md5' | ||
register: privatekey_modulus | ||
|
||
- name: Validate public key (test - publickey modulus) | ||
shell: 'openssl rsa -pubin -noout -modulus < {{ output_dir }}/publickey.pub | openssl md5' | ||
register: publickey_modulus | ||
|
||
- name: Validate public key (assert) | ||
assert: | ||
that: | ||
- publickey_modulus.stdout == privatekey_modulus.stdout |
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,25 @@ | ||
- name: Incluse OS-specific variables | ||
include_vars: '{{ ansible_os_family }}.yml' | ||
when: not ansible_os_family == "Darwin" | ||
|
||
- name: Install pyOpenSSL | ||
become: True | ||
package: | ||
name: '{{ pyopenssl_package_name_python3 }}' | ||
when: not ansible_os_family == 'Darwin' and ansible_python_version|version_compare('3.0', '>=') | ||
|
||
- name: Install pyOpenSSL | ||
become: True | ||
package: | ||
name: '{{ pyopenssl_package_name }}' | ||
when: not ansible_os_family == 'Darwin' and ansible_python_version|version_compare('3.0', '<') | ||
|
||
- name: Install pyOpenSSL | ||
become: True | ||
pip: | ||
name: pyOpenSSL | ||
when: ansible_os_family == 'Darwin' | ||
|
||
- name: register openssl version | ||
command: python -c 'import OpenSSL; print(OpenSSL.__version__)' | ||
register: pyopenssl_version |
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 @@ | ||
pyopenssl_package_name: python-openssl | ||
pyopenssl_package_name_python3: python3-openssl |
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 @@ | ||
pyopenssl_package_name: py27-openssl |
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 @@ | ||
pyopenssl_package_name: pyOpenSSL |
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 @@ | ||
pyopenssl_package_name: python-pyOpenSSL |