Commit Graph

481 Commits

Author SHA1 Message Date
21142f5723 Add some tests for split/apply_subscript 2015-09-18 22:15:28 +05:30
2d420a9bb7 Allow hexadecimal ranges in IPv6 addresses, not only 0-9 2015-09-17 23:32:58 +05:30
951128d7a6 Merge branch 'hostpatterns' of https://github.com/amenonsen/ansible into amenonsen-hostpatterns 2015-09-17 13:31:51 -04:00
01ae60d524 Add more tests for _split_pattern for when the input is a list 2015-09-17 13:50:40 -03:00
abd006657b Add test/units/inventory with a few _split_pattern tests
There were no inventory-specific unit tests earlier, so we add a new
directory for them with some initial low-level tests of _split_pattern
with various valid and deprecated pattern strings.
2015-09-17 19:32:14 +05:30
d9f873495e Ported over #7158 to support SELinux context switches. 2015-09-17 15:03:46 +02:00
8548690ca3 Added a test to ensure that sudo is only used if remote and become user difer. 2015-09-17 14:25:52 +02:00
b6d6c2e4db corrected all missing paths changes 2015-09-15 11:57:54 -04:00
36b5858f51 Fix unit tests for change related to local_action 2015-09-14 14:07:17 -04:00
49ca0eb797 Track local_action internally to prevent it from being overridden
Fixes #12053
2015-09-14 12:11:58 -04:00
7479ab47e0 Be stricter about parsing hostname labels
Labels must start with an alphanumeric character, may contain
alphanumeric characters or hyphens, but must not end with a hyphen.
We enforce those rules, but allow underscores wherever hyphens are
accepted, and allow alphanumeric ranges anywhere.

We relax the definition of "alphanumeric" to include Unicode characters
even though such inventory hostnames cannot be used in practice unless
an ansible_ssh_host is set for each of them.

We still don't enforce length restrictions—the fact that we have to
accept ranges makes it more complex, and it doesn't seem especially
worthwhile.
2015-09-11 21:47:19 +05:30
065bb52109 Be systematic about parsing and validating hostnames and addresses
This adds a parse_address(pattern) utility function that returns
(host,port), and uses it wherever where we accept IPv4 and IPv6
addresses and hostnames (or host patterns): the inventory parser
the the add_host action plugin.

It also introduces a more extensive set of unit tests that supersedes
the old add_host unit tests (which didn't actually test add_host, but
only the parsing function).
2015-09-11 21:47:18 +05:30
f91b28ef23 Fix safe_eval() of set literals
There was code to support set literals (on Python 2.7 and newer), but it
was buggy: SAFE_NODES.union() doesn't modify SAFE_NODES in place,
instead it returns a new set object that is then silently discarded.

I added a unit test and fixed the code.  I also changed the version
check to use sys.version_tuple instead of a string comparison, for
consistency with the subsequent Python 3.4 version check that I added in
the previous commit.
2015-09-11 09:41:05 +03:00
444987cde6 Fix unit test for plugins after basedir/push_basedir removal 2015-09-10 17:01:52 -04:00
e2c49b4ef4 Fix problem with "=" in the initial file path. 2015-09-09 11:14:31 -07:00
3a50393cf7 Merge pull request #12269 from mgedmin/py3k
Python 3: fix TypeError: unorderable types in test
2015-09-08 18:11:31 -07:00
c1039de70c Compatibility with six-1.3.0 2015-09-08 09:46:12 -07:00
ac6f61ec7f Properly handle group/host_var files with dots in them
Fixes #12245
2015-09-08 03:20:09 -04:00
c22f4ee697 Add a comment explaining why async = 1 in the test 2015-09-07 19:46:05 +03:00
1a1c9203e2 Python 3: fix TypeError: unorderable types in test
The full error was

======================================================================
ERROR: test_task_executor_execute (units.executor.test_task_executor.TestTaskExecutor)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/mg/src/ansible/test/units/executor/test_task_executor.py", line 252, in test_task_executor_execute
    mock_action.run.return_value = dict(ansible_facts=dict())
  File "/home/mg/src/ansible/lib/ansible/executor/task_executor.py", line 317, in _execute
    if self._task.async > 0:
TypeError: unorderable types: MagicMock() > int()

----------------------------------------------------------------------

Experiments show that Python 2 MagicMock() > 0 is true, so I'm setting
the async property on mock_task to 1.  (If I set it to 0, the test fails
anyway.)
2015-09-07 09:49:28 +03:00
ff9f5d7dc8 Starting to add additional unit tests for VariableManager
Required some rewiring in inventory code to make sure we're using
the DataLoader class for some data file operations, which makes mocking
them much easier.

