Commit graph

1034 commits

Author SHA1 Message Date
James Cammarata
444987cde6 Fix unit test for plugins after basedir/push_basedir removal 2015-09-10 17:01:52 -04:00
Rene Moser
f6382a160d cloudstack: new integration test role test_cs_user 2015-09-09 22:36:19 +02:00
Toshio Kuratomi
e2c49b4ef4 Fix problem with "=" in the initial file path. 2015-09-09 11:14:31 -07:00
Toshio Kuratomi
3a50393cf7 Merge pull request #12269 from mgedmin/py3k
Python 3: fix TypeError: unorderable types in test
2015-09-08 18:11:31 -07:00
Toshio Kuratomi
c1039de70c Compatibility with six-1.3.0 2015-09-08 09:46:12 -07:00
James Cammarata
ac6f61ec7f Properly handle group/host_var files with dots in them
Fixes #12245
2015-09-08 03:20:09 -04:00
Marius Gedminas
c22f4ee697 Add a comment explaining why async = 1 in the test 2015-09-07 19:46:05 +03:00
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.)
2015-09-07 09:49:28 +03:00
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.
2015-09-04 16:41:38 -04:00
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
2015-09-04 10:36:16 -04:00
Toshio Kuratomi
e218bf8da9 Do not escape backslashes when processing a template file.
Fixes #12198
Fixes #12241
2015-09-03 17:45:17 -07:00
James Cammarata
b2cb3153f1 Fix unit tests for PlayIterator changes regarding fact gathering 2015-09-03 14:25:43 -04:00
Marius Gedminas
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
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.
2015-09-03 09:23:27 +03:00
Toshio Kuratomi
1b64702b9a Fix templar unittests for change in preserve_trailing_newline parameter's default value 2015-09-02 11:58:01 -07:00
James Cammarata
45aac6a739 Adding unit tests for safe_eval 2015-09-02 14:12:06 -04:00
James Cammarata
843138e7d9 Merge pull request #12202 from mgedmin/py3k
Use rich comparisons for Attribute and FieldAttribute
2015-09-02 13:57:04 -04:00
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.
2015-09-02 09:43:42 -07:00
Toshio Kuratomi
417bf1c805 Unittest the _count_trailing_newlines function 2015-09-02 08:59:31 -07:00
Brian Coca
a7231c2203 actually implemented flags correctly for all priv escalation methods 2015-09-02 11:31:39 -04:00
Brian Coca
14f061d5ea fixed become tests 2015-09-02 10:30:00 -04:00
Marius Gedminas
33a374edde Use rich comparisons for Attribute and FieldAttribute
Because __cmp__ is not supported on Python 3.
2015-09-02 12:33:42 +03:00
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
2015-09-01 11:23:12 -07:00
Toshio Kuratomi
7f5080f64a Fix backslash escaping inside of jinja2 expressions
Fixes #11891
2015-08-31 13:17:26 -07:00
James Cammarata
ccaf47bd97 Fix unit tests broken by 057712c1 2015-08-28 16:44:04 -04:00
Brian Coca
514fa73fcd galaxy fixes 2015-08-28 12:32:50 -04:00
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.
2015-08-27 22:15:57 +03:00
Marius Gedminas
709dbbc7db Use 0oNNN octal syntax in test/ 2015-08-27 22:15:57 +03:00
Marius Gedminas
727cb8a917 Support print() function in test/ 2015-08-27 22:15:57 +03:00
Marius Gedminas
9ae66a7f5c Use 'except ... as' syntax in contrib/ and test/ too 2015-08-27 22:15:57 +03:00
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.
2015-08-27 18:36:05 +05:30
Abhijit Menon-Sen
b84053019a Make the filename the first argument to rekey_file 2015-08-26 19:54:59 +05:30
Abhijit Menon-Sen
c4b2540ecc Update tests for VaultEditor API changes 2015-08-26 19:52:20 +05:30
James Cammarata
601a1cc6d9 Multiple fixes for include statements and blocks in general
Fixes #11981
Fixes #11995
Fixes #12039
Fixes #12077
2015-08-26 02:23:22 -04:00
Toshio Kuratomi
9f9891df2c Add unicode characters to the data that we're testing that ansible-vault can decrypt 2015-08-25 15:14:43 -07:00
Toshio Kuratomi
56ae3a032f Merge pull request #12075 from ansible/fix-vault-unicode
Unicode and other fixes for vault
2015-08-25 14:49:15 -07:00
Toshio Kuratomi
a3fd4817ef Unicode and other fixes for vault 2015-08-25 12:43:09 -07:00
Brian Coca
846f0b0510 changed no_log expected type to new value 2015-08-25 10:20:47 -04:00
Brian Coca
3e13dfd7e8 used stdoutlines list to avoid string mismatches
added block environment test
2015-08-25 10:06:24 -04:00
Brian Coca
efa005c228 added names to assert tasks for easier debugging 2015-08-24 22:57:56 -04:00
Brian Coca
d6a1cbeefb corrected varname that started with number and broke templating 2015-08-24 22:44:12 -04:00
Brian Coca
104b8a9a7b avoid hostvars which is not a dict 2015-08-24 22:44:12 -04:00
Brian Coca
857d74a274 made diff ignore whitespace 2015-08-24 22:44:12 -04:00
Brian Coca
6da2587c36 Merge pull request #12058 from resmo/for-ansible
cloudstack: more integration tests and updates
2015-08-24 10:03:58 -04:00
James Cammarata
db65503778 Revert "Add PowerShell exception handling and turn on strict mode." 2015-08-23 21:09:16 -04:00
Rene Moser
69d5e62083 cloudstack: test_cs_account: account_state was renamed, fixes tests 2015-08-23 22:50:23 +02:00
Rene Moser
eb44f85dc8 cloudstack: test_cs_instance: make it more configurable 2015-08-23 22:49:45 +02:00
Rene Moser
15a7f818e1 cloudstack: add more integration tests 2015-08-23 22:48:32 +02:00
Brian Coca
3ccfebc9f7 Merge pull request #12047 from cchurch/powershell_common_cleanup
Add PowerShell exception handling and turn on strict mode.
2015-08-23 14:08:18 -04:00
Ryan Petrello
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
Chris Church
af9200c2de Add integration tests for win_group module. 2015-08-22 18:49:55 -04:00
Chris Church
4b2cdadc98 Add PowerShell exception handling and turn on strict mode.
* Add exception handling when running PowerShell modules to provide exception message and stack trace.
* Enable strict mode for all PowerShell modules and internal commands.
* Update common PowerShell code to fix strict mode errors.
* Fix an issue with Set-Attr where it would not replace an existing property if already set.
* Add tests for exception handling using modified win_ping modules.
2015-08-22 18:28:07 -04:00
Brian Coca
01708cc824 added test for environment directive 2015-08-21 00:37:17 -04:00
Feanil Patel
892e230514 Don't convert nulls to strings.
This change is similar to https://github.com/ansible/ansible/pull/10465

