From 371d6f4679ead2bf57997e37e6189b3f514928a6 Mon Sep 17 00:00:00 2001 From: Till Maas Date: Tue, 2 Jun 2020 20:19:44 +0200 Subject: [PATCH] 802.1x tests: Improve cleanup --- tests/playbooks/tests_802_1x.yml | 17 +++++++++++++++++ tests/tasks/cleanup_802_1x_server.yml | 8 ++++++++ tests/tasks/setup_802_1x_server.yml | 14 +++++++++----- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/tests/playbooks/tests_802_1x.yml b/tests/playbooks/tests_802_1x.yml index 42f20a1..02fe0a8 100644 --- a/tests/playbooks/tests_802_1x.yml +++ b/tests/playbooks/tests_802_1x.yml @@ -156,5 +156,22 @@ state: down ignore_errors: true - include_tasks: tasks/cleanup_802_1x_server.yml + - name: Remove test certificates + file: + state: absent + path: "/etc/pki/tls/{{ item }}" + with_items: + - client.key + - client.key.nocrypt + - client.pem + - cacert.pem + - name: Remove test CA + file: + state: absent + path: "{{ item }}" + with_items: + - /etc/pki/ca-trust/source/anchors/cacert.pem + - name: Update ca trust + command: update-ca-trust tags: - "tests::cleanup" diff --git a/tests/tasks/cleanup_802_1x_server.yml b/tests/tasks/cleanup_802_1x_server.yml index 5d97932..2d1a888 100644 --- a/tests/tasks/cleanup_802_1x_server.yml +++ b/tests/tasks/cleanup_802_1x_server.yml @@ -9,3 +9,11 @@ - name: Kill hostapd process shell: pkill hostapd +- name: Remove certs and config + file: + state: absent + path: "{{ item }}" + with_items: + - /etc/pki/tls/hostapd_test + - /etc/hostapd/wired.conf + - /etc/hostapd/hostapd.eap_user diff --git a/tests/tasks/setup_802_1x_server.yml b/tests/tasks/setup_802_1x_server.yml index 1b9cffc..2873cb4 100644 --- a/tests/tasks/setup_802_1x_server.yml +++ b/tests/tasks/setup_802_1x_server.yml @@ -14,10 +14,14 @@ name: hostapd state: present +- name: Create directory for test certificates + file: + state: directory + path: /etc/pki/tls/hostapd_test - name: Copy server certificates copy: src: "{{ item }}" - dest: "/etc/pki/tls/{{ item }}" + dest: "/etc/pki/tls/hostapd_test/{{ item }}" with_items: - server.key - dh.pem @@ -61,10 +65,10 @@ eap_server=1 use_pae_group_addr=1 eap_user_file=/etc/hostapd/hostapd.eap_user - ca_cert=/etc/pki/tls/cacert.pem - dh_file=/etc/pki/tls/dh.pem - server_cert=/etc/pki/tls/server.pem - private_key=/etc/pki/tls/server.key + ca_cert=/etc/pki/tls/hostapd_test/cacert.pem + dh_file=/etc/pki/tls/hostapd_test/dh.pem + server_cert=/etc/pki/tls/hostapd_test/server.pem + private_key=/etc/pki/tls/hostapd_test/server.key private_key_passwd=test logger_syslog=-1 logger_syslog_level=0