Commit Graph

992 Commits (a1948dd1c151f01ce93d0b76745469a7065ef45e)

Author SHA1 Message Date
James Cammarata d818a72375 Merge branch 'normalize_plugin_paths' of https://github.com/bcoca/ansible into bcoca-normalize_plugin_paths 9 years ago
Chris Church 15070e2af8 Merge pull request #11790 from brianlloyd/win_lineinfile
Integration tests for windows implementation of lineinfile
9 years ago
Brian Coca b6d6c2e4db corrected all missing paths changes 9 years ago
James Cammarata 36b5858f51 Fix unit tests for change related to local_action 9 years ago
James Cammarata 49ca0eb797 Track local_action internally to prevent it from being overridden
Fixes #12053
9 years ago
Abhijit Menon-Sen 88a20e7a20 Fix broken integration test with unicode hostnames
1. The test did "name: '{{hostnames}}.{{item}}'" inside a with_sequence
   loop, which didn't do what was intended: it expanded hostnames into
   an array, appended ".1", and set name to the resulting string. This
   can be converted to a simple with_items loop.

2. Some of the entries in hostnames contained punctuation characters,
   which I see no reason to support in inventory hostnames anyway.

3. Once the add_host failures are fixed, the playbook later fails when
   the unicode hostnames are interpolated into debug output in ssh.py
   due to an encoding error. This is only one of the many places that
   may fail when using unicode inventory hostnames; we work around it
   by providing an ansible_ssh_host setting.
9 years ago
Abhijit Menon-Sen 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.
9 years ago
Abhijit Menon-Sen 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).
9 years ago
Marius Gedminas 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.
9 years ago
Brian Coca 5809a2e81d Merge pull request #12299 from resmo/feature/test_cs_user
cloudstack: new integration test role test_cs_user
9 years ago
James Cammarata 444987cde6 Fix unit test for plugins after basedir/push_basedir removal 9 years ago
Rene Moser f6382a160d cloudstack: new integration test role test_cs_user 9 years ago
Toshio Kuratomi e2c49b4ef4 Fix problem with "=" in the initial file path. 9 years ago
Toshio Kuratomi 3a50393cf7 Merge pull request #12269 from mgedmin/py3k
Python 3: fix TypeError: unorderable types in test
9 years ago
Toshio Kuratomi c1039de70c Compatibility with six-1.3.0 9 years ago
James Cammarata ac6f61ec7f Properly handle group/host_var files with dots in them
Fixes #12245
9 years ago
Marius Gedminas c22f4ee697 Add a comment explaining why async = 1 in the test 9 years ago
Marius Gedminas 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.)
9 years ago
James Cammarata 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.
9 years ago
Brian Coca 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
9 years ago
Toshio Kuratomi e218bf8da9 Do not escape backslashes when processing a template file.
Fixes #12198
Fixes #12241
9 years ago
James Cammarata b2cb3153f1 Fix unit tests for PlayIterator changes regarding fact gathering 9 years ago
Marius Gedminas a32bf1ec18 Simplify FactCache.copy()
Also fix the bug (missing from six import iteritems) I introduced in
823677b490.
9 years ago
Marius Gedminas 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.
9 years ago
Toshio Kuratomi 1b64702b9a Fix templar unittests for change in preserve_trailing_newline parameter's default value 9 years ago
James Cammarata 45aac6a739 Adding unit tests for safe_eval 9 years ago
James Cammarata 843138e7d9 Merge pull request #12202 from mgedmin/py3k
Use rich comparisons for Attribute and FieldAttribute
9 years ago
Toshio Kuratomi 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.
9 years ago
Toshio Kuratomi 417bf1c805 Unittest the _count_trailing_newlines function 9 years ago
Brian Coca a7231c2203 actually implemented flags correctly for all priv escalation methods 9 years ago
Brian Coca 14f061d5ea fixed become tests 9 years ago
Marius Gedminas 33a374edde Use rich comparisons for Attribute and FieldAttribute
Because __cmp__ is not supported on Python 3.
9 years ago
Toshio Kuratomi 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
9 years ago
Toshio Kuratomi 7f5080f64a Fix backslash escaping inside of jinja2 expressions
Fixes #11891
9 years ago
James Cammarata ccaf47bd97 Fix unit tests broken by 057712c1 9 years ago
Brian Coca 514fa73fcd galaxy fixes 9 years ago
Marius Gedminas c846bab69b Fix assert statement syntax
`assert (condition, message)` gets parsed by Python as `assert
a_two_tuple`, and a 2-element tuple is never False.

Discovered by compileall on Python 3.4, which emits a SyntaxWarning for
this common mistake.
9 years ago
Marius Gedminas 709dbbc7db Use 0oNNN octal syntax in test/ 9 years ago
Marius Gedminas 727cb8a917 Support print() function in test/ 9 years ago
Marius Gedminas 9ae66a7f5c Use 'except ... as' syntax in contrib/ and test/ too 9 years ago
Abhijit Menon-Sen 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.
9 years ago
Abhijit Menon-Sen b84053019a Make the filename the first argument to rekey_file 9 years ago
Abhijit Menon-Sen c4b2540ecc Update tests for VaultEditor API changes 9 years ago
James Cammarata 601a1cc6d9 Multiple fixes for include statements and blocks in general
Fixes #11981
Fixes #11995
Fixes #12039
Fixes #12077
9 years ago
Toshio Kuratomi 9f9891df2c Add unicode characters to the data that we're testing that ansible-vault can decrypt 9 years ago
Toshio Kuratomi 56ae3a032f Merge pull request #12075 from ansible/fix-vault-unicode
Unicode and other fixes for vault
9 years ago
Toshio Kuratomi a3fd4817ef Unicode and other fixes for vault 9 years ago
Brian Coca 846f0b0510 changed no_log expected type to new value 9 years ago
Brian Coca 3e13dfd7e8 used stdoutlines list to avoid string mismatches
added block environment test
9 years ago
Brian Coca efa005c228 added names to assert tasks for easier debugging 9 years ago