diff options
author | Kay-Uwe (Kiwi) Lorenz <kiwi@moduleworks.com> | 2021-03-07 15:13:52 +0100 |
---|---|---|
committer | Kay-Uwe (Kiwi) Lorenz <kiwi@moduleworks.com> | 2021-03-07 15:13:52 +0100 |
commit | fc2798fc31a08997c049f609c19dd4ab8d75964e (patch) | |
tree | deeed2598ac9472810aad461a7bd9c50e5ad8fc1 /gitlab/tests/test_config.py | |
parent | b04dd2c08b69619bb58832f40a4c4391e350a735 (diff) | |
download | gitlab-fc2798fc31a08997c049f609c19dd4ab8d75964e.tar.gz |
fix: make secret helper more user friendly
Diffstat (limited to 'gitlab/tests/test_config.py')
-rw-r--r-- | gitlab/tests/test_config.py | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/gitlab/tests/test_config.py b/gitlab/tests/test_config.py index 644b0c1..60c8853 100644 --- a/gitlab/tests/test_config.py +++ b/gitlab/tests/test_config.py @@ -17,6 +17,7 @@ import os import unittest +from textwrap import dedent import mock import io @@ -51,10 +52,6 @@ per_page = 50 [four] url = https://four.url oauth_token = STUV - -[five] -url = https://five.url -oauth_token = lookup: echo "foobar" """ custom_user_agent_config = """[global] @@ -196,16 +193,33 @@ def test_valid_data(m_open, path_exists): assert 2 == cp.timeout assert True == cp.ssl_verify - fd = io.StringIO(valid_config) + +@mock.patch("os.path.exists") +@mock.patch("builtins.open") +def test_data_from_helper(m_open, path_exists, tmp_path): + helper = (tmp_path / "helper.sh") + helper.write_text(dedent("""\ + #!/bin/sh + echo "secret" + """)) + helper.chmod(0o755) + + fd = io.StringIO(dedent("""\ + [global] + default = helper + + [helper] + url = https://helper.url + oauth_token = helper: %s + """) % helper) + fd.close = mock.Mock(return_value=None) m_open.return_value = fd - cp = config.GitlabConfigParser(gitlab_id="five") - assert "five" == cp.gitlab_id - assert "https://five.url" == cp.url + cp = config.GitlabConfigParser(gitlab_id="helper") + assert "helper" == cp.gitlab_id + assert "https://helper.url" == cp.url assert None == cp.private_token - assert "foobar" == cp.oauth_token - assert 2 == cp.timeout - assert True == cp.ssl_verify + assert "secret" == cp.oauth_token @mock.patch("os.path.exists") |