Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
Codecov reports (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
herve4m authored Aug 7, 2024
1 parent f47e953 commit 1841afd
Show file tree
Hide file tree
Showing 16 changed files with 1,102 additions and 24 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ansible-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ jobs:
- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}
...
8 changes: 4 additions & 4 deletions plugins/modules/quay_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def main():
new_fields["name"] = new_name
# The original application does not exists...
if not app_details:
# and neither the new organization. Create that new organization.
# and neither the new application. Create that new application.
if not new_app_details:
data = module.create(
"application",
Expand All @@ -297,8 +297,8 @@ def main():
)
exit_module(module, True, data)

# The original organization does not exists but the new one does.
# Update that new organization.
# The original application does not exists but the new one does.
# Update that new application.
updated, data = module.update(
new_app_details,
"application",
Expand All @@ -310,7 +310,7 @@ def main():
id=new_app_details.get("client_id", ""),
)
exit_module(module, updated, data if updated else new_app_details)
# The original organization exists. Rename it.
# The original application exists. Rename it.
updated, data = module.update(
app_details,
"application",
Expand Down
81 changes: 81 additions & 0 deletions tests/integration/targets/quay_api_token/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,87 @@
quay_host: "{{ quay_url }}"
validate_certs: false

- name: ERROR EXPECTED Non-existing user
herve4m.quay.quay_api_token:
for_user: nonexistinguser
quay_username: testuser1
quay_password: vs9mrD55NP
client_id: "{{ app_details['client_id'] }}"
rights:
- org:admin
- repo:admin
- repo:create
- repo:read
- repo:write
- user:admin
- user:read
quay_host: "{{ quay_url }}"
validate_certs: false
ignore_errors: true
register: result

- name: Ensure that the task failed
ansible.builtin.assert:
that: result['failed']
fail_msg: The preceding task should have failed (non-existing user)

- name: ERROR EXPECTED No rights specified
herve4m.quay.quay_api_token:
quay_username: testuser1
quay_password: vs9mrD55NP
client_id: "{{ app_details['client_id'] }}"
rights: []
quay_host: "{{ quay_url }}"
validate_certs: false
ignore_errors: true
register: result

- name: Ensure that the task failed
ansible.builtin.assert:
that: result['failed']
fail_msg: The preceding task should have failed (non-existing organization)

- name: Generate an OAuth access token for the current user (check mode)
herve4m.quay.quay_api_token:
quay_username: testuser1
quay_password: vs9mrD55NP
client_id: "{{ app_details['client_id'] }}"
rights:
- all
quay_host: "{{ quay_url }}"
validate_certs: false
check_mode: true
register: result

- name: Ensure that the returned data has the access_token key
ansible.builtin.assert:
that: "'access_token' in result"
fail_msg: The result should have the access_token key

- name: Generate an OAuth access token for ansibletestuser1 (check mode)
herve4m.quay.quay_api_token:
for_user: ansibletestuser1
quay_username: testuser1
quay_password: vs9mrD55NP
client_id: "{{ app_details['client_id'] }}"
rights:
- org:admin
- repo:admin
- repo:create
- repo:read
- repo:write
- user:admin
- user:read
quay_host: "{{ quay_url }}"
validate_certs: false
check_mode: true
register: result

- name: Ensure that the task did change something
ansible.builtin.assert:
that: result['changed']
fail_msg: The preceding task should created the token

- name: Ensure testteam1 team is removed
herve4m.quay.quay_team:
name: testteam1
Expand Down
70 changes: 70 additions & 0 deletions tests/integration/targets/quay_application/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,76 @@
quay_token: "{{ quay_token }}"
validate_certs: false

- name: Non-existing organization and state=absent (no change)
herve4m.quay.quay_application:
organization: nonexisting
name: ansibletestapp1
state: absent
quay_host: "{{ quay_url }}"
quay_token: "{{ quay_token }}"
validate_certs: false
register: result

- name: Ensure that the task did not change anything
ansible.builtin.assert:
that: not result['changed']
fail_msg: The preceding task should not have changed anything

- name: ERROR EXPECTED Non-existing organization
herve4m.quay.quay_application:
organization: nonexisting
name: ansibletestapp1
state: present
quay_host: "{{ quay_url }}"
quay_token: "{{ quay_token }}"
validate_certs: false
ignore_errors: true
register: result

- name: Ensure that the task failed
ansible.builtin.assert:
that: result['failed']
fail_msg: The preceding task should have failed (non-existing organization)

- name: ERROR EXPECTED Already existing application
herve4m.quay.quay_application:
organization: ansibletestorg
name: ansibletestapp2
new_name: ansibletestapp3
state: present
quay_host: "{{ quay_url }}"
quay_token: "{{ quay_token }}"
validate_certs: false
ignore_errors: true
register: result

- name: Ensure that the task failed
ansible.builtin.assert:
that: result['failed']
fail_msg: The preceding task should have failed (application exists)

- name: Ensure the application ansibletestapp2 is updated (new_name)
herve4m.quay.quay_application:
organization: ansibletestorg
name: doesnotexist
new_name: ansibletestapp2
description: Application 2 description
state: present
quay_host: "{{ quay_url }}"
quay_token: "{{ quay_token }}"
validate_certs: false

- name: Ensure the application ansibletestapp3 is removed
herve4m.quay.quay_application:
organization: ansibletestorg
name: doesnotexist
new_name: ansibletestapp3
description: "New ansibletestapp3 application"
state: absent
quay_host: "{{ quay_url }}"
quay_token: "{{ quay_token }}"
validate_certs: false

- name: Ensure the applications are removed
herve4m.quay.quay_application:
organization: ansibletestorg
Expand Down
111 changes: 111 additions & 0 deletions tests/integration/targets/quay_default_perm/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,117 @@
that: not result['changed']
fail_msg: The preceding task should not have changed anything

- name: Missing organization and state=absent (no change)
herve4m.quay.quay_default_perm:
organization: nonexisting
name: ansibletestteam1
type: team
role: admin
creator: ansibletestuser2
state: absent
quay_host: "{{ quay_url }}"
quay_token: "{{ quay_token }}"
validate_certs: false
register: result

- name: Ensure that the task did not change anything
ansible.builtin.assert:
that: not result['changed']
fail_msg: The preceding task should not have changed anything

- name: ERROR EXPECTED Non-existing organization
herve4m.quay.quay_default_perm:
organization: nonexisting
name: ansibletestteam1
type: team
role: admin
creator: ansibletestuser2
state: present
quay_host: "{{ quay_url }}"
quay_token: "{{ quay_token }}"
validate_certs: false
ignore_errors: true
register: result

- name: Ensure that the task failed
ansible.builtin.assert:
that: result['failed']
fail_msg: The preceding task should have failed (non-existing organization)

- name: ERROR EXPECTED Non-existing user
herve4m.quay.quay_default_perm:
organization: ansibletestorg
name: nonexistinguser
type: user
role: admin
state: present
quay_host: "{{ quay_url }}"
quay_token: "{{ quay_token }}"
validate_certs: false
ignore_errors: true
register: result

- name: Ensure that the task failed
ansible.builtin.assert:
that: result['failed']
fail_msg: The preceding task should have failed (non-existing user)

- name: ERROR EXPECTED Non-existing team
herve4m.quay.quay_default_perm:
organization: ansibletestorg
name: nonexistingteam
type: team
role: admin
state: present
quay_host: "{{ quay_url }}"
quay_token: "{{ quay_token }}"
validate_certs: false
ignore_errors: true
register: result

- name: Ensure that the task failed
ansible.builtin.assert:
that: result['failed']
fail_msg: The preceding task should have failed (non-existing team)

- name: ERROR EXPECTED Non-existing creator
herve4m.quay.quay_default_perm:
organization: ansibletestorg
name: ansibletestteam1
type: team
role: admin
creator: nonexistingcreator
state: present
quay_host: "{{ quay_url }}"
quay_token: "{{ quay_token }}"
validate_certs: false
ignore_errors: true
register: result

- name: Ensure that the task failed
ansible.builtin.assert:
that: result['failed']
fail_msg: The preceding task should have failed (non-existing creator)

- name: ERROR EXPECTED Creator is a robot account
herve4m.quay.quay_default_perm:
organization: ansibletestorg
name: ansibletestteam1
type: team
role: admin
creator: ansibletestorg+ansibletestrobot1
state: present
quay_host: "{{ quay_url }}"
quay_token: "{{ quay_token }}"
validate_certs: false
ignore_errors: true
register: result

- name: Ensure that the task failed
ansible.builtin.assert:
that: result['failed']
fail_msg: The preceding task should have failed (creator is a robot)

- name: Ensure default perm anon-read-ansibletestuser1 is removed
herve4m.quay.quay_default_perm:
organization: ansibletestorg
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/targets/quay_docker_config/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
---
- name: Build a Docker configuration in JSON format
ansible.builtin.set_fact:
json_conf: "{{ 'myuser' | herve4m.quay.quay_docker_config('mypassword',
json_conf: "{{ 'myuser' |
herve4m.quay.quay_docker_config('mypassword',
'https://www.example.com:8080', 'myuser@example.com') }}"

- name: Ensure that the Docker configuration matches
Expand Down
15 changes: 14 additions & 1 deletion tests/integration/targets/quay_layer_info/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
that: layers1['layers']|length == layers2['layers']|length
fail_msg: The same image should have been returned

- name: Retrieve an image with no namespace (error)
- name: ERROR EXPECTED Retrieve an image with no namespace
herve4m.quay.quay_layer_info:
image: nosuchimageipresume
quay_host: quay.io
Expand All @@ -32,6 +32,19 @@
that: result['failed']
fail_msg: The preceding task should have failed

- name: Retrieve an image in a non-existing namespace
herve4m.quay.quay_layer_info:
image: nonexisting/ansibletestrepo:latest
quay_host: "{{ quay_url }}"
quay_token: "{{ quay_token }}"
validate_certs: false
register: result

- name: Ensure that the task did not change anything
ansible.builtin.assert:
that: not result['changed']
fail_msg: The preceding task should not have changed anything

- name: Retrieve a non-existing image in my namespace (no change)
herve4m.quay.quay_layer_info:
image: dnsmasq:v1.0.0
Expand Down
Loading

0 comments on commit 1841afd

Please sign in to comment.