Module: check_mk
Branch: master
Commit: bc237061cc203708008f5d73549f096c71f48fde
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bc237061cc2037…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Jan 4 16:09:33 2019 +0100
Fix redirection test.
Quoting https://en.wikipedia.org/wiki/HTTP_location:
An obsolete version of the HTTP 1.1 specifications (IETF RFC 2616)
required a complete absolute URI for redirection. The IETF HTTP
working group found that the most popular web browsers tolerate the
passing of a relative URL and, consequently, the updated HTTP 1.1
specifications (IETF RFC 7231) relaxed the original constraint,
allowing the use of relative URLs in Location headers.
To be on the safe side, werkzeug follows the old RFC and constructs an
absolute URI.
Change-Id: Ifb40c6a8fda07ce94e70477fe6dc5db334d46dfd
---
tests/integration/omd/test_web_access.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/tests/integration/omd/test_web_access.py b/tests/integration/omd/test_web_access.py
index b518047..5d9e2c2 100644
--- a/tests/integration/omd/test_web_access.py
+++ b/tests/integration/omd/test_web_access.py
@@ -28,15 +28,17 @@ def test_base_path_redirects(site):
def test_cmk_base_path_access(site):
web = CMKWebSession(site)
+ expected_target = '%s://%s:%d/%s/check_mk/login.py?_origtarget=index.py' % \
+ (site.http_proto, site.http_address, site.apache_port, site.id)
# TODO: Figure out if which status code we *really* expect here: 301 or 302?
web.check_redirect("/%s/check_mk/" % site.id,
- expected_code=302,
- expected_target="/%s/check_mk/login.py?_origtarget=index.py" % site.id)
+ expected_code=302,
+ expected_target=expected_target)
web.check_redirect("/%s/check_mk/index.py" % site.id,
- expected_code=302,
- expected_target="/%s/check_mk/login.py?_origtarget=index.py" % site.id)
+ expected_code=302,
+ expected_target=expected_target)
def test_cmk_agents_access(site):
Module: check_mk
Branch: master
Commit: f664b526ea20051a0c5988477d00e05a501ee9b4
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f664b526ea2005…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Jan 4 14:46:09 2019 +0100
Replaced the remaining hand-made WSGI envronments.
Change-Id: I7eabaca21825fd0ca2b174221241b9042f84afe7
---
tests/unit/cmk/gui/test_http.py | 31 +++++++++++--------------------
1 file changed, 11 insertions(+), 20 deletions(-)
diff --git a/tests/unit/cmk/gui/test_http.py b/tests/unit/cmk/gui/test_http.py
index df0b5fa..180bca0 100644
--- a/tests/unit/cmk/gui/test_http.py
+++ b/tests/unit/cmk/gui/test_http.py
@@ -1,25 +1,21 @@
#!/usr/bin/env python
# encoding: utf-8
-import time
import io
+import time
+
+from werkzeug.test import create_environ
import cmk.gui.http as http
from cmk.gui.globals import html
def test_http_request_allowed_vars():
- wsgi_environ = {
- # Please note: This is no complete WSGI environment
- "REQUEST_METHOD" : "POST",
- # Contains a variable that has a base64 coded value in it's name. This
- # is done for example on the service discovery page or on the user
- # editing page.
- "wsgi.input" : io.BytesIO("asd=x&_Y21rYWRtaW4%3D=aaa"),
- "SCRIPT_NAME" : "",
- "REQUEST_URI" : "",
- }
- req = http.Request(wsgi_environ)
+ environ = dict(create_environ(method="POST",
+ content_type="application/x-www-form-urlencoded",
+ input_stream=io.BytesIO("asd=x&_Y21rYWRtaW4%3D=aaa")),
+ REQUEST_URI='')
+ req = http.Request(environ)
assert req.var("asd") == "x"
assert req.var("_Y21rYWRtaW4=") == "aaa"
@@ -85,14 +81,9 @@ def test_response_del_cookie(register_builtin_html, monkeypatch):
# We dropped the old format during 1.6 development. It would be a good time to drop the
# compatibility with the old format earliest with 1.7.
def test_pre_16_format_cookie_handling(monkeypatch):
- wsgi_environ = {
- # This is no complete WSGI environment. But we currently don't need more.
- "wsgi.input" : "",
- "SCRIPT_NAME" : "",
- "HTTP_COOKIE" : "xyz=123; auth_stable=lärs:1534272374.61:1f59cac3fcd5bcc389e4f8397bed315b; abc=123"
- }
-
- request = http.Request(wsgi_environ)
+ environ = dict(create_environ(),
+ HTTP_COOKIE="xyz=123; auth_stable=lärs:1534272374.61:1f59cac3fcd5bcc389e4f8397bed315b; abc=123")
+ request = http.Request(environ)
assert isinstance(request.cookie("auth_stable"), bytes)
assert request.cookie("auth_stable") == "lärs:1534272374.61:1f59cac3fcd5bcc389e4f8397bed315b"