From 88b80ddfba865ab0bf31bd6f8ab5aa0bfe273b01 Mon Sep 17 00:00:00 2001 From: Yuriy Novostavskiy Date: Fri, 29 Nov 2024 13:44:15 +0000 Subject: [PATCH] final update copyright and integration test before pr --- plugins/modules/helm_registry_auth.py | 4 +- .../helm_registry_auth/tasks/main.yaml | 70 +++++++------------ 2 files changed, 29 insertions(+), 45 deletions(-) diff --git a/plugins/modules/helm_registry_auth.py b/plugins/modules/helm_registry_auth.py index 52885d4d..69cd24f0 100644 --- a/plugins/modules/helm_registry_auth.py +++ b/plugins/modules/helm_registry_auth.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# Copyright: (c) 2024, Yuriy Novostavskiy <@yurnov> +# Copyright: © Ericsson AB 2024 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) from __future__ import absolute_import, division, print_function @@ -39,7 +39,7 @@ options: description: - Provide a URL for accessing the registry. required: true - aliases: [ registry_url ] + aliases: [ registry_url ] type: str insecure: description: diff --git a/tests/integration/targets/helm_registry_auth/tasks/main.yaml b/tests/integration/targets/helm_registry_auth/tasks/main.yaml index 14bbdbeb..3a5845a8 100644 --- a/tests/integration/targets/helm_registry_auth/tasks/main.yaml +++ b/tests/integration/targets/helm_registry_auth/tasks/main.yaml @@ -49,11 +49,11 @@ register: _login_correct failed_when: _login_correct.rc != 0 - # - name: Clean up credentials to run test on clean environment - # ansible.builtin.shell: >- - # helm registry logout localhost:{{ registry_port }} - # register: _logout - # failed_when: _logout.rc != 0 + - name: Clean up credentials to run test on clean environment + ansible.builtin.shell: >- + helm registry logout localhost:{{ registry_port }} + register: _logout + failed_when: _logout.rc != 0 - name: Create directory for helm chart ansible.builtin.tempfile: @@ -68,18 +68,12 @@ return_content: no status_code: 200 - # - name: Test module helm_registry_auth with correct credentials - # helm_registry_auth: - # username: "{{ username }}" - # password: "{{ password }}" - # registry: localhost:{{ registry_port }} - # state: present - # register: _helm_registry_auth_correct - # failed_when: _helm_registry_auth_correct.failed - - name: Test the registry with correct credentials (to be removed) - ansible.builtin.shell: >- - echo {{ password | quote }} | helm registry login localhost:{{ registry_port }} - -u {{ username }} --password-stdin + - name: Test module helm_registry_auth with correct credentials + helm_registry_auth: + username: "{{ username }}" + password: "{{ password }}" + registry: localhost:{{ registry_port }} + state: present register: _helm_registry_auth_correct - name: Assert that the registry is logged in @@ -87,9 +81,9 @@ assert: that: - "'Login Succeeded' in _helm_registry_auth_correct.stderr" - # - "'{{ password }}' not in _helm_registry_auth_correct.command" - # - "'{{ password }}' not in _helm_registry_auth_correct.stdout" - # - "'{{ password }}' not in _helm_registry_auth_correct.stderr" + - "'{{ password }}' not in _helm_registry_auth_correct.command" + - "'{{ password }}' not in _helm_registry_auth_correct.stdout" + - "'{{ password }}' not in _helm_registry_auth_correct.stderr" - name: Ensure that push to the registry is working ansible.builtin.shell: >- @@ -103,14 +97,10 @@ that: "'Pushed: localhost:{{ registry_port }}/test/k8s-monitoring' in _save_chart.stderr" - # - name: Test logout - # helm_registry_auth: - # registry: localhost:{{ registry_port }} - # state: absent - # register: _helm_registry_auth_logout - # failed_when: _helm_registry_auth_logout.failed - - name: Test logout (to be removed) - ansible.builtin.shell: helm registry logout localhost:{{ registry_port }} + - name: Test logout + helm_registry_auth: + registry: localhost:{{ registry_port }} + state: absent register: _helm_registry_auth_logout - name: Assert logout @@ -138,18 +128,12 @@ - "_save_chart.rc != 0" - "'localhost' not in _config_json.content | b64decode" - # - name: Test module helm_registry_auth with wrong credentials - # helm_registry_auth: - # username: "{{ username }}" - # password: "{{ wrong_password }}" - # registry: localhost:{{ registry_port }} - # state: present - # register: _helm_registry_auth_wrong - # failed_when: _helm_registry_auth_wrong.rc == 0 - - name: Test module helm_registry_auth with wrong credentials (to be removed) - ansible.builtin.shell: >- - echo {{ wrong_password | quote }} | helm registry login localhost:{{ registry_port }} - -u {{ username }} --password-stdin + - name: Test module helm_registry_auth with wrong credentials + helm_registry_auth: + username: "{{ username }}" + password: "{{ wrong_password }}" + registry: localhost:{{ registry_port }} + state: present register: _helm_registry_auth_wrong failed_when: _helm_registry_auth_wrong.rc == 0 @@ -163,9 +147,9 @@ that: - "'401 Unauthorized' in _helm_registry_auth_wrong.stderr" - "_helm_registry_auth_wrong.rc != 0" - # - "'{{ wrong_password }}' not in _helm_registry_auth_correct.command" - # - "'{{ wrong_password }}' not in _helm_registry_auth_correct.stdout" - # - "'{{ wrong_password }}' not in _helm_registry_auth_correct.stderr" + - "'{{ wrong_password }}' not in _helm_registry_auth_correct.command" + - "'{{ wrong_password }}' not in _helm_registry_auth_correct.stdout" + - "'{{ wrong_password }}' not in _helm_registry_auth_correct.stderr" - "'localhost' not in _config_json.content | b64decode" # Clean up