summaryrefslogtreecommitdiffstats
path: root/ansible_collections/cyberark/conjur/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ansible_collections/cyberark/conjur/tests')
-rw-r--r--ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable2
-rw-r--r--ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-bad-cert-path2
-rw-r--r--ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-bad-certs2
-rw-r--r--ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-disable-verify-certs2
-rw-r--r--ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-into-file2
-rw-r--r--ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-no-cert-provided2
-rw-r--r--ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-with-authn-token2
-rw-r--r--ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-with-authn-token-bad-cert2
-rw-r--r--ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-with-spaces-secret2
-rwxr-xr-xansible_collections/cyberark/conjur/tests/conjur_variable/test.sh3
-rw-r--r--ansible_collections/cyberark/conjur/tests/sanity/ignore-2.10.txt6
-rw-r--r--ansible_collections/cyberark/conjur/tests/sanity/ignore-2.11.txt6
-rw-r--r--ansible_collections/cyberark/conjur/tests/sanity/ignore-2.12.txt6
-rw-r--r--ansible_collections/cyberark/conjur/tests/sanity/ignore-2.13.txt8
-rw-r--r--ansible_collections/cyberark/conjur/tests/sanity/ignore-2.14.txt8
-rw-r--r--ansible_collections/cyberark/conjur/tests/sanity/ignore-2.15.txt8
-rw-r--r--ansible_collections/cyberark/conjur/tests/sanity/ignore-2.9.txt4
-rw-r--r--ansible_collections/cyberark/conjur/tests/unit/plugins/lookup/__init__.py0
-rw-r--r--ansible_collections/cyberark/conjur/tests/unit/plugins/lookup/test_conjur_variable.py79
19 files changed, 79 insertions, 67 deletions
diff --git a/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable b/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable
index bc362ea43..78767685b 100644
--- a/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable
+++ b/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable
@@ -1 +1 @@
-<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="0.476" timestamp="2023-09-28T17:28:54.180417" hostname="3bd1d1ebca35"><testcase classname="test_cases.retrieve-variable.tests.test_default" name="test_retrieved_secret[docker://dev-ansible-1]" time="0.450" /></testsuite></testsuites> \ No newline at end of file
+<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="0.480" timestamp="2024-05-24T10:40:05.446831" hostname="c471efefee8a"><testcase classname="test_cases.retrieve-variable.tests.test_default" name="test_retrieved_secret[docker://dev-ansible-1]" time="0.450" /></testsuite></testsuites> \ No newline at end of file
diff --git a/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-bad-cert-path b/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-bad-cert-path
index 7d7b7b4a7..26ee4675a 100644
--- a/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-bad-cert-path
+++ b/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-bad-cert-path
@@ -1 +1 @@
-<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="0.381" timestamp="2023-09-28T17:28:57.025234" hostname="3bd1d1ebca35"><testcase classname="test_cases.retrieve-variable-bad-cert-path.tests.test_default" name="test_retrieval_failed[docker://dev-ansible-1]" time="0.357" /></testsuite></testsuites> \ No newline at end of file
+<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="0.381" timestamp="2024-05-24T10:40:08.220541" hostname="c471efefee8a"><testcase classname="test_cases.retrieve-variable-bad-cert-path.tests.test_default" name="test_retrieval_failed[docker://dev-ansible-1]" time="0.351" /></testsuite></testsuites> \ No newline at end of file
diff --git a/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-bad-certs b/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-bad-certs
index 684fdb89d..09efed3d7 100644
--- a/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-bad-certs
+++ b/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-bad-certs
@@ -1 +1 @@
-<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="0.372" timestamp="2023-09-28T17:28:59.744035" hostname="3bd1d1ebca35"><testcase classname="test_cases.retrieve-variable-bad-certs.tests.test_default" name="test_retrieval_failed[docker://dev-ansible-1]" time="0.348" /></testsuite></testsuites> \ No newline at end of file
+<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="0.408" timestamp="2024-05-24T10:40:10.871829" hostname="c471efefee8a"><testcase classname="test_cases.retrieve-variable-bad-certs.tests.test_default" name="test_retrieval_failed[docker://dev-ansible-1]" time="0.376" /></testsuite></testsuites> \ No newline at end of file
diff --git a/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-disable-verify-certs b/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-disable-verify-certs
index 7cd98843b..2466fcc8a 100644
--- a/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-disable-verify-certs
+++ b/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-disable-verify-certs
@@ -1 +1 @@
-<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="0.484" timestamp="2023-09-28T17:29:03.245129" hostname="3bd1d1ebca35"><testcase classname="test_cases.retrieve-variable-disable-verify-certs.tests.test_default" name="test_retrieved_secret[docker://dev-ansible-1]" time="0.458" /></testsuite></testsuites> \ No newline at end of file
+<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="0.473" timestamp="2024-05-24T10:40:14.267839" hostname="c471efefee8a"><testcase classname="test_cases.retrieve-variable-disable-verify-certs.tests.test_default" name="test_retrieved_secret[docker://dev-ansible-1]" time="0.441" /></testsuite></testsuites> \ No newline at end of file
diff --git a/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-into-file b/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-into-file
index c9082babb..255bc72ab 100644
--- a/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-into-file
+++ b/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-into-file
@@ -1 +1 @@
-<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="0.721" timestamp="2023-09-28T17:29:06.557606" hostname="3bd1d1ebca35"><testcase classname="test_cases.retrieve-variable-into-file.tests.test_default" name="test_retrieved_secret[docker://dev-ansible-1]" time="0.695" /></testsuite></testsuites> \ No newline at end of file
+<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="0.694" timestamp="2024-05-24T10:40:17.441882" hostname="c471efefee8a"><testcase classname="test_cases.retrieve-variable-into-file.tests.test_default" name="test_retrieved_secret[docker://dev-ansible-1]" time="0.666" /></testsuite></testsuites> \ No newline at end of file
diff --git a/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-no-cert-provided b/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-no-cert-provided
index 34fd1fa03..901d73d5f 100644
--- a/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-no-cert-provided
+++ b/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-no-cert-provided
@@ -1 +1 @@
-<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="0.373" timestamp="2023-09-28T17:29:09.688977" hostname="3bd1d1ebca35"><testcase classname="test_cases.retrieve-variable-no-cert-provided.tests.test_default" name="test_retrieval_failed[docker://dev-ansible-1]" time="0.349" /></testsuite></testsuites> \ No newline at end of file
+<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="0.398" timestamp="2024-05-24T10:40:20.482341" hostname="c471efefee8a"><testcase classname="test_cases.retrieve-variable-no-cert-provided.tests.test_default" name="test_retrieval_failed[docker://dev-ansible-1]" time="0.369" /></testsuite></testsuites> \ No newline at end of file
diff --git a/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-with-authn-token b/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-with-authn-token
index c3f0e5978..155af8480 100644
--- a/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-with-authn-token
+++ b/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-with-authn-token
@@ -1 +1 @@
-<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="0.585" timestamp="2023-09-28T17:29:12.796986" hostname="3bd1d1ebca35"><testcase classname="test_cases.retrieve-variable-with-authn-token.tests.test_default" name="test_retrieved_secret[docker://dev-ansible-1]" time="0.552" /></testsuite></testsuites> \ No newline at end of file
+<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="0.485" timestamp="2024-05-24T10:40:23.597487" hostname="c471efefee8a"><testcase classname="test_cases.retrieve-variable-with-authn-token.tests.test_default" name="test_retrieved_secret[docker://dev-ansible-1]" time="0.453" /></testsuite></testsuites> \ No newline at end of file
diff --git a/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-with-authn-token-bad-cert b/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-with-authn-token-bad-cert
index db2705ced..cfba55757 100644
--- a/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-with-authn-token-bad-cert
+++ b/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-with-authn-token-bad-cert
@@ -1 +1 @@
-<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="1.129" timestamp="2023-09-28T17:29:16.832828" hostname="3bd1d1ebca35"><testcase classname="test_cases.retrieve-variable-with-authn-token-bad-cert.tests.test_default" name="test_retrieve_secret_failed[docker://dev-ansible-1]" time="1.046" /></testsuite></testsuites> \ No newline at end of file
+<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="0.681" timestamp="2024-05-24T10:40:26.802196" hostname="c471efefee8a"><testcase classname="test_cases.retrieve-variable-with-authn-token-bad-cert.tests.test_default" name="test_retrieve_secret_failed[docker://dev-ansible-1]" time="0.633" /></testsuite></testsuites> \ No newline at end of file
diff --git a/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-with-spaces-secret b/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-with-spaces-secret
index 7747d9fd7..af4ac7fde 100644
--- a/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-with-spaces-secret
+++ b/ansible_collections/cyberark/conjur/tests/conjur_variable/junit/retrieve-variable-with-spaces-secret
@@ -1 +1 @@
-<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="0.746" timestamp="2023-09-28T17:29:22.880901" hostname="3bd1d1ebca35"><testcase classname="test_cases.retrieve-variable-with-spaces-secret.tests.test_default" name="test_retrieved_secret[docker://dev-ansible-1]" time="0.695" /></testsuite></testsuites> \ No newline at end of file
+<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="1" time="0.573" timestamp="2024-05-24T10:40:31.821871" hostname="c471efefee8a"><testcase classname="test_cases.retrieve-variable-with-spaces-secret.tests.test_default" name="test_retrieved_secret[docker://dev-ansible-1]" time="0.538" /></testsuite></testsuites> \ No newline at end of file
diff --git a/ansible_collections/cyberark/conjur/tests/conjur_variable/test.sh b/ansible_collections/cyberark/conjur/tests/conjur_variable/test.sh
index c82810054..6983c7522 100755
--- a/ansible_collections/cyberark/conjur/tests/conjur_variable/test.sh
+++ b/ansible_collections/cyberark/conjur/tests/conjur_variable/test.sh
@@ -26,7 +26,8 @@ function run_test_case {
fi
# You can add -vvvvv here for debugging
- ansible-playbook 'test_cases/${test_case}/playbook.yml'
+ export SAMPLE_KEY='set_in_env'
+ ansible-playbook --extra-vars 'sample_key=set_in_extravars' 'test_cases/${test_case}/playbook.yml'
py.test --junitxml='./junit/${test_case}' \
--connection docker \
diff --git a/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.10.txt b/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.10.txt
index a81ded000..adfba63eb 100644
--- a/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.10.txt
+++ b/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.10.txt
@@ -1,9 +1,3 @@
-dev/start.sh shebang
Jenkinsfile shebang
tests/conjur_variable/policy/root.yml yamllint:unparsable-with-libyaml
roles/conjur_host_identity/tests/policy/root.yml yamllint:unparsable-with-libyaml # File loaded by summon utility (in Jenkinsfile), not via Python
-ci/build_release shebang
-ci/publish_to_galaxy shebang
-ci/test.sh shebang
-secrets.yml yamllint:unparsable-with-libyaml # File loaded by Conjur server, not via Python
-dev/policy/root.yml yamllint:unparsable-with-libyaml \ No newline at end of file
diff --git a/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.11.txt b/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.11.txt
index b643480a2..adfba63eb 100644
--- a/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.11.txt
+++ b/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.11.txt
@@ -1,9 +1,3 @@
Jenkinsfile shebang
-dev/start.sh shebang
tests/conjur_variable/policy/root.yml yamllint:unparsable-with-libyaml
roles/conjur_host_identity/tests/policy/root.yml yamllint:unparsable-with-libyaml # File loaded by summon utility (in Jenkinsfile), not via Python
-ci/build_release shebang
-ci/publish_to_galaxy shebang
-ci/test.sh shebang
-secrets.yml yamllint:unparsable-with-libyaml # File loaded by Conjur server, not via Python
-dev/policy/root.yml yamllint:unparsable-with-libyaml \ No newline at end of file
diff --git a/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.12.txt b/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.12.txt
index 6615526dc..c5b63bd70 100644
--- a/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.12.txt
+++ b/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.12.txt
@@ -1,9 +1,3 @@
Jenkinsfile shebang
-dev/start.sh shebang
tests/conjur_variable/policy/root.yml yamllint:unparsable-with-libyaml # File loaded by Conjur server, not via Python
roles/conjur_host_identity/tests/policy/root.yml yamllint:unparsable-with-libyaml # File loaded by Conjur server, not via Python
-ci/build_release shebang
-ci/publish_to_galaxy shebang
-ci/test.sh shebang
-secrets.yml yamllint:unparsable-with-libyaml # File loaded by Summon utility (in Jenkinsfile), not via Python
-dev/policy/root.yml yamllint:unparsable-with-libyaml \ No newline at end of file
diff --git a/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.13.txt b/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.13.txt
index e456a5ff7..4144f5b48 100644
--- a/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.13.txt
+++ b/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.13.txt
@@ -1,10 +1,2 @@
-ci/build_release shebang
-ci/publish_to_galaxy shebang
-ci/test.sh shebang
-dev/policy/root.yml yamllint:unparsable-with-libyaml
-dev/start.sh shebang
-dev/stop.sh shebang
-dev/util.sh shebang
Jenkinsfile shebang
plugins/lookup/conjur_variable.py validate-modules:version-added-must-be-major-or-minor
-secrets.yml yamllint:unparsable-with-libyaml
diff --git a/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.14.txt b/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.14.txt
index e456a5ff7..4144f5b48 100644
--- a/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.14.txt
+++ b/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.14.txt
@@ -1,10 +1,2 @@
-ci/build_release shebang
-ci/publish_to_galaxy shebang
-ci/test.sh shebang
-dev/policy/root.yml yamllint:unparsable-with-libyaml
-dev/start.sh shebang
-dev/stop.sh shebang
-dev/util.sh shebang
Jenkinsfile shebang
plugins/lookup/conjur_variable.py validate-modules:version-added-must-be-major-or-minor
-secrets.yml yamllint:unparsable-with-libyaml
diff --git a/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.15.txt b/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.15.txt
index e456a5ff7..4144f5b48 100644
--- a/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.15.txt
+++ b/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.15.txt
@@ -1,10 +1,2 @@
-ci/build_release shebang
-ci/publish_to_galaxy shebang
-ci/test.sh shebang
-dev/policy/root.yml yamllint:unparsable-with-libyaml
-dev/start.sh shebang
-dev/stop.sh shebang
-dev/util.sh shebang
Jenkinsfile shebang
plugins/lookup/conjur_variable.py validate-modules:version-added-must-be-major-or-minor
-secrets.yml yamllint:unparsable-with-libyaml
diff --git a/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.9.txt b/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.9.txt
index 1ee255c73..e3a0cf635 100644
--- a/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.9.txt
+++ b/ansible_collections/cyberark/conjur/tests/sanity/ignore-2.9.txt
@@ -1,7 +1,3 @@
Jenkinsfile shebang
-dev/start.sh shebang
tests/conjur_variable/test.sh shebang
roles/conjur_host_identity/tests/test.sh shebang
-ci/build_release shebang
-ci/publish_to_galaxy shebang
-ci/test.sh shebang \ No newline at end of file
diff --git a/ansible_collections/cyberark/conjur/tests/unit/plugins/lookup/__init__.py b/ansible_collections/cyberark/conjur/tests/unit/plugins/lookup/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/ansible_collections/cyberark/conjur/tests/unit/plugins/lookup/__init__.py
+++ /dev/null
diff --git a/ansible_collections/cyberark/conjur/tests/unit/plugins/lookup/test_conjur_variable.py b/ansible_collections/cyberark/conjur/tests/unit/plugins/lookup/test_conjur_variable.py
index 995adf2da..c78704e8b 100644
--- a/ansible_collections/cyberark/conjur/tests/unit/plugins/lookup/test_conjur_variable.py
+++ b/ansible_collections/cyberark/conjur/tests/unit/plugins/lookup/test_conjur_variable.py
@@ -84,6 +84,22 @@ class TestConjurLookup(TestCase):
@patch('ansible_collections.cyberark.conjur.plugins.lookup.conjur_variable._fetch_conjur_variable')
@patch('ansible_collections.cyberark.conjur.plugins.lookup.conjur_variable._fetch_conjur_token')
+ def test_run_with_ansible_vars(self, mock_fetch_conjur_token, mock_fetch_conjur_variable):
+ mock_fetch_conjur_token.return_value = "token"
+ mock_fetch_conjur_variable.return_value = ["conjur_variable"]
+
+ variables = {'conjur_account': 'fakeaccount',
+ 'conjur_appliance_url': 'https://conjur-fake',
+ 'conjur_cert_file': './conjurfake.pem',
+ 'conjur_authn_login': 'host/ansible/ansible-fake',
+ 'conjur_authn_api_key': 'fakekey'}
+ terms = ['ansible/fake-secret']
+
+ output = self.lookup.run(terms, variables)
+ self.assertEqual(output, ["conjur_variable"])
+
+ @patch('ansible_collections.cyberark.conjur.plugins.lookup.conjur_variable._fetch_conjur_variable')
+ @patch('ansible_collections.cyberark.conjur.plugins.lookup.conjur_variable._fetch_conjur_token')
@patch('ansible_collections.cyberark.conjur.plugins.lookup.conjur_variable._merge_dictionaries')
def test_retrieve_to_file(self, mock_merge_dictionaries, mock_fetch_conjur_token, mock_fetch_conjur_variable):
mock_fetch_conjur_token.return_value = "token"
@@ -116,10 +132,11 @@ class TestConjurLookup(TestCase):
kwargs = {'as_file': False, 'conf_file': 'conf_file', 'validate_certs': True}
with self.assertRaises(AnsibleError) as context:
self.lookup.run(terms, **kwargs)
- self.assertEqual(
- context.exception.message,
- "Configuration file on the controlling host must define `account` and `appliance_url` entries or they should be environment variables"
- )
+
+ self.assertIn(
+ "Configuration must define options `conjur_account` and `conjur_appliance_url`",
+ context.exception.message,
+ )
# Withhold 'id' and 'api_key' fields
mock_merge_dictionaries.side_effect = [
@@ -129,11 +146,11 @@ class TestConjurLookup(TestCase):
with self.assertRaises(AnsibleError) as context:
self.lookup.run(terms, **kwargs)
- self.assertEqual(
- context.exception.message,
- ("Identity file on the controlling host must contain `login` and `password` "
- "entries for Conjur appliance URL or they should be environment variables")
- )
+
+ self.assertIn(
+ "Configuration must define options `conjur_authn_login` and `conjur_authn_api_key`",
+ context.exception.message,
+ )
@patch('ansible_collections.cyberark.conjur.plugins.lookup.conjur_variable._merge_dictionaries')
def test_run_bad_cert_path(self, mock_merge_dictionaries):
@@ -152,8 +169,48 @@ class TestConjurLookup(TestCase):
with self.assertRaises(AnsibleError) as context:
self.lookup.run([], **kwargs)
- self.assertEqual(context.exception.message, "Invalid secret path: no secret path provided.")
+
+ self.assertEqual(context.exception.message, "Invalid secret path: no secret path provided.")
with self.assertRaises(AnsibleError) as context:
self.lookup.run([''], **kwargs)
- self.assertEqual(context.exception.message, "Invalid secret path: empty secret path not accepted.")
+
+ self.assertEqual(context.exception.message, "Invalid secret path: empty secret path not accepted.")
+
+ @patch('ansible_collections.cyberark.conjur.plugins.lookup.conjur_variable._fetch_conjur_variable')
+ @patch('ansible_collections.cyberark.conjur.plugins.lookup.conjur_variable._fetch_conjur_token')
+ def test_run_missing_account(self, mock_fetch_conjur_token, mock_fetch_conjur_variable):
+ mock_fetch_conjur_token.return_value = "token"
+ mock_fetch_conjur_variable.return_value = ["conjur_variable"]
+
+ variables = {'conjur_cert_file': './conjurfake.pem',
+ 'conjur_authn_login': 'host/ansible/ansible-fake',
+ 'conjur_authn_api_key': 'fakekey'}
+ terms = ['ansible/fake-secret']
+
+ with self.assertRaises(AnsibleError) as context:
+ self.lookup.run(terms, variables)
+
+ self.assertIn(
+ "Configuration must define options `conjur_account` and `conjur_appliance_url`",
+ context.exception.message
+ )
+
+ @patch('ansible_collections.cyberark.conjur.plugins.lookup.conjur_variable._fetch_conjur_variable')
+ @patch('ansible_collections.cyberark.conjur.plugins.lookup.conjur_variable._fetch_conjur_token')
+ def test_run_missing_login(self, mock_fetch_conjur_token, mock_fetch_conjur_variable):
+ mock_fetch_conjur_token.return_value = "token"
+ mock_fetch_conjur_variable.return_value = ["conjur_variable"]
+
+ variables = {'conjur_account': 'fakeaccount',
+ 'conjur_appliance_url': 'https://conjur-fake',
+ 'conjur_cert_file': './conjurfake.pem'}
+ terms = ['ansible/fake-secret']
+
+ with self.assertRaises(AnsibleError) as context:
+ self.lookup.run(terms, variables)
+
+ self.assertIn(
+ "Configuration must define options `conjur_authn_login` and `conjur_authn_api_key`",
+ context.exception.message
+ )