mirror of
https://github.com/ZwareBear/awx.git
synced 2026-04-23 16:31:50 -05:00
add robust handling of non-UTF8 when detecting inventory/playbooks
This commit is contained in:
0
awx/main/tests/unit/utils/ansible/__init__.py
Normal file
0
awx/main/tests/unit/utils/ansible/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
$$$
|
||||
@@ -0,0 +1,2 @@
|
||||
<EFBFBD>
|
||||
?
|
||||
0
awx/main/tests/unit/utils/ansible/inventories/valid/executable
Executable file
0
awx/main/tests/unit/utils/ansible/inventories/valid/executable
Executable file
1
awx/main/tests/unit/utils/ansible/playbooks/invalid/bad
Normal file
1
awx/main/tests/unit/utils/ansible/playbooks/invalid/bad
Normal file
@@ -0,0 +1 @@
|
||||
not a playbook
|
||||
@@ -0,0 +1,2 @@
|
||||
<EFBFBD>
|
||||
?
|
||||
@@ -0,0 +1,7 @@
|
||||
- name: Hello World Sample
|
||||
hosts: all
|
||||
tasks:
|
||||
- name: Hello Message
|
||||
debug:
|
||||
msg: "Hello World!"
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
- name: Hello World Sample
|
||||
hosts: all
|
||||
tasks:
|
||||
- name: Hello Message
|
||||
debug:
|
||||
msg: "Hello World!"
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
- name: Hello World Sample
|
||||
hosts: all
|
||||
tasks:
|
||||
- name: Hello Message
|
||||
debug:
|
||||
msg: "Hello World!"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
- hosts: all
|
||||
@@ -0,0 +1 @@
|
||||
- import_playbook: foo
|
||||
@@ -0,0 +1 @@
|
||||
- include: foo
|
||||
11
awx/main/tests/unit/utils/ansible/playbooks/valid/vault.yml
Normal file
11
awx/main/tests/unit/utils/ansible/playbooks/valid/vault.yml
Normal file
@@ -0,0 +1,11 @@
|
||||
$ANSIBLE_VAULT;1.1;AES256
|
||||
64313966653262616130386430653233326161623364386235636436333430646161323830336663
|
||||
6633613437653635626162386338613338646231396363660a376537373331356239623435353365
|
||||
31633039363639376166633538336335383062316461633439346630363135316266613766393864
|
||||
3363343634636535650a346231653233626362323135383164636634343534333466363139633436
|
||||
66366132656364316161336538613933666537666361356662306631653235323936363764613338
|
||||
65653833326661323935373535396164373132393165383633643432306432373463376461613165
|
||||
61376361323861373036316230343038666366336231303231303937393731616664316664373338
|
||||
36623935363262623566653238313964636435666138626336346465363562356535663033356265
|
||||
64323239616536346365306635353863623831636266633233313437396236633235373539373363
|
||||
6464303039663737333164613763306137393864356663316263
|
||||
32
awx/main/tests/unit/utils/ansible/test_ansible.py
Normal file
32
awx/main/tests/unit/utils/ansible/test_ansible.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import os
|
||||
import os.path
|
||||
|
||||
import pytest
|
||||
|
||||
from awx.main.utils.ansible import could_be_playbook, could_be_inventory
|
||||
|
||||
HERE, _ = os.path.split(__file__)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('filename', os.listdir(os.path.join(HERE, 'playbooks', 'valid')))
|
||||
def test_could_be_playbook(filename):
|
||||
path = os.path.join(HERE, 'playbooks', 'valid')
|
||||
assert could_be_playbook(HERE, path, filename).endswith(filename)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('filename', os.listdir(os.path.join(HERE, 'playbooks', 'invalid')))
|
||||
def test_is_not_playbook(filename):
|
||||
path = os.path.join(HERE, 'playbooks', 'invalid')
|
||||
assert could_be_playbook(HERE, path, filename) is None
|
||||
|
||||
|
||||
@pytest.mark.parametrize('filename', os.listdir(os.path.join(HERE, 'inventories', 'valid')))
|
||||
def test_could_be_inventory(filename):
|
||||
path = os.path.join(HERE, 'inventories', 'valid')
|
||||
assert could_be_inventory(HERE, path, filename).endswith(filename)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('filename', os.listdir(os.path.join(HERE, 'inventories', 'invalid')))
|
||||
def test_is_not_inventory(filename):
|
||||
path = os.path.join(HERE, 'inventories', 'invalid')
|
||||
assert could_be_inventory(HERE, path, filename) is None
|
||||
Reference in New Issue
Block a user