cli2 4.0.2__tar.gz → 4.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {cli2-4.0.2/cli2.egg-info → cli2-4.0.4}/PKG-INFO +1 -1
- {cli2-4.0.2 → cli2-4.0.4}/cli2/ansible/action.py +3 -4
- {cli2-4.0.2 → cli2-4.0.4}/cli2/client.py +2 -0
- {cli2-4.0.2 → cli2-4.0.4/cli2.egg-info}/PKG-INFO +1 -1
- {cli2-4.0.2 → cli2-4.0.4}/setup.py +1 -1
- {cli2-4.0.2 → cli2-4.0.4}/tests/test_ansible.py +19 -15
- {cli2-4.0.2 → cli2-4.0.4}/tests/test_client.py +30 -0
- {cli2-4.0.2 → cli2-4.0.4}/MANIFEST.in +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/README.rst +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/classifiers.txt +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/__init__.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/ansible/__init__.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/ansible/playbook.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/ansible/pytest.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/asyncio.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/cli.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/cli2.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/colors.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/configuration.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/decorators.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/display.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/examples/__init__.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/examples/client.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/examples/conf.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/examples/example.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/examples/example_obj.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/examples/nesting.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/examples/obj.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/examples/obj2.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/examples/test.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/lock.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/log.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/node.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/sphinx.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/table.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2/test.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2.egg-info/SOURCES.txt +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2.egg-info/dependency_links.txt +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2.egg-info/entry_points.txt +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2.egg-info/requires.txt +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/cli2.egg-info/top_level.txt +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/setup.cfg +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/tests/test_cli.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/tests/test_command.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/tests/test_configuration.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/tests/test_decorators.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/tests/test_display.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/tests/test_entry_point.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/tests/test_group.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/tests/test_inject.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/tests/test_lock.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/tests/test_node.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/tests/test_restful.py +0 -0
- {cli2-4.0.2 → cli2-4.0.4}/tests/test_table.py +0 -0
|
@@ -127,8 +127,8 @@ class ActionBase(ActionBase):
|
|
|
127
127
|
The client object generated by :py:meth:`client_factory` if you
|
|
128
128
|
implement it.
|
|
129
129
|
"""
|
|
130
|
-
def get(self, arg_name, fact_name=None, default=UNSET_DEFAULT):
|
|
131
|
-
if arg_name in self._task.args:
|
|
130
|
+
def get(self, arg_name=None, fact_name=None, default=UNSET_DEFAULT):
|
|
131
|
+
if arg_name and arg_name in self._task.args:
|
|
132
132
|
return self._task.args[arg_name]
|
|
133
133
|
if fact_name and fact_name in self.task_vars:
|
|
134
134
|
return self.task_vars[fact_name]
|
|
@@ -240,12 +240,11 @@ class ActionBase(ActionBase):
|
|
|
240
240
|
from unittest import mock
|
|
241
241
|
obj = cls(*[mock.Mock()] * 6)
|
|
242
242
|
obj.tmp = None
|
|
243
|
-
obj.task_vars = mock.Mock()
|
|
244
243
|
obj.result = dict()
|
|
245
244
|
obj._task = mock.Mock()
|
|
246
245
|
obj._task.args = args or {}
|
|
247
246
|
obj.task_vars = facts or {}
|
|
248
|
-
obj.task_vars
|
|
247
|
+
obj.task_vars.setdefault('ansible_verbosity', 2)
|
|
249
248
|
obj.exc = False
|
|
250
249
|
if client:
|
|
251
250
|
async def _factory():
|
|
@@ -1565,6 +1565,8 @@ class Client(metaclass=ClientMetaclass):
|
|
|
1565
1565
|
data[key] = '***MASKED***'
|
|
1566
1566
|
if isinstance(value, dict):
|
|
1567
1567
|
data[key] = self.mask_data(value, mask)
|
|
1568
|
+
if isinstance(value, list):
|
|
1569
|
+
data[key] = [self.mask_data(item, mask) for item in value]
|
|
1568
1570
|
return data
|
|
1569
1571
|
|
|
1570
1572
|
return data
|
|
@@ -39,30 +39,34 @@ async def test_response_error(httpx_mock):
|
|
|
39
39
|
@pytest.mark.asyncio
|
|
40
40
|
async def test_option():
|
|
41
41
|
class Action(ansible.ActionBase):
|
|
42
|
-
|
|
42
|
+
fact = ansible.Option(fact='fact', default='default fact')
|
|
43
|
+
arg = ansible.Option(arg='arg', fact='arg_fact')
|
|
43
44
|
|
|
44
45
|
async def run_async(self):
|
|
45
|
-
self.result['
|
|
46
|
-
|
|
47
|
-
module = await Action.run_test_async(args=dict(name='foo'))
|
|
48
|
-
assert module.result['name'] == 'foo'
|
|
46
|
+
self.result['arg'] = self.arg
|
|
47
|
+
self.result['fact'] = self.fact
|
|
49
48
|
|
|
50
|
-
module = await Action.run_test_async(facts=dict(object_name='foo'))
|
|
51
|
-
assert module.result['name'] == 'foo'
|
|
52
49
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
# test setting arg and fact
|
|
51
|
+
module = await Action.run_test_async(
|
|
52
|
+
args=dict(arg='arg'),
|
|
53
|
+
facts=dict(fact='fact'),
|
|
54
|
+
)
|
|
55
|
+
assert module.result['arg'] == 'arg'
|
|
56
|
+
assert module.result['fact'] == 'fact'
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
# test default
|
|
59
|
+
module = await Action.run_test_async(
|
|
60
|
+
args=dict(arg='arg'),
|
|
61
|
+
)
|
|
62
|
+
assert module.result['arg'] == 'arg'
|
|
63
|
+
assert module.result['fact'] == 'default fact'
|
|
61
64
|
|
|
65
|
+
# test failing for missing default
|
|
62
66
|
module = await Action.run_test_async(fail=True)
|
|
63
67
|
assert module.result == dict(
|
|
64
68
|
failed=True,
|
|
65
|
-
error="Missing arg `
|
|
69
|
+
error="Missing arg `arg` or fact `arg_fact`",
|
|
66
70
|
)
|
|
67
71
|
|
|
68
72
|
class Action(ansible.ActionBase):
|
|
@@ -854,6 +854,36 @@ def test_datetime_default_fmt(client_class):
|
|
|
854
854
|
assert model.data['dt'] == str_dt
|
|
855
855
|
|
|
856
856
|
|
|
857
|
+
@pytest.mark.asyncio
|
|
858
|
+
async def test_mask_recursive(client_class):
|
|
859
|
+
client = client_class(mask=['scrt', 'password'])
|
|
860
|
+
client.client.send = mock.AsyncMock()
|
|
861
|
+
|
|
862
|
+
client.logger = mock.Mock()
|
|
863
|
+
response = httpx.Response(
|
|
864
|
+
status_code=200,
|
|
865
|
+
content='{"pub": 1, "foo": [{"scrt": "pass"}]}',
|
|
866
|
+
)
|
|
867
|
+
data = [dict(foo=[dict(src='pass')])]
|
|
868
|
+
response.request = httpx.Request('POST', '/', json=data)
|
|
869
|
+
client.client.send.return_value = response
|
|
870
|
+
await client.post('/', json=data)
|
|
871
|
+
client.logger.bind.assert_called_once_with(
|
|
872
|
+
method='POST',
|
|
873
|
+
url='http://lol/',
|
|
874
|
+
)
|
|
875
|
+
log = client.logger.bind.return_value
|
|
876
|
+
log.debug.assert_called_once_with(
|
|
877
|
+
'request',
|
|
878
|
+
json=[{'foo': [{'src': 'pass'}]}],
|
|
879
|
+
)
|
|
880
|
+
log.info.assert_called_once_with(
|
|
881
|
+
'response',
|
|
882
|
+
status_code=200,
|
|
883
|
+
json={'pub': 1, 'foo': [{'scrt': '***MASKED***'}]},
|
|
884
|
+
)
|
|
885
|
+
|
|
886
|
+
|
|
857
887
|
@pytest.mark.asyncio
|
|
858
888
|
@pytest.mark.parametrize(
|
|
859
889
|
'key', ('json', 'data'),
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|