mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
c0915e2f5a
* Support nested JSON decoding in AnsibleJSONDecoder * Add tests for vault portion of AnsibleJSONDecoder
22 lines
798 B
Python
22 lines
798 B
Python
# Copyright 2018, Matt Martz <matt@sivel.net>
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
__metaclass__ = type
|
|
|
|
import os
|
|
import json
|
|
|
|
import pytest
|
|
|
|
from ansible.parsing.ajson import AnsibleJSONDecoder
|
|
from ansible.parsing.yaml.objects import AnsibleVaultEncryptedUnicode
|
|
|
|
|
|
def test_AnsibleJSONDecoder_vault():
|
|
with open(os.path.join(os.path.dirname(__file__), 'fixtures/ajson.json')) as f:
|
|
data = json.load(f, cls=AnsibleJSONDecoder)
|
|
|
|
assert isinstance(data['password'], AnsibleVaultEncryptedUnicode)
|
|
assert isinstance(data['bar']['baz'][0]['password'], AnsibleVaultEncryptedUnicode)
|
|
assert isinstance(data['foo']['password'], AnsibleVaultEncryptedUnicode)
|