Commit Graph

25 Commits

Author SHA1 Message Date
Erik Johnson
7b13a7df8b
Replace json module usage with a helper to ensure unicode content is handled properly
This adds wrappers for json.dump{,s} which disable `ensure_ascii` by
default.
2017-12-27 09:30:58 -06:00
Erik Johnson
877abb89d0
Complete the salt.utils refactor
This moves the remaining 30 functions from salt.utils to new locations.
2017-10-15 09:43:31 -05:00
Erik Johnson
3184168365 Use explicit unicode strings + break up salt.utils
This PR is part of what will be an ongoing effort to use explicit
unicode strings in Salt. Because Python 3 does not suport Python 2's raw
unicode string syntax (i.e. `ur'\d+'`), we must use
`salt.utils.locales.sdecode()` to ensure that the raw string is unicode.
However, because of how `salt/utils/__init__.py` has evolved into the
hulking monstrosity it is today, this means importing a large module in
places where it is not needed, which could negatively impact
performance. For this reason, this PR also breaks out some of the
functions from `salt/utils/__init__.py` into new/existing modules under
`salt/utils/`. The long term goal will be that the modules within this
directory do not depend on importing `salt.utils`.

A summary of the changes in this PR is as follows:

* Moves the following functions from `salt.utils` to new locations
  (including a deprecation warning if invoked from `salt.utils`):
  `to_bytes`, `to_str`, `to_unicode`, `str_to_num`, `is_quoted`,
  `dequote`, `is_hex`, `is_bin_str`, `rand_string`,
  `contains_whitespace`, `clean_kwargs`, `invalid_kwargs`, `which`,
  `which_bin`, `path_join`, `shlex_split`, `rand_str`, `is_windows`,
  `is_proxy`, `is_linux`, `is_darwin`, `is_sunos`, `is_smartos`,
  `is_smartos_globalzone`, `is_smartos_zone`, `is_freebsd`, `is_netbsd`,
  `is_openbsd`, `is_aix`
* Moves the functions already deprecated by @rallytime to the bottom of
  `salt/utils/__init__.py` for better organization, so we can keep the
  deprecated ones separate from the ones yet to be deprecated as we
  continue to break up `salt.utils`
* Updates `salt/*.py` and all files under `salt/client/` to use explicit
  unicode string literals.
* Gets rid of implicit imports of `salt.utils` (e.g. `from salt.utils
  import foo` becomes `import salt.utils.foo as foo`).
* Renames the `test.rand_str` function to `test.random_hash` to more
  accurately reflect what it does
* Modifies `salt.utils.stringutils.random()` (née `salt.utils.rand_string()`)
  such that it returns a string matching the passed size. Previously
  this function would get `size` bytes from `os.urandom()`,
  base64-encode it, and return the result, which would in most cases not
  be equal to the passed size.
2017-08-08 13:33:43 -05:00
Erik Johnson
b7cc420e6f decode to string before trying to load JSON 2017-05-16 14:20:05 -05:00
rallytime
d4e42b8e74 Use cptc.BaseRestCherryPyTest as test class 2017-05-11 09:09:40 -06:00
rallytime
12a75c1108 Merge branch '2016.11' into 'nitrogen'
No conflicts.
2017-05-10 15:32:23 -06:00
Pedro Algarvio
80b80e5416
Fix cherrypy memory leakage
* Clean its event/signal bus since our tests don't rely on those.
* No test class level dictionaries
2017-04-28 13:33:35 +01:00
Erik Johnson
1cdf5ea737 PY3 compatibility fixes to netapi tests 2017-03-22 16:09:56 -05:00
Pedro Algarvio
1daa2e24cd
Moved some test supporting modules to tests/support
Previously they were in tests/utils which also had test case modules.
2017-02-28 22:52:48 +00:00
Pedro Algarvio
15af4c9728
Test filenames conformity. Adjust for pytest. 2017-02-23 23:19:42 +00:00
Seth House
6d22514934 Rename the rest_cherrypy tests to conform to our convention
Previously they conformed to the default unittest2 convention.
2015-09-09 10:39:34 -06:00
Pedro Algarvio
60f215f191 Add from __future__ import absolute_import 2015-01-30 22:25:04 +00:00
Pedro Algarvio
e45033b993 Make PyLint ignore unused imports 2014-11-20 16:40:47 +00:00
Pedro Algarvio
6b19c7b03e Use urlencode from six 2014-11-20 16:40:45 +00:00
Pedro Algarvio
5e4eb4bbaf Don't add tests in __init__ 2014-10-08 01:02:10 +01:00
Seth House
2b5bed43b9 Add integration test for logging out of the rest_cherrypy app 2014-08-15 09:45:30 -04:00
Seth House
63be4efae9 Added basic smoke-tests for the rest_cherrypy /run entrypoint 2014-07-14 22:11:20 -06:00
Seth House
2dad062f8a Move rest_cherrypy mocked methods into individual tests 2014-07-14 20:18:21 -06:00
Pedro Algarvio
db58cbd8ca Ignore import 2014-06-30 01:03:36 +01:00
Seth House
f18a636628 Raise a 401 reponse instead of redirecting to the login page
Also fixed bad tests that should have caught this.

Fixes saltstack/salt-api#155.
2014-06-27 14:03:34 -06:00
Seth House
d00cd104ac And yet more pylint fixes 2014-06-19 17:25:56 -06:00
Pedro Algarvio
7590586d05 Don't fail on missing CherryPy 2014-06-19 13:00:38 +01:00
Seth House
d526c9ec2b Mock fire_event() in test to check auth setting 2014-06-18 16:52:14 -06:00
Seth House
d24cf41b62 Added integration tests for webhook auth enable/disable 2014-04-08 13:51:33 -06:00
Seth House
0a1a21df17 First stab at integration tests for the rest_cherrypy netapi module 2014-03-31 09:58:56 -06:00