Update tests dir to use yaml.safe_load()

Unit tests are warning that yaml.load() without a loader are deprecated.
Switch these calls to yaml.safe_load() to resolve warnings.

Change-Id: Ia8e080fc5317eefe432eee984608df190546530c
This commit is contained in:
Alexander Hughes 2019-06-03 09:29:45 -05:00
parent b18c4c0093
commit e6abbf5b07
4 changed files with 8 additions and 8 deletions

View File

@ -31,7 +31,7 @@ import pegleg
from pegleg.engine.util.pegleg_secret_management import ENV_PASSPHRASE
from pegleg.engine.util.pegleg_secret_management import ENV_SALT
TEST_PASSPHRASES_CATALOG = yaml.load("""
TEST_PASSPHRASES_CATALOG = yaml.safe_load("""
---
schema: pegleg/PassphraseCatalog/v1
metadata:
@ -69,7 +69,7 @@ data:
...
""")
TEST_GLOBAL_PASSPHRASES_CATALOG = yaml.load("""
TEST_GLOBAL_PASSPHRASES_CATALOG = yaml.safe_load("""
---
schema: pegleg/PassphraseCatalog/v1
metadata:
@ -87,7 +87,7 @@ data:
...
""")
TEST_BASE64_PASSPHRASES_CATALOG = yaml.load("""
TEST_BASE64_PASSPHRASES_CATALOG = yaml.safe_load("""
---
schema: pegleg/PassphraseCatalog/v1
metadata:
@ -180,7 +180,7 @@ def test_generate_passphrases(*_):
passphrase_file_name)
assert os.path.isfile(passphrase_file_path)
with open(passphrase_file_path) as stream:
doc = yaml.load(stream)
doc = yaml.safe_load(stream)
assert doc['schema'] == 'pegleg/PeglegManagedDocument/v1'
assert doc['metadata']['storagePolicy'] == 'cleartext'
assert 'encrypted' in doc['data']

View File

@ -116,7 +116,7 @@ data: {0}-password
encrypted_path = str(save_location.join("site/cicd/secrets/passphrases/"
"cicd-passphrase-encrypted.yaml"))
decrypted = secrets.decrypt(encrypted_path)
assert yaml.load(decrypted[encrypted_path]) == yaml.load(passphrase_doc)
assert yaml.safe_load(decrypted[encrypted_path]) == yaml.safe_load(passphrase_doc)
def test_pegleg_secret_management_constructor():

View File

@ -43,7 +43,7 @@ def _gen_document(**kwargs):
if "storagePolicy" not in kwargs:
kwargs["storagePolicy"] = "cleartext"
test_document = TEST_DOCUMENT % kwargs
return yaml.load(test_document)
return yaml.safe_load(test_document)
@pytest.fixture()

View File

@ -553,7 +553,7 @@ class TestSiteSecretsActions(BaseCLIActionTest):
file_path = os.path.join(repo_path, "site", "airship-seaworthy",
"secrets", "passphrases", "ceph_fsid.yaml")
with open(file_path, "r") as ceph_fsid_fi:
ceph_fsid = yaml.load(ceph_fsid_fi)
ceph_fsid = yaml.safe_load(ceph_fsid_fi)
ceph_fsid["metadata"]["storagePolicy"] = "encrypted"
with open(file_path, "w") as ceph_fsid_fi:
@ -568,7 +568,7 @@ class TestSiteSecretsActions(BaseCLIActionTest):
"secrets", "passphrases", "ceph_fsid.yaml"),
"r") \
as ceph_fsid_fi:
ceph_fsid = yaml.load(ceph_fsid_fi)
ceph_fsid = yaml.safe_load(ceph_fsid_fi)
assert "encrypted" in ceph_fsid["data"]
assert "managedDocument" in ceph_fsid["data"]