Commit Graph

47 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
Ch3LL
dac16583b7
add test to query results of /jobs call in api 2017-05-10 12:39:17 -04: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
Pedro Algarvio
7b713d9256
Use the more portable helper skip_if_not_root. 2017-04-04 18:58:21 +01:00
Pedro Algarvio
2ee6d5d589
Import from the original modules not tests.integration 2017-04-04 18:58:19 +01:00
Erik Johnson
1cdf5ea737 PY3 compatibility fixes to netapi tests 2017-03-22 16:09:56 -05:00
Pedro Algarvio
7b4d849540
Moved some test supporting modules to tests/support
Previously they were in tests/utils which also had test case modules.
2017-03-02 19:56:05 +00:00
Pedro Algarvio
40a64191a1
Absolute imports and A LOT of code cleanup. 2017-03-01 01:33:07 +00:00
Pedro Algarvio
3beb3fb801
Move whatever we need from salttesting to salt.
Let's drop the salttesting dependency cycle.
2017-02-28 22:52:49 +00: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
Aditya Kulkarni
df6296e3ce Replace args and kwargs (plural) by arg and kwarg (singular) for `RunnerClient` (#32938)
* Replace args and kwargs (plural) by arg and kwarg (singular)

* Add test and deprecation warning

* Add deprecation warning
2016-05-05 07:31:08 -07:00
Justin Findlay
5a4398a746 netapi.rest_cherrypy: use unsalted PW on MacOS (#32850) 2016-04-26 11:04:25 -06:00
rallytime
e8658697a6 Pylint fix for integration import 2016-03-28 16:56:22 -06:00
rallytime
527bc3e491 Pylint fix 2016-03-28 11:24:45 -06:00
rallytime
e9abd2d420 Merge branch '2015.5' into '2015.8'
Conflicts:
  - salt/modules/rh_service.py
2016-03-28 10:51:23 -06:00
Ch3LL
ba605b0128 fix more pylint and add ability to close cherrypy engine 2016-03-25 12:06:39 -06:00
Ch3LL
2d4dc4da05 add teardown call 2016-03-14 16:45:27 -06:00
Ch3LL
d115878714 fix pylint error 2016-03-14 13:45:59 -06:00
root
4c1ab082b6 add pam salt-api tests 2016-03-14 19:19:06 +00:00
Seth House
e47fe835c9 Remove mocks from rest_cherrypy integration tests
These mocks predated the inclusion of salt-api into Salt core. They are
now no longer needed and counter-productive.
2015-09-09 10:39:35 -06: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
Seth House
d68aefcfde Remove mocks from rest_cherrypy integration tests
These mocks predated the inclusion of salt-api into Salt core. They are
now no longer needed and counter-productive.
2015-09-08 15:40:06 -06:00
Seth House
2aa3da8911 Rename the rest_cherrypy tests to conform to our convention
Previously they conformed to the default unittest2 convention.
2015-09-08 15:40:06 -06:00
Colton Myers
befb666623 Merge remote-tracking branch 'upstream/2015.2' into merge-forward-develop
Conflicts:
    salt/modules/mongodb.py
    salt/utils/http.py
    salt/utils/process.py
    tests/integration/__init__.py
2015-04-27 10:28:53 -06:00
rallytime
8d5b50e17c Don't forget the blank lines at the end of the file 2015-04-24 16:29:51 -06:00
rallytime
9830708f86 Some small test clean up changes 2015-04-24 16:27:22 -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
66e2b54f36 Added encoding comment to empty init files 2014-06-19 17:37:44 -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