Commit Graph

100 Commits

Author SHA1 Message Date
Erik Johnson
80dcb44a0d
Merge remote-tracking branch 'upstream/2018.3' into merge-fluorine
Conflicts:
- salt/utils/mac_utils.py
- tests/unit/config/test_config.py
- tests/unit/loader/test_globals.py
- tests/unit/ssh/test_ssh.py
- tests/unit/templates/test_jinja.py
- tests/unit/utils/vmware/test_host.py
- tests/unit/utils/vmware/test_license.py
2018-08-17 07:52:59 -05:00
Erik Johnson
516594b164
Consolidate netapi tests and move them to reflect naming convention 2018-08-14 13:53:30 -05:00
rallytime
0eab957281
Merge branch '2018.3' into 'develop'
Conflicts:
  - salt/netapi/rest_tornado/saltnado.py
  - tests/integration/states/test_file.py
  - tests/integration/states/test_git.py
  - tests/unit/modules/test_tls.py
2018-04-20 15:40:49 -04:00
rallytime
bee4948df1
Lint: use full path for event utils function 2018-04-20 09:35:33 -04:00
rallytime
4718d31e53
Merge branch '2017.7' into '2018.3'
Conflicts:
  - salt/config/__init__.py
  - salt/minion.py
  - salt/modules/pip.py
  - salt/states/pip_state.py
  - salt/states/virtualenv_mod.py
  - tests/integration/modules/test_status.py
2018-04-19 17:15:20 -04:00
kstreee
0624aee0ed
Fixes misusing of the timeout option. 2018-04-17 14:21:15 +09:00
Matt Phillips
c2ef045e5c fix syndic_wait handling in saltnado in syndic topologies
as is, yielding sleep before registering the event listener as actually causing
saltnado to _miss_ the event entirely. instead of waiting before registering,
instead we just add the syndic_wait to the futures base timeout.
2018-04-06 11:13:41 -04:00
rallytime
d83727fdf9
Merge branch '2017.7' into '2018.3'
Conflicts:
  - salt/cli/api.py
  - salt/client/ssh/wrapper/state.py
  - salt/config/__init__.py
  - salt/crypt.py
  - salt/daemons/masterapi.py
  - salt/key.py
  - salt/loader.py
  - salt/master.py
  - salt/modules/archive.py
  - salt/modules/hipchat.py
  - salt/modules/pip.py
  - salt/modules/state.py
  - salt/modules/virt.py
  - salt/modules/x509.py
  - salt/state.py
  - salt/transport/tcp.py
  - salt/transport/zeromq.py
  - salt/utils/__init__.py
  - salt/utils/event.py
  - salt/utils/extmods.py
  - salt/utils/files.py
  - salt/utils/parsers.py
  - salt/utils/verify.py
  - tests/integration/shell/test_call.py
  - tests/unit/utils/test_args.py
2018-03-06 13:45:59 -05:00
GwiYeong
45d663f435
fix for local client timeout bug 2018-02-12 13:00:22 +09:00
Erik Johnson
002aa88a97
Replace yaml usage with a helper to ensure unicode is handled properly
Without allow_unicode=True, unicode characters are processed through the
str representer and on Python 2 are dumped as a Unicode code point (i.e.
a literal \u0414). This commit makes allow_unicode=True the default in
our salt.utils.yamlloader.safe_dump() helper. It also adds a new
salt.utils.yamlloader.dump() helper which wraps yaml.dump() and also
makes allow_unicode=True the default.

To make importing and using our custom yaml loader/dumper easier, a
convenience module called salt.utils.yaml has been added, which does a
wildcard import from both salt.utils.yamldumper and
salt.utils.yamlloader.

Refs to yaml.load/dump and yaml.safe_load/safe_dump have been updated to
salt.utils.yaml, to ensure that unicode is handled properly.
2018-01-03 14:14:21 -06:00
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
kstreee
e210f12cb7
Fixes inconsistent exception handling in rest_tornado. 2017-10-19 02:22:23 +09: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
Pedro Algarvio
abe608d739
Drop @patch usage 2017-04-28 13:36:42 +01: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
6364128ad3
Fix tornado test cases 2017-04-28 13:33:34 +01:00
Pedro Algarvio
8031ac0209
Move mixins to tests.support.mixins.
The adapted config mixin get config methods are not static methods
2017-04-04 17:29:34 +01:00
Pedro Algarvio
d198a900a4
Remove unused imports 2017-04-01 19:01:09 +01:00
Pedro Algarvio
2ebd04e7ce
Use a temporary configuration 2017-04-01 14:26:11 +01:00
Pedro Algarvio
c28f896adb
Py3 compat 2017-04-01 14:22:57 +01:00
Pedro Algarvio
9b1e55aa85
Import the full module namespace to avoid import shadowing.
https://github.com/saltstack/salt/pull/39996#issuecomment-287857698
2017-03-28 19:02:47 +01:00
Pedro Algarvio
af7de9f0ea
One more attribute to clean up 2017-03-08 18:34:35 +00:00
Pedro Algarvio
07d0a5ed20
Cleanup after ourselves 2017-03-08 18:34:32 +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
bdb3cc3d89
Test websockets against the actual tornado application created in salt 2017-02-23 23:19:45 +00:00
Pedro Algarvio
1e2753c875
Fix imports after renames 2017-02-23 23:19:43 +00:00
Pedro Algarvio
15af4c9728
Test filenames conformity. Adjust for pytest. 2017-02-23 23:19:42 +00:00
kstreee
51972d0724 Removes a redundant test case after removed 'batch' in 'netapi'. 2017-02-10 07:12:22 +00:00
Mike Place
7fc803b4bd Try/except the setup call in tornado test as a workaround pending salt-testing release 2016-08-22 19:08:40 +09:00
rallytime
72a116b731 Merge branch '2016.3' into 'develop'
Conflicts:
  - salt/states/pkg.py