It extends the logic there to also support none types.  Right now if you have
a '!!null' in yaml, and that var gets passed around, it will get converted to
a string.

eg. defaults/main.yml
```
ENABLE_AWESOME_FEATURE: !!null # Yaml Null
OTHER_CONFIG:
  secret1: "so_secret"
  secret2: "even_more_secret"

CONFIG:
  hostname: "some_hostname"
  features:
    awesame_feature: "{{ ENABLE_AWESOME_FEATURE}}"
  secrets: "{{ OTHER_CONFIG }}"
```

If you output `CONFIG` to json or yaml, the feature flag would get represented in the output
as a string instead of as a null, but secrets would get represented as a dictionary.  This is
a mis-match in behaviour where some "types" are retained and others are not.  This change
should fix the issue.

I also updated the template test to test for this and made the changes to v2.

Added a changelog entry specifically for the change from empty string to null as the default.

Made the null representation configurable.

It still defaults to the python NoneType but can be overriden to be an emptystring by updating
the DEFAULT_NULL_REPRESENTATION config.
2015-08-19 18:35:07 -04:00
Rene Moser
9d3577a74a cloudstack: fix tests unhashable type: 'dict' 2015-08-19 21:39:58 +02:00
Rene Moser
8f3c181d90 cloudstack: tests: use resource_prefix 2015-08-19 21:37:54 +02:00
Brian Coca
69f380da3a changed mod_args test to match connection 2015-08-19 00:34:37 -04:00
Jeremy Wells
9f9f476b6e Update consul integration test with http checks 2015-08-19 00:38:36 +02:00
Brian Coca
ab355218a0 fixed test to new parser options 2015-08-18 03:34:38 -04:00
Brian Coca
1acb29ff9b sequence will now run once for start=end, added test to suite
fixes #11979
2015-08-18 02:33:23 -04:00
Brian Coca
ee21ebaffc Merge pull request #11975 from mutemule/become_doas
Add become support for OpenBSD doas
2015-08-17 21:36:03 -04:00
Damian Gerow
1c5611100e Add become support for OpenBSD doas 2015-08-17 21:31:18 -04:00
Brian Coca
43bf9c86d8 fixed typo 2015-08-16 13:15:23 -04:00
Brian Coca
d38bb4152d fixed test to match new exception class used 2015-08-16 10:35:09 -04:00
Brian Coca
2eb5333b50 fixed test to match new become output 2015-08-15 12:26:35 -04:00
Brian Coca
43cc27084d corrected on delete also 2015-08-13 09:58:30 -04:00
Brian Coca
089687140d corrected role path 2015-08-13 09:57:36 -04:00
Brian Coca
033c77a13b now creates/removes files/ dir 2015-08-13 09:54:06 -04:00
Brian Coca
464a436f8f fixed testplay host, included lookup path tests in all, added stage for easier debugging 2015-08-12 19:26:52 -04:00
Brian Coca
60803a1d3c added lookup paths testing 2015-08-12 19:26:52 -04:00
Brian Coca
8f106c9a58 Merge pull request #11078 from Yannig/devel
New lookup plugin : ini
2015-08-07 09:46:54 -04:00
Toshio Kuratomi
e8452c864e Restore the relative path handling portion of #11865 2015-08-06 07:28:22 -07:00
Brian Coca
b9433650d1 Revert "Path of group_vars and host_vars were getting the basedir added twice."
in view of simpler solution incomming from james
This reverts commit bae7a02be5.
2015-08-06 10:09:43 -04:00
Toshio Kuratomi
bae7a02be5 Path of group_vars and host_vars were getting the basedir added twice.
Fix inventory so this won't happen and fix DataLoader so that it will
test relative paths relative to self._basedir

