ansible/lib/ansible
Toshio Kuratomi 5e9a8d9202 Fix password lookup py3 plus alikins unittest additions refactoring (#17626)
* Improve unit testing of 'password' lookup

The tests showed some UnicodeErrors for the
cases where the 'chars' param include unicode,
causing the 'getattr(string, c, c)' to fail.
So the candidate char generation code try/excepts
UnicodeErrors there now.

Some refactoring of the password.py module to make
it easier to test, and some new tests that cover more
of the password and salt generation.

* More refactoring and fixes.

* manual merge of text enc fixes from pr17475

* moving methods to module scope

* more refactoring

* A few more text encoding fixes/merges

* remove now unused code

* Add test cases and data for _gen_candidate_chars

* more test coverage for password lookup

* wip

* More text encoding fixes and test coverage

* cleanups

* reenable text_type assert

* Remove unneeded conditional in _random_password

* Add docstring for _gen_candidate_chars

* remove redundant to_text and list comphenesion

* Move set of 'chars' default in _random_password

on py2, C.DEFAULT_PASSWORD_CHARS is a regular str
type, so the assert here fails. Move setting the
default into the method and to_text(DEFAULT_PASSWORD_CHARS)
if it's needed.

* combine _random_password and _gen_password

* s/_create_password_file/_create_password_file_dir

* native strings for exception msgs

* move password to_text to _read_password_file

* move to_bytes(content) to _write_password_file

* add more test assertions about genned pw's

* Some cleanups to alikins and abadger's password lookup refactoring:

* Make DEFAULT_PASSWORD_CHARS into a text string in constants.py
  - Move this into the nonconfigurable section of constants.
* Make utils.encrypt.do_encrypt() return a text string because all the
  hashes in passlib should be returning ascii-only strings and they are
  text strings in python3.
* Make the split up of functions more sane:
   - Don't split such that conditionals have to occur in two separate functions.
   - Don't go overboard: Good to split file system manipulation from parsing
     but we don't need to do every file manipulation in a separate
     function.
  - Don't split so that creation of the password store happens in two
    parts.
  - Don't split in such a way that no decisions are made in run.
* Organize functions by when it gets called from run().
* Run all potential characters through the gen_candidate_chars function
  because it does both normalization and validation.
* docstrings for functions
* Change when we store salt slightly.  Store it whenever it was already
  present in the file as well as when encrypt is requested.  This will
  head of potential idempotence bugs where a user has two playbook tasks
  using the same password and in one they need it encrypted but in the
  other they need it plaintext.
* Reorganize tests to follow the order of the functions so it's easier
  to figure out if/where a function has been tested.
* Add tests for the functions that read and write the password file.
* Add tests of run() when the password has already been created.
* Test coverage currently at 100%
2016-09-19 11:37:57 -07:00
..
cli win_shell/win_command changes + tests (#17557) 2016-09-15 11:25:56 -07:00
compat Move py34 mock_open compat to compat/test/mock (#17157) 2016-08-19 18:11:24 -04:00
config
errors Move uses of to_bytes, to_text, to_native to use the module_utils version (#17423) 2016-09-06 22:54:17 -07:00
executor remove bare variable support from loops (#17519) 2016-09-16 12:54:52 -04:00
galaxy Iterate through role paths when installing roles (#17487) 2016-09-09 16:50:50 -04:00
inventory Improve inventory script error messages. (#17589) 2016-09-15 15:42:57 -04:00
module_utils update facts.py for aix (#17539) 2016-09-19 12:20:29 -04:00
modules Update submodule refs. 2016-09-16 16:25:47 -07:00
parsing Fix dataloader using deprecated version of is_encrypted (#17615) 2016-09-17 00:45:29 -07:00
playbook Fix dataloader using deprecated version of is_encrypted (#17615) 2016-09-17 00:45:29 -07:00
plugins Fix password lookup py3 plus alikins unittest additions refactoring (#17626) 2016-09-19 11:37:57 -07:00
template Support late evaluation, suppress warnings on SyntaxError (#17462) 2016-09-09 09:33:23 -04:00
utils Fix password lookup py3 plus alikins unittest additions refactoring (#17626) 2016-09-19 11:37:57 -07:00
vars include_vars now properly deals with hash_behaviour (#15895) 2016-09-16 15:40:38 -04:00
__init__.py
constants.py Fix password lookup py3 plus alikins unittest additions refactoring (#17626) 2016-09-19 11:37:57 -07:00
release.py
test-requirements.txt