diff --git a/tests/integration/targets/sslcertkey/aliases b/tests/integration/targets/sslcertkey/aliases new file mode 100644 index 00000000..28a231e4 --- /dev/null +++ b/tests/integration/targets/sslcertkey/aliases @@ -0,0 +1,3 @@ +gather_facts/no +netscaler/cpx/ +netscaler/vpx/ diff --git a/tests/integration/targets/sslcertkey/tasks/main.yaml b/tests/integration/targets/sslcertkey/tasks/main.yaml new file mode 100644 index 00000000..503a9a7d --- /dev/null +++ b/tests/integration/targets/sslcertkey/tasks/main.yaml @@ -0,0 +1,141 @@ +--- +- name: Include prerequisite tasks + ansible.builtin.include_tasks: setup.yaml +- name: SSLCERTKEY | ADD | --check + delegate_to: localhost + register: result + check_mode: true + tags: test + netscaler.adc.sslcertkey: + nsip: "{{ nsip }}" + nitro_user: "{{ nitro_user }}" + nitro_pass: "{{ nitro_pass }}" + nitro_protocol: "{{ nitro_protocol }}" + validate_certs: "{{ validate_certs }}" + save_config: "{{ save_config }}" + state: present + certkey: "{{ intermediate_cert }}" + cert: "{{ intermediate_cert }}.crt" + key: "{{ intermediate_cert }}.key" + linkcertkeyname: "{{ root_cert }}" +- name: Assert | SSLCERTKEY | ADD | --check + tags: test + ansible.builtin.assert: + that: + - "result.failed==false" + - "result.changed==true" +- name: SSLCERTKEY | ADD + delegate_to: localhost + register: result + check_mode: false + tags: test + netscaler.adc.sslcertkey: + nsip: "{{ nsip }}" + nitro_user: "{{ nitro_user }}" + nitro_pass: "{{ nitro_pass }}" + nitro_protocol: "{{ nitro_protocol }}" + validate_certs: "{{ validate_certs }}" + save_config: "{{ save_config }}" + state: present + certkey: "{{ intermediate_cert }}" + cert: "{{ intermediate_cert }}.crt" + key: "{{ intermediate_cert }}.key" + linkcertkeyname: "{{ root_cert }}" +- name: Assert | SSLCERTKEY | ADD + ansible.builtin.assert: + that: + - "result.failed==false" + - "result.changed==true" +- name: SSLCERTKEY | ADD | idempotent + delegate_to: localhost + register: result + check_mode: false + tags: test + netscaler.adc.sslcertkey: + nsip: "{{ nsip }}" + nitro_user: "{{ nitro_user }}" + nitro_pass: "{{ nitro_pass }}" + nitro_protocol: "{{ nitro_protocol }}" + validate_certs: "{{ validate_certs }}" + save_config: "{{ save_config }}" + state: present + certkey: "{{ intermediate_cert }}" + cert: "{{ intermediate_cert }}.crt" + key: "{{ intermediate_cert }}.key" + linkcertkeyname: "{{ root_cert }}" +- name: Assert | SSLCERTKEY | ADD | idempotent + tags: test + ansible.builtin.assert: + that: + - "result.failed==false" + - "result.changed==false" +- name: SSLCERTKEY | DELETE | --check + delegate_to: localhost + register: result + check_mode: true + tags: test + netscaler.adc.sslcertkey: + nsip: "{{ nsip }}" + nitro_user: "{{ nitro_user }}" + nitro_pass: "{{ nitro_pass }}" + nitro_protocol: "{{ nitro_protocol }}" + validate_certs: "{{ validate_certs }}" + save_config: "{{ save_config }}" + state: absent + certkey: "{{ intermediate_cert }}" + cert: "{{ intermediate_cert }}.crt" + key: "{{ intermediate_cert }}.key" + linkcertkeyname: "{{ root_cert }}" +- name: Assert | SSLCERTKEY | DELETE | --check + tags: test + ansible.builtin.assert: + that: + - "result.failed==false" + - "result.changed==true" +- name: SSLCERTKEY | DELETE + delegate_to: localhost + register: result + check_mode: false + tags: test + netscaler.adc.sslcertkey: + nsip: "{{ nsip }}" + nitro_user: "{{ nitro_user }}" + nitro_pass: "{{ nitro_pass }}" + nitro_protocol: "{{ nitro_protocol }}" + validate_certs: "{{ validate_certs }}" + save_config: "{{ save_config }}" + state: absent + certkey: "{{ intermediate_cert }}" + cert: "{{ intermediate_cert }}.crt" + key: "{{ intermediate_cert }}.key" + linkcertkeyname: "{{ root_cert }}" +- name: Assert | SSLCERTKEY | DELETE + ansible.builtin.assert: + that: + - "result.failed==false" + - "result.changed==true" +- name: SSLCERTKEY | DELETE | idempotent + delegate_to: localhost + register: result + check_mode: false + tags: test + netscaler.adc.sslcertkey: + nsip: "{{ nsip }}" + nitro_user: "{{ nitro_user }}" + nitro_pass: "{{ nitro_pass }}" + nitro_protocol: "{{ nitro_protocol }}" + validate_certs: "{{ validate_certs }}" + save_config: "{{ save_config }}" + state: absent + certkey: "{{ intermediate_cert }}" + cert: "{{ intermediate_cert }}.crt" + key: "{{ intermediate_cert }}.key" + linkcertkeyname: "{{ root_cert }}" +- name: Assert | SSLCERTKEY | DELETE | idempotent + tags: test + ansible.builtin.assert: + that: + - "result.failed==false" + - "result.changed==false" +- name: Include prerequisite tasks + ansible.builtin.include_tasks: teardown.yaml diff --git a/tests/integration/targets/sslcertkey/tasks/setup.yaml b/tests/integration/targets/sslcertkey/tasks/setup.yaml new file mode 100644 index 00000000..1abeaac4 --- /dev/null +++ b/tests/integration/targets/sslcertkey/tasks/setup.yaml @@ -0,0 +1,67 @@ +--- +- name: Create ssl rsakey intermediate_cert + delegate_to: localhost + netscaler.adc.sslrsakey: + nsip: "{{ nsip }}" + nitro_user: "{{ nitro_user }}" + nitro_pass: "{{ nitro_pass }}" + nitro_protocol: "{{ nitro_protocol }}" + validate_certs: "{{ validate_certs }}" + save_config: "{{ save_config }}" + state: created + keyfile: "{{ intermediate_cert }}.key" + bits: 2048 + exponent: F4 + keyform: PEM +- name: Create ssl certReq intermediate_cert.csr + delegate_to: localhost + netscaler.adc.sslcertreq: + nsip: "{{ nsip }}" + nitro_user: "{{ nitro_user }}" + nitro_pass: "{{ nitro_pass }}" + nitro_protocol: "{{ nitro_protocol }}" + validate_certs: "{{ validate_certs }}" + save_config: "{{ save_config }}" + state: created + reqfile: "{{ intermediate_cert }}.csr" + keyfile: "{{ intermediate_cert }}.key" + keyform: PEM + countryname: IN + statename: KAR + organizationname: example + commonname: example + emailaddress: test1@example.com +- name: Create ssl cert intermediate_cert.crt + delegate_to: localhost + netscaler.adc.sslcert: + nsip: "{{ nsip }}" + nitro_user: "{{ nitro_user }}" + nitro_pass: "{{ nitro_pass }}" + nitro_protocol: "{{ nitro_protocol }}" + validate_certs: "{{ validate_certs }}" + save_config: "{{ save_config }}" + state: created + certfile: "{{ intermediate_cert }}.crt" + reqfile: "{{ intermediate_cert }}.csr" + keyform: PEM + days: 1480 + certform: PEM + cacert: "{{ root_cert }}.cert" + cacertform: PEM + cakey: "{{ root_cert }}.key" + cakeyform: PEM + caserial: "{{ root_cert }}.srl" + certtype: SRVR_CERT +- name: Create Root SSL CertKey + delegate_to: localhost + netscaler.adc.sslcertkey: + nsip: "{{ nsip }}" + nitro_user: "{{ nitro_user }}" + nitro_pass: "{{ nitro_pass }}" + nitro_protocol: "{{ nitro_protocol }}" + validate_certs: "{{ validate_certs }}" + save_config: "{{ save_config }}" + state: present + certkey: "{{ root_cert }}" + cert: "{{ root_cert }}.cert" + key: "{{ root_cert }}.key" diff --git a/tests/integration/targets/sslcertkey/tasks/teardown.yaml b/tests/integration/targets/sslcertkey/tasks/teardown.yaml new file mode 100644 index 00000000..eb623a37 --- /dev/null +++ b/tests/integration/targets/sslcertkey/tasks/teardown.yaml @@ -0,0 +1,14 @@ +--- +- name: Delete Root SSL CertKey + delegate_to: localhost + netscaler.adc.sslcertkey: + nsip: "{{ nsip }}" + nitro_user: "{{ nitro_user }}" + nitro_pass: "{{ nitro_pass }}" + nitro_protocol: "{{ nitro_protocol }}" + validate_certs: "{{ validate_certs }}" + save_config: "{{ save_config }}" + state: absent + certkey: "{{ root_cert }}" + cert: "{{ root_cert }}.cert" + key: "{{ root_cert }}.key" diff --git a/tests/integration/targets/sslcertkey/vars/main.yaml b/tests/integration/targets/sslcertkey/vars/main.yaml new file mode 100644 index 00000000..f8df4035 --- /dev/null +++ b/tests/integration/targets/sslcertkey/vars/main.yaml @@ -0,0 +1,3 @@ +--- +intermediate_cert: test1-sni +root_cert: ns-root