Fixes #11789
2015-08-05 17:41:17 -07:00
Yannig Perré
47db352725 Merge remote-tracking branch 'ansible/devel' into devel 2015-08-05 11:20:41 +02:00
Yannig Perré
c0bd140959 Add documentation for the ini lookup plugin. 2015-08-05 11:09:40 +02:00
Yannig Perré
733d40a77c When value does not exist, return default value instead of stopping ansible with an exception. 2015-08-05 10:54:24 +02:00
James Cammarata
9891bcbcae Fix unit tests broken by previous commit 2015-08-04 12:40:13 -04:00
Brian Coca
aefca24616 Merge pull request #10857 from jeffb-stell/devel
Add test for https://github.com/ansible/ansible/issues/9851
2015-08-03 19:23:59 -04:00
James Cammarata
6b244ed61e update unit tests for role templating changes 2015-08-03 16:33:47 -04:00
James Cammarata
a586c74967 Merge pull request #11838 from cchurch/stringify_powershell_unquote_value
Fix for PowerShell unquote method when passed None.
2015-08-02 22:57:27 -04:00
Chris Church
cafc35fd5b Fix for PowerShell unquote method when passed None. 2015-08-02 18:38:29 -04:00
Chris Church
6969b5ac8b Make sure raw doesn't eat key=value arguments. 2015-08-02 11:57:32 -04:00
Chris Church
2154212491 Merge pull request #11094 from cchurch/test_win_feature_has_servermanager
Only run win_feature tests when the host has the ServerManager module.
2015-07-31 17:52:45 -04:00
Chris Church
e87cf4a3cc Fixes for WinRM/PowerShell support in v2.
- Add support for inserting module args into PowerShell modules.  Fixes #11661.
- Support Windows paths containing spaces.  Applies changes from #10727 to v2.  Fixes #9999.  Should also fix ansible/ansible-modules-core#944 and ansible/ansible-modules-core#1007.
- Change how execution policy is set for running remote scripts.  Applies changes from #11092 to v2.  Also fixes ansible/ansible-modules-core#1776.
- Use codepage 65001 (UTF-8) for WinRM connection instead of default (CP437), convert command to UTF-8 and results from UTF-8.  Replaces changes from #10024.  Fixes #11198.
- Close WinRM connection when task completes.
- Use win_stat, win_file and win_copy modules instead of stat, file and copy when called from within other action plugins (only when using WinRM+PowerShell).
- Unquote Windows path arguments before passing to win_stat, win_file, win_copy and slurp modules (only when using WinRM/PowerShell).
- Check for win_ping module to determine if core modules are missing (only when using WinRM/PowerShell).
- Add stdout_lines to result from running low level commands (so stdout_lines is available when using raw/script).
- Update copy action plugin to use shell functions for joining paths and checking for trailing slash.
- Update fetch action plugin to unquote source path when using Windows paths.
- Add win_copy and win_template action plugins that inherit from copy and template.
- Support running .bat and .cmd scripts using default system encoding instead of UTF-8.
- Always send PowerShell commands as base64-encoded blobs to allow for running simple PowerShell commands via raw.
- Support running modules on Windows with interpreters other than PowerShell.
- Update integration tests to support above changes and test unicode fixes.
- Add test for win_user error from ansible/ansible-modules-core#1241 (fixed by ansible/ansible-modules-core#1774).
- Add test for additional win_stat output values (implemented by ansible/ansible-modules-core#1473).
- Add test for OS architecture and name from setup.ps1 (implemented by ansible/ansible-modules-core#1100).

All WinRM integration tests pass for me with these changes.
2015-07-31 14:38:31 -04:00
Brian Coca
c2d8ca4bf7 fixed test to expected output 2015-07-30 18:36:54 -04:00
Brian Lloyd
07b14b9731 integration tests for windows implementation of lineinfile 2015-07-29 19:50:06 -04:00
James Cammarata
ba56beda90 Fix include task using a potentially undefined variable 2015-07-29 15:49:29 -04:00
James Cammarata
71867f9480 Remove vars attribute from base
Fixes #11779
2015-07-29 09:45:30 -04:00
James Cammarata
42cfacf83b Switch up the task/host overrides for PlayContext to use the compiled vars dict
Fixes #11436
2015-07-28 16:25:44 -04:00
James Cammarata
e505a1b7c4 Fix variable precedence integrationt test 2015-07-28 00:51:58 -04:00
Brian Coca
c76a66694f fixed typo 2015-07-27 22:54:57 -04:00
Michael Scherer
106e942faa Document and test 'is undefined' rather than 'is not defined'
According to https://github.com/ansible/ansible/issues/10273,
this syntax should work better for nested dicts.
2015-07-25 14:05:27 +02:00
James Cammarata
8146a193eb Fix strategy base unit tests after 88e1ef8 2015-07-24 10:53:54 -04:00
Toshio Kuratomi
b06353791c Don't pass mode from synchronize action plugin to the ansible module
Fixes https://github.com/ansible/ansible-modules-core/issues/1783
2015-07-23 00:42:27 -07:00
James Cammarata
993ce592b1 Update unit tests for flush_handlers fix 2015-07-22 11:30:05 -04:00
James Cammarata
66a8864ae9 Fix environment setting and inheritence
Fixes #11401
2015-07-21 13:57:30 -04:00
James Cammarata
46f74a0d69 Re-adding --start-at-task test to unicode integration test 2015-07-21 12:36:41 -04:00
James Cammarata
e64989beb4 Moving ConnectionInformation -> PlayContext
Also making PlayContext a child class of the Playbook Base class,
which gives it access to all of the FieldAttribute code to ensure
field values are correctly typed after post_validation

Fixes #11381
2015-07-21 12:13:50 -04:00
James Cammarata
b09eed3353 Merge branch 'test_notify_with_loops' of https://github.com/pilou-/ansible into pilou--test_notify_with_loops 2015-07-20 21:09:34 -04:00