mirror of
https://github.com/saltstack/salt.git
synced 2025-04-15 17:20:19 +00:00
Fix up pre-commit and lint
This commit is contained in:
parent
680301504f
commit
ade9da2703
8 changed files with 16 additions and 29 deletions
|
@ -1364,6 +1364,7 @@ repos:
|
|||
- msgpack==1.0.3
|
||||
- packaging
|
||||
- looseversion
|
||||
- tornado
|
||||
|
||||
- repo: https://github.com/saltstack/invoke-pre-commit
|
||||
rev: v1.9.0
|
||||
|
@ -1387,6 +1388,7 @@ repos:
|
|||
- msgpack==1.0.3
|
||||
- packaging
|
||||
- looseversion
|
||||
- tornado
|
||||
|
||||
- repo: https://github.com/saltstack/invoke-pre-commit
|
||||
rev: v1.9.0
|
||||
|
|
|
@ -1308,7 +1308,7 @@ class SAuth(AsyncAuth):
|
|||
self.authenticate()
|
||||
return self._crypticle
|
||||
|
||||
def authenticate(self, _=None): # TODO: remove unused var
|
||||
def authenticate(self): # TODO: remove unused var
|
||||
"""
|
||||
Authenticate with the master, this method breaks the functional
|
||||
paradigm, it will update the master information from a fresh sign
|
||||
|
|
|
@ -39,8 +39,6 @@ def get_application(opts):
|
|||
except ImportError as err:
|
||||
log.error("ImportError! %s", err)
|
||||
return None
|
||||
log = logging.getLogger()
|
||||
log.setLevel(logging.DEBUG)
|
||||
|
||||
mod_opts = opts.get(__virtualname__, {})
|
||||
|
||||
|
@ -58,7 +56,6 @@ def get_application(opts):
|
|||
|
||||
# if you have enabled websockets, add them!
|
||||
if mod_opts.get("websockets", False):
|
||||
log.error("ENABEL WEBSOC")
|
||||
from . import saltnado_websockets
|
||||
|
||||
token_pattern = r"([0-9A-Fa-f]{{{0}}})".format(
|
||||
|
@ -76,11 +73,8 @@ def get_application(opts):
|
|||
(all_events_pattern, saltnado_websockets.AllEventsHandler),
|
||||
(formatted_events_pattern, saltnado_websockets.FormattedEventsHandler),
|
||||
]
|
||||
log.error("ENABEL WEBSOC - DONE")
|
||||
|
||||
application = salt.ext.tornado.web.Application(
|
||||
paths, debug=True
|
||||
)
|
||||
application = salt.ext.tornado.web.Application(paths, mod_opts.get("debug", False))
|
||||
|
||||
application.opts = opts
|
||||
application.mod_opts = mod_opts
|
||||
|
|
|
@ -506,11 +506,6 @@ class BaseSaltAPIHandler(salt.ext.tornado.web.RequestHandler): # pylint: disabl
|
|||
# TODO: set a header or something??? so we know it was a timeout
|
||||
self.application.event_listener.clean_by_request(self)
|
||||
|
||||
def finish(self):
|
||||
import traceback
|
||||
log.error("FINISH CALLED: %s", "\n".join(traceback.format_stack()))
|
||||
super().finish()
|
||||
|
||||
def on_finish(self):
|
||||
"""
|
||||
When the job has been done, lets cleanup
|
||||
|
@ -924,7 +919,6 @@ class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223
|
|||
"""
|
||||
Disbatch all lowstates to the appropriate clients
|
||||
"""
|
||||
log.error("BEGIN DISBATCH")
|
||||
ret = []
|
||||
|
||||
# check clients before going, we want to throw 400 if one is bad
|
||||
|
@ -961,9 +955,7 @@ class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223
|
|||
self.write(self.serialize({"return": ret}))
|
||||
self.finish()
|
||||
except RuntimeError as exc:
|
||||
log.exception("DISBATCH RUNTIME ERROR")
|
||||
pass # Do we need any logging here?
|
||||
log.error("END DISBATCH")
|
||||
log.exception("Encountered Runtime Error")
|
||||
|
||||
@salt.ext.tornado.gen.coroutine
|
||||
def get_minion_returns(
|
||||
|
@ -1431,17 +1423,14 @@ class JobsSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
|
|||
"""
|
||||
# if you aren't authenticated, redirect to login
|
||||
if not self._verify_auth():
|
||||
log.error("AUTH ERROR")
|
||||
self.redirect("/login")
|
||||
return
|
||||
|
||||
log.error("LOWSTATE")
|
||||
if jid:
|
||||
self.lowstate = [{"fun": "jobs.list_job", "jid": jid, "client": "runner"}]
|
||||
else:
|
||||
self.lowstate = [{"fun": "jobs.list_jobs", "client": "runner"}]
|
||||
|
||||
log.error("DISBATCH")
|
||||
self.disbatch()
|
||||
|
||||
|
||||
|
|
|
@ -313,20 +313,18 @@ class AllEventsHandler(
|
|||
"""
|
||||
|
||||
# pylint: disable=W0221
|
||||
#@salt.ext.tornado.gen.coroutine
|
||||
def get(self, token):
|
||||
"""
|
||||
Check the token, returns a 401 if the token is invalid.
|
||||
Else open the websocket connection
|
||||
"""
|
||||
log.error("In the websocket get method")
|
||||
log.debug("In the websocket get method")
|
||||
self.token = token
|
||||
# close the connection, if not authenticated
|
||||
if not self.application.auth.get_tok(token):
|
||||
log.debug("Refusing websocket connection, bad token!")
|
||||
self.send_error(401)
|
||||
return
|
||||
log.error("In the websocket get method - get")
|
||||
return super().get(token)
|
||||
|
||||
def open(self, token): # pylint: disable=W0221
|
||||
|
@ -334,7 +332,6 @@ class AllEventsHandler(
|
|||
Return a websocket connection to Salt
|
||||
representing Salt's "real time" event stream.
|
||||
"""
|
||||
log.error("Open websocket")
|
||||
self.connected = False
|
||||
|
||||
@salt.ext.tornado.gen.coroutine
|
||||
|
@ -345,7 +342,7 @@ class AllEventsHandler(
|
|||
These messages make up salt's
|
||||
"real time" event stream.
|
||||
"""
|
||||
log.error("Got websocket message %s", message)
|
||||
log.debug("Got websocket message %s", message)
|
||||
if message == "websocket client ready":
|
||||
if self.connected:
|
||||
# TBD: Add ability to run commands in this branch
|
||||
|
@ -372,7 +369,7 @@ class AllEventsHandler(
|
|||
|
||||
def on_close(self, *args, **kwargs):
|
||||
"""Cleanup."""
|
||||
log.error("In the websocket close method")
|
||||
log.debug("In the websocket close method")
|
||||
self.close()
|
||||
|
||||
def check_origin(self, origin):
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import urllib.parse
|
||||
import salt.ext.tornado
|
||||
|
||||
import pytest
|
||||
|
||||
import salt.ext.tornado
|
||||
import salt.utils.json
|
||||
from salt.netapi.rest_tornado import saltnado
|
||||
from tests.support.mock import MagicMock, patch
|
||||
|
@ -16,6 +16,7 @@ def app_urls():
|
|||
|
||||
|
||||
async def test_hook_can_handle_get_parameters(http_client, app, content_type_map):
|
||||
|
||||
with patch("salt.utils.event.get_event") as get_event:
|
||||
with patch.dict(app.mod_opts, {"webhook_disable_auth": True}):
|
||||
event = MagicMock()
|
||||
|
|
|
@ -27,7 +27,11 @@ def http_server_port(http_server):
|
|||
|
||||
|
||||
async def test_websocket_handler_upgrade_to_websocket(
|
||||
http_client, auth_creds, content_type_map, http_server_port, io_loop,
|
||||
http_client,
|
||||
auth_creds,
|
||||
content_type_map,
|
||||
http_server_port,
|
||||
io_loop,
|
||||
):
|
||||
response = await http_client.fetch(
|
||||
"/login",
|
||||
|
|
|
@ -133,7 +133,7 @@ class HTTPTestCase(TestCase):
|
|||
|
||||
url = "http://{host}:{port}/".format(host=host, port=port)
|
||||
result = http.query(url, raise_error=False)
|
||||
if sys.platform.strtswith("win"):
|
||||
if sys.platform.startswith("win"):
|
||||
assert result == {"error": "[Errno 10061] Unknown error"}, result
|
||||
else:
|
||||
assert result == {"error": "[Errno 111] Connection refused"}, result
|
||||
|
|
Loading…
Add table
Reference in a new issue