2016-08-02 13:05:36 -06:00
kstreee
28f793caac Fix missing first data in stream when subscribing stream using a function 'read_async'. 2016-08-02 07:37:25 +00:00
rallytime
cbf42a8407 Merge branch '2016.3' into 'develop'
Conflicts:
  - conf/master
  - doc/ref/configuration/master.rst
  - salt/cli/batch.py
  - salt/cli/daemons.py
  - salt/config/__init__.py
  - salt/minion.py
  - salt/modules/aptpkg.py
  - salt/modules/beacons.py
  - salt/states/archive.py
  - salt/states/cmd.py
  - salt/utils/gitfs.py
  - tests/unit/states/cmd_test.py
2016-04-26 14:42:26 -06:00
rallytime
80fcdfb9d8 Merge branch '2015.8' into '2016.3'
Conflicts:
  - doc/topics/targeting/grains.rst
  - salt/cli/daemons.py
  - salt/exceptions.py
  - salt/minion.py
  - salt/modules/schedule.py
  - salt/scripts.py
  - salt/states/archive.py
2016-04-26 12:07:42 -06:00
rallytime
9064d3bbfb Merge branch '2015.5' into '2015.8'
Conflicts:
  - salt/cloud/clouds/vmware.py
  - salt/modules/file.py
  - salt/states/archive.py
2016-04-25 15:45:17 -06:00
rallytime
ce72851861 Merge branch '2014.7' into '2015.5'
Conflicts:
  - salt/netapi/rest_tornado/__init__.py
  - salt/netapi/rest_tornado/saltnado.py
2016-04-22 10:24:06 -06:00
Seth House
2775edc176 Saltnado /run fix (#32590)
* Revert "Verify auth in saltnado run (#32552)"

This reverts commit b19c5a5ce7.

* Call runner.cmd_async instead to enforce eauth

* Check for both token or user/pass before giving to Salt

* Remove comment as we're now enforcing auth here

* Lint and functionality fix courtesy of Mike P.

* Don't fail the whole request if there's an eauth problem
2016-04-22 10:10:47 -06:00
kstreee
1c9e05249f [saltstack/salt#31534] Resolve data['arg'] type issue. Now rest_tornado can accept not only a list of string type for 'arg', but also a string type data for 'arg'. 2016-03-01 01:53:30 +00:00
Nicolas Delaby
a8dc33a5e3 Saltnado provide also get parameters to the context 2016-02-19 09:11:15 +01:00
Nicolas Delaby
f0a6d2b814 Saltnado provide also get parameters to the context 2016-02-15 10:09:02 +01:00
FELD Boris
049815fb34 Add support for cors preflight request for parametrized urls
The implementation was broken for jobs and minions handlers
2015-11-10 18:37:03 +01:00
Mike Place
23fcc9e348 Merge pull request #27248 from tinyclues/better_cors_headers
[Saltnado] - The CORS implementation was a bit naive about headers allowance.
2015-09-23 08:50:06 -06:00
Mike Place
3933eed307 Merge pull request #27249 from tinyclues/login_support_more_content_type
[Saltnado] - Add the support of login payload in JSON and YAML.
2015-09-23 08:49:42 -06:00
FELD Boris
6417161fd7 The CORS implementation was a bit naive about headers allowance.
A preflight request send the list of headers of the final request
in a special header ```Access-Control-Request-Headers```.
The server must returns the list of allowed header in the special header
```Access-Control-Allow-Headers```.

This PR just returns the whole list of headers but may allow filtering of some
of them quite easily. I'm not sure to see how filtering how headers may
impact security, if anyone has some leads.
2015-09-18 23:24:43 +02:00
FELD Boris
a4fd1e75c5 Add the support of login payload in JSON and YAML.
Login endpoint supported only application/x-www-form-urlencoded which may
be an useless limitation. This PR add support for more content-type,
JSON and YAML and every content-type supported by saltnado in general
as it uses the same deserialisation method than the lowstate deserialisation.
2015-09-18 19:16:47 +02:00
FELD Boris
5e9c3c7d96 Improve support of Accept header in saltnado.
It currently supports 'simple' values like application/json, but Accept header
could also include more than one value with parameters
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1.
For example:

```application/json, text/javascript, */*; q=0.01```

This PR add support for multiple media_range in Accept header, support parsing
of parameter (like q=0.01) but discard them and finally iterate on
media_range and take the first compatible.

A more complete implementation may fully supports the RFC and support
q parameter and specific order of priority to find the most compatible
Content-Type but I don't think it's worth the pain.

If we want a better implementation, werkzeug has actually an implementation
http://werkzeug.pocoo.org/docs/0.10/datastructures/#werkzeug.datastructures.Accept.best_match.
2015-09-17 00:48:34 +02:00
FELD Boris
ef3b7ddc2d Fix lints 2015-09-15 20:29:18 +02:00
FELD Boris
b13f66ee4b Add support for CORS in saltnado.
Add support for CORS and tests in RPC salt-api. The code was inspired by
https://github.com/globocom/tornado-cors.

Also add support for CORS in websocket. By adding some tests, I made
a small refactoring to make the websocket handler more easily testable.

Some documentation about CORS could be found here
https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS
for reference.
2015-09-15 18:52:44 +02:00
Mike Place
b13b6b912a Merge pull request #26984 from tinyclues/26505_improve_content_type_support
[NetAPI] SaltNado - Improve support for Content-Type parsing. Ref #26505
2015-09-14 13:02:28 -06:00