mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 22:33:25 +00:00
Cleanup git tests (#19737)
* Cleanup git tests * Split git tests in seperate files * Remove use of repo_depth_url * Use native yaml * Remove unnecessary remote/local clones * Fix newlines for yamllint * If the hash is valid (full-length) but doesn't exist, git returns 128 instead of 1. * Ensure git doesn't use hardlinks for shallow clones
This commit is contained in:
54
test/integration/targets/git/tasks/missing_hostkey.yml
Normal file
54
test/integration/targets/git/tasks/missing_hostkey.yml
Normal file
@@ -0,0 +1,54 @@
|
||||
---
|
||||
|
||||
- name: remove known_host files
|
||||
file:
|
||||
state: absent
|
||||
path: '{{ item }}'
|
||||
with_items: "{{known_host_files}}"
|
||||
|
||||
- name: checkout ssh://git@github.com repo without accept_hostkey (expected fail)
|
||||
git:
|
||||
repo: '{{ repo_format2 }}'
|
||||
dest: '{{ checkout_dir }}'
|
||||
register: git_result
|
||||
ignore_errors: true
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'git_result.failed'
|
||||
- 'git_result.msg == "github.com has an unknown hostkey. Set accept_hostkey to True or manually add the hostkey prior to running the git module"'
|
||||
|
||||
- name: checkout git@github.com repo with accept_hostkey (expected pass)
|
||||
git:
|
||||
repo: '{{ repo_format2 }}'
|
||||
dest: '{{ checkout_dir }}'
|
||||
accept_hostkey: true
|
||||
key_file: '{{ github_ssh_private_key }}'
|
||||
register: git_result
|
||||
when: github_ssh_private_key is defined
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'git_result.changed'
|
||||
when: not git_result|skipped
|
||||
|
||||
|
||||
- name: clear checkout_dir
|
||||
file:
|
||||
state: absent
|
||||
path: '{{ checkout_dir }}'
|
||||
|
||||
- name: checkout ssh://git@github.com repo with accept_hostkey (expected pass)
|
||||
git:
|
||||
repo: '{{ repo_format3 }}'
|
||||
dest: '{{ checkout_dir }}'
|
||||
version: 'master'
|
||||
accept_hostkey: false # should already have been accepted
|
||||
key_file: '{{ github_ssh_private_key }}'
|
||||
register: git_result
|
||||
when: github_ssh_private_key is defined
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- 'git_result.changed'
|
||||
when: not git_result|skipped
|
||||
Reference in New Issue
Block a user