Also identified two corner cases not currently handled by the code, related
to inventory variable sources and which one "wins". Also noticed we weren't
properly merging variables from multiple group/host_var file locations
(inventory directory vs. playbook directory locations) so fixed as well.
2015-09-04 16:41:38 -04:00
c17fbf2f12 simplify become testing and handling, we had drifted and were doulbe checking prompt, become and become_pass
fixed tests to conform to new signature and now tests both with and w/o password
now we are more explicit about self.prompt
2015-09-04 10:36:16 -04:00
e218bf8da9 Do not escape backslashes when processing a template file.
Fixes #12198
Fixes #12241
2015-09-03 17:45:17 -07:00
b2cb3153f1 Fix unit tests for PlayIterator changes regarding fact gathering 2015-09-03 14:25:43 -04:00
a32bf1ec18 Simplify FactCache.copy()
Also fix the bug (missing from six import iteritems) I introduced in
823677b490.
2015-09-03 09:44:44 +03:00
823677b490 Replace .iteritems() with six.iteritems()
Replace .iteritems() with six.iteritems() everywhere except in
module_utils (because there's no 'six' on the remote host).  And except
in lib/ansible/galaxy/data/metadata_template.j2, because I'm not sure
six is available there.
2015-09-03 09:23:27 +03:00
1b64702b9a Fix templar unittests for change in preserve_trailing_newline parameter's default value 2015-09-02 11:58:01 -07:00
45aac6a739 Adding unit tests for safe_eval 2015-09-02 14:12:06 -04:00
843138e7d9 Merge pull request #12202 from mgedmin/py3k
Use rich comparisons for Attribute and FieldAttribute
2015-09-02 13:57:04 -04:00
9ecfc30f9a * Mark all strings as unicode -- shouldn't matter for this dataset but
ansible is passing unicode arond internally so we should test the same
  data.
* Add a zero length test for _count_newlines and fix the zero newlines
  test to have no newlines.
2015-09-02 09:43:42 -07:00
417bf1c805 Unittest the _count_trailing_newlines function 2015-09-02 08:59:31 -07:00
a7231c2203 actually implemented flags correctly for all priv escalation methods 2015-09-02 11:31:39 -04:00
14f061d5ea fixed become tests 2015-09-02 10:30:00 -04:00
33a374edde Use rich comparisons for Attribute and FieldAttribute
Because __cmp__ is not supported on Python 3.
2015-09-02 12:33:42 +03:00
aeff960d02 Cleanup combine_vars
* Dedupe combine_vars() code (removed from VariableManager)
* Fix merge_hash algorithm to preserve the type
* unittest combine_vars and merge_hash
2015-09-01 11:23:12 -07:00
7f5080f64a Fix backslash escaping inside of jinja2 expressions
Fixes #11891
2015-08-31 13:17:26 -07:00
ccaf47bd97 Fix unit tests broken by 057712c1 2015-08-28 16:44:04 -04:00
709dbbc7db Use 0oNNN octal syntax in test/ 2015-08-27 22:15:57 +03:00
4f3a98eff6 Update Vault tests to make sure AES decryption works
Note that this test was broken in devel because it was really just
duplicating the AES256 test because setting v.cipher_name to 'AES'
no longer selected AES after it was de-write-whitelisted.

Now that we've removed the VaultAES encryption code, we embed static
output from an earlier version and test that we can decrypt it.
2015-08-27 18:36:05 +05:30
b84053019a Make the filename the first argument to rekey_file 2015-08-26 19:54:59 +05:30
c4b2540ecc Update tests for VaultEditor API changes 2015-08-26 19:52:20 +05:30
56ae3a032f Merge pull request #12075 from ansible/fix-vault-unicode
Unicode and other fixes for vault
2015-08-25 14:49:15 -07:00
a3fd4817ef Unicode and other fixes for vault 2015-08-25 12:43:09 -07:00
846f0b0510 changed no_log expected type to new value 2015-08-25 10:20:47 -04:00
1886307845 Fix a parsing bug that prevents IPv6 addresses from being used with add_host
Closes #8682
2015-08-23 22:50:47 +05:30
69f380da3a changed mod_args test to match connection 2015-08-19 00:34:37 -04:00
ab355218a0 fixed test to new parser options 2015-08-18 03:34:38 -04:00
ee21ebaffc Merge pull request #11975 from mutemule/become_doas
Add become support for OpenBSD doas
2015-08-17 21:36:03 -04:00
1c5611100e Add become support for OpenBSD doas 2015-08-17 21:31:18 -04:00
43bf9c86d8 fixed typo 2015-08-16 13:15:23 -04:00