mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-05 03:26:53 +00:00
Add an --unsafe option to check-yaml
This commit is contained in:
parent
e80813e7e9
commit
a21def36e3
3 changed files with 59 additions and 6 deletions
|
|
@ -22,7 +22,7 @@ def test_check_yaml_allow_multiple_documents(tmpdir):
|
|||
f = tmpdir.join('test.yaml')
|
||||
f.write('---\nfoo\n---\nbar\n')
|
||||
|
||||
# should failw without the setting
|
||||
# should fail without the setting
|
||||
assert check_yaml((f.strpath,))
|
||||
|
||||
# should pass when we allow multiple documents
|
||||
|
|
@ -33,3 +33,22 @@ def test_fails_even_with_allow_multiple_documents(tmpdir):
|
|||
f = tmpdir.join('test.yaml')
|
||||
f.write('[')
|
||||
assert check_yaml(('--allow-multiple-documents', f.strpath))
|
||||
|
||||
|
||||
def test_check_yaml_unsafe(tmpdir):
|
||||
f = tmpdir.join('test.yaml')
|
||||
f.write(
|
||||
'some_foo: !vault |\n'
|
||||
' $ANSIBLE_VAULT;1.1;AES256\n'
|
||||
' deadbeefdeadbeefdeadbeef\n',
|
||||
)
|
||||
# should fail "safe" check
|
||||
assert check_yaml((f.strpath,))
|
||||
# should pass when we allow unsafe documents
|
||||
assert not check_yaml(('--unsafe', f.strpath))
|
||||
|
||||
|
||||
def test_check_yaml_unsafe_still_fails_on_syntax_errors(tmpdir):
|
||||
f = tmpdir.join('test.yaml')
|
||||
f.write('[')
|
||||
assert check_yaml(('--unsafe', f.strpath))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue