summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorSloane Hertel <shertel@redhat.com>2020-03-02 20:14:42 -0500
committerGitHub <noreply@github.com>2020-03-02 17:14:42 -0800
commitafb389e5880bf37bb5b0b07f8b31a57297129e18 (patch)
tree4083b8139e0b5487d758a5aac4fd91dd6d138b9b /test
parente379dc76c34f068996381fe51204626d3acf6146 (diff)
downloadansible-afb389e5880bf37bb5b0b07f8b31a57297129e18.tar.gz
Fix inline vaults for plugins in ensure_type (#67492) (#67741)
* Fix implicit string - only looked right because of the vault __repr__ * Add tests for strings and implicit strings (cherry picked from commit 8eb00dd14cc9cc896a7cfd8719ffa325f2f98f23)
Diffstat (limited to 'test')
-rw-r--r--test/units/config/test_manager.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/units/config/test_manager.py b/test/units/config/test_manager.py
index 0a0a71af97..d103e5e661 100644
--- a/test/units/config/test_manager.py
+++ b/test/units/config/test_manager.py
@@ -131,3 +131,15 @@ class TestConfigManager:
actual_value, actual_origin = self.manager._loop_entries({'name': vault_var}, [{'name': 'name'}])
assert actual_value == "vault text"
assert actual_origin == "name"
+
+ @pytest.mark.parametrize("value_type", ("str", "string", None))
+ def test_ensure_type_with_vaulted_str(self, value_type):
+ class MockVault:
+ def decrypt(self, value):
+ return value
+
+ vault_var = AnsibleVaultEncryptedUnicode(b"vault text")
+ vault_var.vault = MockVault()
+
+ actual_value = ensure_type(vault_var, value_type)
+ assert actual_value == "vault text"