mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-28 07:31:23 -07:00
Add api_url in github_key module (#10191)
* github_key: add api_url parameter for GitHub Enterprise support * github_key: add tests * Add changelog * Review fixes: remove test from CI & fix version --------- Co-authored-by: Aleksei Loginov <aloginov@drwholdings.com>
This commit is contained in:
parent
ce1dd0c78f
commit
97e386f85b
5 changed files with 100 additions and 8 deletions
6
tests/integration/targets/github_key/aliases
Normal file
6
tests/integration/targets/github_key/aliases
Normal file
|
@ -0,0 +1,6 @@
|
|||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
unsupported
|
||||
destructive
|
58
tests/integration/targets/github_key/tasks/main.yml
Normal file
58
tests/integration/targets/github_key/tasks/main.yml
Normal file
|
@ -0,0 +1,58 @@
|
|||
---
|
||||
####################################################################
|
||||
# WARNING: These are designed specifically for Ansible tests #
|
||||
# and should not be used as examples of how to write Ansible roles #
|
||||
####################################################################
|
||||
|
||||
# Test code for the github_key module.
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
- name: Test api_url parameter with GitHub.com
|
||||
community.general.github_key:
|
||||
token: "{{ fake_token }}"
|
||||
name: "{{ test_key_name }}"
|
||||
pubkey: "{{ test_pubkey }}"
|
||||
state: present
|
||||
api_url: "{{ github_api_url }}"
|
||||
register: github_api_result
|
||||
ignore_errors: true
|
||||
|
||||
- name: Assert api_url parameter works with GitHub.com
|
||||
assert:
|
||||
that:
|
||||
- github_api_result is failed
|
||||
- '"Unauthorized" in github_api_result.msg or "401" in github_api_result.msg'
|
||||
|
||||
- name: Test api_url parameter with GitHub Enterprise
|
||||
community.general.github_key:
|
||||
token: "{{ fake_token }}"
|
||||
name: "{{ test_key_name }}"
|
||||
pubkey: "{{ test_pubkey }}"
|
||||
state: present
|
||||
api_url: "{{ enterprise_api_url }}"
|
||||
register: enterprise_api_result
|
||||
ignore_errors: true
|
||||
|
||||
- name: Assert api_url parameter works with GitHub Enterprise
|
||||
assert:
|
||||
that:
|
||||
- enterprise_api_result is failed
|
||||
- '"github.company.com" in enterprise_api_result.msg'
|
||||
|
||||
- name: Test api_url with trailing slash
|
||||
community.general.github_key:
|
||||
token: "{{ fake_token }}"
|
||||
name: "{{ test_key_name }}"
|
||||
pubkey: "{{ test_pubkey }}"
|
||||
state: present
|
||||
api_url: "{{ enterprise_api_url_trailing }}"
|
||||
register: trailing_slash_result
|
||||
ignore_errors: true
|
||||
|
||||
- name: Assert trailing slash is handled correctly
|
||||
assert:
|
||||
that:
|
||||
- trailing_slash_result is failed
|
||||
- '"github.company.com" in trailing_slash_result.msg'
|
11
tests/integration/targets/github_key/vars/main.yml
Normal file
11
tests/integration/targets/github_key/vars/main.yml
Normal file
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
# Copyright (c) Ansible Project
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
fake_token: "fake_token_for_testing"
|
||||
test_key_name: "ansible-test-key"
|
||||
github_api_url: "https://api.github.com"
|
||||
enterprise_api_url: "https://github.company.com/api/v3"
|
||||
enterprise_api_url_trailing: "https://github.company.com/api/v3/"
|
||||
test_pubkey: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTgvwjlRHZ8E1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ test@example.com"
|
Loading…
Add table
Add a link
Reference in a new issue