request = <WSGIRequest: GET '/'>
@wraps(get_response)
def inner(request):
try:
> response = get_response(request)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:34:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.middleware.common.CommonMiddleware object at 0x7f7793cdbc18>
request = <WSGIRequest: GET '/'>
def __call__(self, request):
response = None
if hasattr(self, 'process_request'):
> response = self.process_request(request)
.tox/py3/lib/python3.7/site-packages/django/utils/deprecation.py:93:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.middleware.common.CommonMiddleware object at 0x7f7793cdbc18>
request = <WSGIRequest: GET '/'>
def process_request(self, request):
"""
Check for denied User-Agents and rewrite the URL based on
settings.APPEND_SLASH and settings.PREPEND_WWW
"""
# Check for denied User-Agents
if 'HTTP_USER_AGENT' in request.META:
for user_agent_regex in settings.DISALLOWED_USER_AGENTS:
if user_agent_regex.search(request.META['HTTP_USER_AGENT']):
raise PermissionDenied('Forbidden user agent')
# Check for a redirect based on settings.PREPEND_WWW
> host = request.get_host()
.tox/py3/lib/python3.7/site-packages/django/middleware/common.py:47:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/'>
def get_host(self):
"""Return the HTTP host using the environment or request headers."""
host = self._get_raw_host()
# Allow variants of localhost if ALLOWED_HOSTS is empty and DEBUG=True.
allowed_hosts = settings.ALLOWED_HOSTS
if settings.DEBUG and not allowed_hosts:
allowed_hosts = ['localhost', '127.0.0.1', '[::1]']
domain, port = split_domain_port(host)
if domain and validate_host(domain, allowed_hosts):
return host
else:
msg = "Invalid HTTP_HOST header: %r." % host
if domain:
msg += " You may need to add %r to ALLOWED_HOSTS." % domain
else:
msg += " The domain name provided is not valid according to RFC 1034/1035."
> raise DisallowedHost(msg)
E django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: 'webapp.staging.swh.network'. You may need to add 'webapp.staging.swh.network' to ALLOWED_HOSTS.
.tox/py3/lib/python3.7/site-packages/django/http/request.py:111: DisallowedHost
During handling of the above exception, another exception occurred:
request = <WSGIRequest: GET '/'>
@wraps(get_response)
def inner(request):
try:
> response = get_response(request)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:34:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <corsheaders.middleware.CorsMiddleware object at 0x7f7793c8ecc0>
request = <WSGIRequest: GET '/'>
def __call__(self, request):
response = None
if hasattr(self, 'process_request'):
response = self.process_request(request)
> response = response or self.get_response(request)
.tox/py3/lib/python3.7/site-packages/django/utils/deprecation.py:94:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>
@wraps(get_response)
def inner(request):
try:
response = get_response(request)
except Exception as exc:
> response = response_for_exception(request, exc)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:36:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>
exc = DisallowedHost("Invalid HTTP_HOST header: 'webapp.staging.swh.network'. You may need to add 'webapp.staging.swh.network' to ALLOWED_HOSTS.")
def response_for_exception(request, exc):
if isinstance(exc, Http404):
if settings.DEBUG:
response = debug.technical_404_response(request, exc)
else:
response = get_exception_response(request, get_resolver(get_urlconf()), 404, exc)
elif isinstance(exc, PermissionDenied):
response = get_exception_response(request, get_resolver(get_urlconf()), 403, exc)
log_response(
'Forbidden (Permission denied): %s', request.path,
response=response,
request=request,
exc_info=sys.exc_info(),
)
elif isinstance(exc, MultiPartParserError):
response = get_exception_response(request, get_resolver(get_urlconf()), 400, exc)
log_response(
'Bad request (Unable to parse request body): %s', request.path,
response=response,
request=request,
exc_info=sys.exc_info(),
)
elif isinstance(exc, SuspiciousOperation):
if isinstance(exc, (RequestDataTooBig, TooManyFieldsSent)):
# POST data can't be accessed again, otherwise the original
# exception would be raised.
request._mark_post_parse_error()
# The request logger receives events for any problematic request
# The security logger receives events for all SuspiciousOperations
security_logger = logging.getLogger('django.security.%s' % exc.__class__.__name__)
security_logger.error(
str(exc),
extra={'status_code': 400, 'request': request},
)
if settings.DEBUG:
response = debug.technical_500_response(request, *sys.exc_info(), status_code=400)
else:
> response = get_exception_response(request, get_resolver(get_urlconf()), 400, exc)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:82:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>
resolver = <URLResolver 'swh.web.urls' (None:None) '^/'>, status_code = 400
exception = DisallowedHost("Invalid HTTP_HOST header: 'webapp.staging.swh.network'. You may need to add 'webapp.staging.swh.network' to ALLOWED_HOSTS.")
def get_exception_response(request, resolver, status_code, exception):
try:
callback, param_dict = resolver.resolve_error_handler(status_code)
response = callback(request, **{**param_dict, 'exception': exception})
except Exception:
signals.got_request_exception.send(sender=None, request=request)
> response = handle_uncaught_exception(request, resolver, sys.exc_info())
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:111:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>
resolver = <URLResolver 'swh.web.urls' (None:None) '^/'>, status_code = 400
exception = DisallowedHost("Invalid HTTP_HOST header: 'webapp.staging.swh.network'. You may need to add 'webapp.staging.swh.network' to ALLOWED_HOSTS.")
def get_exception_response(request, resolver, status_code, exception):
try:
callback, param_dict = resolver.resolve_error_handler(status_code)
> response = callback(request, **{**param_dict, 'exception': exception})
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:108:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>
exception = DisallowedHost("Invalid HTTP_HOST header: 'webapp.staging.swh.network'. You may need to add 'webapp.staging.swh.network' to ALLOWED_HOSTS.")
def swh_handle400(request, exception=None):
"""
Custom Django HTTP error 400 handler for swh-web.
"""
error_description = (
"The server cannot process the request to %s due to "
"something that is perceived to be a client error."
% escape(request.META["PATH_INFO"])
)
> return _generate_error_page(request, 400, error_description)
.tox/py3/lib/python3.7/site-packages/swh/web/common/exc.py:97:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>, error_code = 400
error_description = 'The server cannot process the request to / due to something that is perceived to be a client error.'
def _generate_error_page(request, error_code, error_description):
return render(
request,
"error.html",
{
"error_code": error_code,
"error_message": http_status_code_message[error_code],
"error_description": mark_safe(error_description),
},
> status=error_code,
)
.tox/py3/lib/python3.7/site-packages/swh/web/common/exc.py:84:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>, template_name = 'error.html'
context = {'error_code': 400, 'error_description': 'The server cannot process the request to / due to something that is perceived to be a client error.', 'error_message': 'Bad Request'}
content_type = None, status = 400, using = None
def render(request, template_name, context=None, content_type=None, status=None, using=None):
"""
Return a HttpResponse whose content is filled with the result of calling
django.template.loader.render_to_string() with the passed arguments.
"""
> content = loader.render_to_string(template_name, context, request, using=using)
.tox/py3/lib/python3.7/site-packages/django/shortcuts.py:36:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
template_name = 'error.html'
context = {'error_code': 400, 'error_description': 'The server cannot process the request to / due to something that is perceived to be a client error.', 'error_message': 'Bad Request'}
request = <WSGIRequest: GET '/'>, using = None
def render_to_string(template_name, context=None, request=None, using=None):
"""
Load a template and render it with a context. Return a string.
template_name may be a string or a list of strings.
"""
if isinstance(template_name, (list, tuple)):
template = select_template(template_name, using=using)
else:
template = get_template(template_name, using=using)
> return template.render(context, request)
.tox/py3/lib/python3.7/site-packages/django/template/loader.py:62:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.template.backends.django.Template object at 0x7f7793c917b8>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_description': 'The server cannot process the request to / due to something that is perceived to be a client error.'}]
request = <WSGIRequest: GET '/'>
def render(self, context=None, request=None):
context = make_context(context, request, autoescape=self.backend.engine.autoescape)
try:
> return self.template.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/backends/django.py:61:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.template.base.Template object at 0x7f7793ee8da0>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_description': 'The server cannot process the request to / due to something that is perceived to be a client error.'}]
def render(self, context):
"Display stage -- can be called many times"
with context.render_context.push_state(self):
if context.template is None:
> with context.bind_template(self):
.tox/py3/lib/python3.7/site-packages/django/template/base.py:169:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <contextlib._GeneratorContextManager object at 0x7f7793c91e48>
def __enter__(self):
# do not keep args and kwds alive unnecessarily
# they are only needed for recreation, which is not possible anymore
del self.args, self.kwds, self.func
try:
> return next(self.gen)
/usr/lib/python3.7/contextlib.py:112:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_description': 'The server cannot process the request to / due to something that is perceived to be a client error.'}]
template = <django.template.base.Template object at 0x7f7793ee8da0>
@contextmanager
def bind_template(self, template):
if self.template is not None:
raise RuntimeError("Context is already bound to a template")
self.template = template
# Set context processors according to the template engine's settings.
processors = (template.engine.template_context_processors +
self._processors)
updates = {}
for processor in processors:
> updates.update(processor(self.request))
.tox/py3/lib/python3.7/site-packages/django/template/context.py:246:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>
def context_processor(request):
"""
Django context processor used to inject variables
in all swh-web templates.
"""
config = get_config()
if (
hasattr(request, "user")
and request.user.is_authenticated
and not hasattr(request.user, "backend")
):
# To avoid django.template.base.VariableDoesNotExist errors
# when rendering templates when standard Django user is logged in.
request.user.backend = "django.contrib.auth.backends.ModelBackend"
> site_base_url = request.build_absolute_uri("/")
.tox/py3/lib/python3.7/site-packages/swh/web/common/utils.py:259:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/'>, location = '/'
def build_absolute_uri(self, location=None):
"""
Build an absolute URI from the location and the variables available in
this request. If no ``location`` is specified, build the absolute URI
using request.get_full_path(). If the location is absolute, convert it
to an RFC 3987 compliant URI and return it. If location is relative or
is scheme-relative (i.e., ``//example.com/``), urljoin() it to a base
URL constructed from the request variables.
"""
if location is None:
# Make it an absolute url (but schemeless and domainless) for the
# edge case that the path starts with '//'.
location = '//%s' % self.get_full_path()
bits = urlsplit(location)
if not (bits.scheme and bits.netloc):
# Handle the simple, most common case. If the location is absolute
# and a scheme or host (netloc) isn't provided, skip an expensive
# urljoin() as long as no path segments are '.' or '..'.
if (bits.path.startswith('/') and not bits.scheme and not bits.netloc and
'/./' not in bits.path and '/../' not in bits.path):
# If location starts with '//' but has no netloc, reuse the
# schema and netloc from the current request. Strip the double
# slashes and continue as if it wasn't specified.
if location.startswith('//'):
location = location[2:]
> location = self._current_scheme_host + location
.tox/py3/lib/python3.7/site-packages/django/http/request.py:195:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.utils.functional.cached_property object at 0x7f779c3ecfd0>
instance = <WSGIRequest: GET '/'>
cls = <class 'django.core.handlers.wsgi.WSGIRequest'>
def __get__(self, instance, cls=None):
"""
Call the function and put the return value in instance.__dict__ so that
subsequent attribute access on the instance returns the cached value
instead of calling cached_property.__get__().
"""
if instance is None:
return self
> res = instance.__dict__[self.name] = self.func(instance)
.tox/py3/lib/python3.7/site-packages/django/utils/functional.py:80:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/'>
@cached_property
def _current_scheme_host(self):
> return '{}://{}'.format(self.scheme, self.get_host())
.tox/py3/lib/python3.7/site-packages/django/http/request.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/'>
def get_host(self):
"""Return the HTTP host using the environment or request headers."""
host = self._get_raw_host()
# Allow variants of localhost if ALLOWED_HOSTS is empty and DEBUG=True.
allowed_hosts = settings.ALLOWED_HOSTS
if settings.DEBUG and not allowed_hosts:
allowed_hosts = ['localhost', '127.0.0.1', '[::1]']
domain, port = split_domain_port(host)
if domain and validate_host(domain, allowed_hosts):
return host
else:
msg = "Invalid HTTP_HOST header: %r." % host
if domain:
msg += " You may need to add %r to ALLOWED_HOSTS." % domain
else:
msg += " The domain name provided is not valid according to RFC 1034/1035."
> raise DisallowedHost(msg)
E django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: 'webapp.staging.swh.network'. You may need to add 'webapp.staging.swh.network' to ALLOWED_HOSTS.
.tox/py3/lib/python3.7/site-packages/django/http/request.py:111: DisallowedHost
During handling of the above exception, another exception occurred:
request = <WSGIRequest: GET '/'>
@wraps(get_response)
def inner(request):
try:
> response = get_response(request)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:34:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.contrib.sessions.middleware.SessionMiddleware object at 0x7f7793c8efd0>
request = <WSGIRequest: GET '/'>
def __call__(self, request):
response = None
if hasattr(self, 'process_request'):
response = self.process_request(request)
> response = response or self.get_response(request)
.tox/py3/lib/python3.7/site-packages/django/utils/deprecation.py:94:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>
@wraps(get_response)
def inner(request):
try:
response = get_response(request)
except Exception as exc:
> response = response_for_exception(request, exc)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:36:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>
exc = DisallowedHost("Invalid HTTP_HOST header: 'webapp.staging.swh.network'. You may need to add 'webapp.staging.swh.network' to ALLOWED_HOSTS.")
def response_for_exception(request, exc):
if isinstance(exc, Http404):
if settings.DEBUG:
response = debug.technical_404_response(request, exc)
else:
response = get_exception_response(request, get_resolver(get_urlconf()), 404, exc)
elif isinstance(exc, PermissionDenied):
response = get_exception_response(request, get_resolver(get_urlconf()), 403, exc)
log_response(
'Forbidden (Permission denied): %s', request.path,
response=response,
request=request,
exc_info=sys.exc_info(),
)
elif isinstance(exc, MultiPartParserError):
response = get_exception_response(request, get_resolver(get_urlconf()), 400, exc)
log_response(
'Bad request (Unable to parse request body): %s', request.path,
response=response,
request=request,
exc_info=sys.exc_info(),
)
elif isinstance(exc, SuspiciousOperation):
if isinstance(exc, (RequestDataTooBig, TooManyFieldsSent)):
# POST data can't be accessed again, otherwise the original
# exception would be raised.
request._mark_post_parse_error()
# The request logger receives events for any problematic request
# The security logger receives events for all SuspiciousOperations
security_logger = logging.getLogger('django.security.%s' % exc.__class__.__name__)
security_logger.error(
str(exc),
extra={'status_code': 400, 'request': request},
)
if settings.DEBUG:
response = debug.technical_500_response(request, *sys.exc_info(), status_code=400)
else:
> response = get_exception_response(request, get_resolver(get_urlconf()), 400, exc)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:82:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>
resolver = <URLResolver 'swh.web.urls' (None:None) '^/'>, status_code = 400
exception = DisallowedHost("Invalid HTTP_HOST header: 'webapp.staging.swh.network'. You may need to add 'webapp.staging.swh.network' to ALLOWED_HOSTS.")
def get_exception_response(request, resolver, status_code, exception):
try:
callback, param_dict = resolver.resolve_error_handler(status_code)
response = callback(request, **{**param_dict, 'exception': exception})
except Exception:
signals.got_request_exception.send(sender=None, request=request)
> response = handle_uncaught_exception(request, resolver, sys.exc_info())
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:111:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>
resolver = <URLResolver 'swh.web.urls' (None:None) '^/'>, status_code = 400
exception = DisallowedHost("Invalid HTTP_HOST header: 'webapp.staging.swh.network'. You may need to add 'webapp.staging.swh.network' to ALLOWED_HOSTS.")
def get_exception_response(request, resolver, status_code, exception):
try:
callback, param_dict = resolver.resolve_error_handler(status_code)
> response = callback(request, **{**param_dict, 'exception': exception})
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:108:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>
exception = DisallowedHost("Invalid HTTP_HOST header: 'webapp.staging.swh.network'. You may need to add 'webapp.staging.swh.network' to ALLOWED_HOSTS.")
def swh_handle400(request, exception=None):
"""
Custom Django HTTP error 400 handler for swh-web.
"""
error_description = (
"The server cannot process the request to %s due to "
"something that is perceived to be a client error."
% escape(request.META["PATH_INFO"])
)
> return _generate_error_page(request, 400, error_description)
.tox/py3/lib/python3.7/site-packages/swh/web/common/exc.py:97:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>, error_code = 400
error_description = 'The server cannot process the request to / due to something that is perceived to be a client error.'
def _generate_error_page(request, error_code, error_description):
return render(
request,
"error.html",
{
"error_code": error_code,
"error_message": http_status_code_message[error_code],
"error_description": mark_safe(error_description),
},
> status=error_code,
)
.tox/py3/lib/python3.7/site-packages/swh/web/common/exc.py:84:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>, template_name = 'error.html'
context = {'error_code': 400, 'error_description': 'The server cannot process the request to / due to something that is perceived to be a client error.', 'error_message': 'Bad Request'}
content_type = None, status = 400, using = None
def render(request, template_name, context=None, content_type=None, status=None, using=None):
"""
Return a HttpResponse whose content is filled with the result of calling
django.template.loader.render_to_string() with the passed arguments.
"""
> content = loader.render_to_string(template_name, context, request, using=using)
.tox/py3/lib/python3.7/site-packages/django/shortcuts.py:36:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
template_name = 'error.html'
context = {'error_code': 400, 'error_description': 'The server cannot process the request to / due to something that is perceived to be a client error.', 'error_message': 'Bad Request'}
request = <WSGIRequest: GET '/'>, using = None
def render_to_string(template_name, context=None, request=None, using=None):
"""
Load a template and render it with a context. Return a string.
template_name may be a string or a list of strings.
"""
if isinstance(template_name, (list, tuple)):
template = select_template(template_name, using=using)
else:
template = get_template(template_name, using=using)
> return template.render(context, request)
.tox/py3/lib/python3.7/site-packages/django/template/loader.py:62:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.template.backends.django.Template object at 0x7f7793c91ef0>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_description': 'The server cannot process the request to / due to something that is perceived to be a client error.'}]
request = <WSGIRequest: GET '/'>
def render(self, context=None, request=None):
context = make_context(context, request, autoescape=self.backend.engine.autoescape)
try:
> return self.template.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/backends/django.py:61:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.template.base.Template object at 0x7f7793ee8da0>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_description': 'The server cannot process the request to / due to something that is perceived to be a client error.'}]
def render(self, context):
"Display stage -- can be called many times"
with context.render_context.push_state(self):
if context.template is None:
> with context.bind_template(self):
.tox/py3/lib/python3.7/site-packages/django/template/base.py:169:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <contextlib._GeneratorContextManager object at 0x7f7793c91f98>
def __enter__(self):
# do not keep args and kwds alive unnecessarily
# they are only needed for recreation, which is not possible anymore
del self.args, self.kwds, self.func
try:
> return next(self.gen)
/usr/lib/python3.7/contextlib.py:112:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_description': 'The server cannot process the request to / due to something that is perceived to be a client error.'}]
template = <django.template.base.Template object at 0x7f7793ee8da0>
@contextmanager
def bind_template(self, template):
if self.template is not None:
raise RuntimeError("Context is already bound to a template")
self.template = template
# Set context processors according to the template engine's settings.
processors = (template.engine.template_context_processors +
self._processors)
updates = {}
for processor in processors:
> updates.update(processor(self.request))
.tox/py3/lib/python3.7/site-packages/django/template/context.py:246:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>
def context_processor(request):
"""
Django context processor used to inject variables
in all swh-web templates.
"""
config = get_config()
if (
hasattr(request, "user")
and request.user.is_authenticated
and not hasattr(request.user, "backend")
):
# To avoid django.template.base.VariableDoesNotExist errors
# when rendering templates when standard Django user is logged in.
request.user.backend = "django.contrib.auth.backends.ModelBackend"
> site_base_url = request.build_absolute_uri("/")
.tox/py3/lib/python3.7/site-packages/swh/web/common/utils.py:259:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/'>, location = '/'
def build_absolute_uri(self, location=None):
"""
Build an absolute URI from the location and the variables available in
this request. If no ``location`` is specified, build the absolute URI
using request.get_full_path(). If the location is absolute, convert it
to an RFC 3987 compliant URI and return it. If location is relative or
is scheme-relative (i.e., ``//example.com/``), urljoin() it to a base
URL constructed from the request variables.
"""
if location is None:
# Make it an absolute url (but schemeless and domainless) for the
# edge case that the path starts with '//'.
location = '//%s' % self.get_full_path()
bits = urlsplit(location)
if not (bits.scheme and bits.netloc):
# Handle the simple, most common case. If the location is absolute
# and a scheme or host (netloc) isn't provided, skip an expensive
# urljoin() as long as no path segments are '.' or '..'.
if (bits.path.startswith('/') and not bits.scheme and not bits.netloc and
'/./' not in bits.path and '/../' not in bits.path):
# If location starts with '//' but has no netloc, reuse the
# schema and netloc from the current request. Strip the double
# slashes and continue as if it wasn't specified.
if location.startswith('//'):
location = location[2:]
> location = self._current_scheme_host + location
.tox/py3/lib/python3.7/site-packages/django/http/request.py:195:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.utils.functional.cached_property object at 0x7f779c3ecfd0>
instance = <WSGIRequest: GET '/'>
cls = <class 'django.core.handlers.wsgi.WSGIRequest'>
def __get__(self, instance, cls=None):
"""
Call the function and put the return value in instance.__dict__ so that
subsequent attribute access on the instance returns the cached value
instead of calling cached_property.__get__().
"""
if instance is None:
return self
> res = instance.__dict__[self.name] = self.func(instance)
.tox/py3/lib/python3.7/site-packages/django/utils/functional.py:80:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/'>
@cached_property
def _current_scheme_host(self):
> return '{}://{}'.format(self.scheme, self.get_host())
.tox/py3/lib/python3.7/site-packages/django/http/request.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/'>
def get_host(self):
"""Return the HTTP host using the environment or request headers."""
host = self._get_raw_host()
# Allow variants of localhost if ALLOWED_HOSTS is empty and DEBUG=True.
allowed_hosts = settings.ALLOWED_HOSTS
if settings.DEBUG and not allowed_hosts:
allowed_hosts = ['localhost', '127.0.0.1', '[::1]']
domain, port = split_domain_port(host)
if domain and validate_host(domain, allowed_hosts):
return host
else:
msg = "Invalid HTTP_HOST header: %r." % host
if domain:
msg += " You may need to add %r to ALLOWED_HOSTS." % domain
else:
msg += " The domain name provided is not valid according to RFC 1034/1035."
> raise DisallowedHost(msg)
E django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: 'webapp.staging.swh.network'. You may need to add 'webapp.staging.swh.network' to ALLOWED_HOSTS.
.tox/py3/lib/python3.7/site-packages/django/http/request.py:111: DisallowedHost
During handling of the above exception, another exception occurred:
request = <WSGIRequest: GET '/'>
@wraps(get_response)
def inner(request):
try:
> response = get_response(request)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:34:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.middleware.security.SecurityMiddleware object at 0x7f7793c8ecf8>
request = <WSGIRequest: GET '/'>
def __call__(self, request):
response = None
if hasattr(self, 'process_request'):
response = self.process_request(request)
> response = response or self.get_response(request)
.tox/py3/lib/python3.7/site-packages/django/utils/deprecation.py:94:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>
@wraps(get_response)
def inner(request):
try:
response = get_response(request)
except Exception as exc:
> response = response_for_exception(request, exc)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:36:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>
exc = DisallowedHost("Invalid HTTP_HOST header: 'webapp.staging.swh.network'. You may need to add 'webapp.staging.swh.network' to ALLOWED_HOSTS.")
def response_for_exception(request, exc):
if isinstance(exc, Http404):
if settings.DEBUG:
response = debug.technical_404_response(request, exc)
else:
response = get_exception_response(request, get_resolver(get_urlconf()), 404, exc)
elif isinstance(exc, PermissionDenied):
response = get_exception_response(request, get_resolver(get_urlconf()), 403, exc)
log_response(
'Forbidden (Permission denied): %s', request.path,
response=response,
request=request,
exc_info=sys.exc_info(),
)
elif isinstance(exc, MultiPartParserError):
response = get_exception_response(request, get_resolver(get_urlconf()), 400, exc)
log_response(
'Bad request (Unable to parse request body): %s', request.path,
response=response,
request=request,
exc_info=sys.exc_info(),
)
elif isinstance(exc, SuspiciousOperation):
if isinstance(exc, (RequestDataTooBig, TooManyFieldsSent)):
# POST data can't be accessed again, otherwise the original
# exception would be raised.
request._mark_post_parse_error()
# The request logger receives events for any problematic request
# The security logger receives events for all SuspiciousOperations
security_logger = logging.getLogger('django.security.%s' % exc.__class__.__name__)
security_logger.error(
str(exc),
extra={'status_code': 400, 'request': request},
)
if settings.DEBUG:
response = debug.technical_500_response(request, *sys.exc_info(), status_code=400)
else:
> response = get_exception_response(request, get_resolver(get_urlconf()), 400, exc)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:82:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>
resolver = <URLResolver 'swh.web.urls' (None:None) '^/'>, status_code = 400
exception = DisallowedHost("Invalid HTTP_HOST header: 'webapp.staging.swh.network'. You may need to add 'webapp.staging.swh.network' to ALLOWED_HOSTS.")
def get_exception_response(request, resolver, status_code, exception):
try:
callback, param_dict = resolver.resolve_error_handler(status_code)
response = callback(request, **{**param_dict, 'exception': exception})
except Exception:
signals.got_request_exception.send(sender=None, request=request)
> response = handle_uncaught_exception(request, resolver, sys.exc_info())
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:111:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>
resolver = <URLResolver 'swh.web.urls' (None:None) '^/'>, status_code = 400
exception = DisallowedHost("Invalid HTTP_HOST header: 'webapp.staging.swh.network'. You may need to add 'webapp.staging.swh.network' to ALLOWED_HOSTS.")
def get_exception_response(request, resolver, status_code, exception):
try:
callback, param_dict = resolver.resolve_error_handler(status_code)
> response = callback(request, **{**param_dict, 'exception': exception})
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:108:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>
exception = DisallowedHost("Invalid HTTP_HOST header: 'webapp.staging.swh.network'. You may need to add 'webapp.staging.swh.network' to ALLOWED_HOSTS.")
def swh_handle400(request, exception=None):
"""
Custom Django HTTP error 400 handler for swh-web.
"""
error_description = (
"The server cannot process the request to %s due to "
"something that is perceived to be a client error."
% escape(request.META["PATH_INFO"])
)
> return _generate_error_page(request, 400, error_description)
.tox/py3/lib/python3.7/site-packages/swh/web/common/exc.py:97:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>, error_code = 400
error_description = 'The server cannot process the request to / due to something that is perceived to be a client error.'
def _generate_error_page(request, error_code, error_description):
return render(
request,
"error.html",
{
"error_code": error_code,
"error_message": http_status_code_message[error_code],
"error_description": mark_safe(error_description),
},
> status=error_code,
)
.tox/py3/lib/python3.7/site-packages/swh/web/common/exc.py:84:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>, template_name = 'error.html'
context = {'error_code': 400, 'error_description': 'The server cannot process the request to / due to something that is perceived to be a client error.', 'error_message': 'Bad Request'}
content_type = None, status = 400, using = None
def render(request, template_name, context=None, content_type=None, status=None, using=None):
"""
Return a HttpResponse whose content is filled with the result of calling
django.template.loader.render_to_string() with the passed arguments.
"""
> content = loader.render_to_string(template_name, context, request, using=using)
.tox/py3/lib/python3.7/site-packages/django/shortcuts.py:36:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
template_name = 'error.html'
context = {'error_code': 400, 'error_description': 'The server cannot process the request to / due to something that is perceived to be a client error.', 'error_message': 'Bad Request'}
request = <WSGIRequest: GET '/'>, using = None
def render_to_string(template_name, context=None, request=None, using=None):
"""
Load a template and render it with a context. Return a string.
template_name may be a string or a list of strings.
"""
if isinstance(template_name, (list, tuple)):
template = select_template(template_name, using=using)
else:
template = get_template(template_name, using=using)
> return template.render(context, request)
.tox/py3/lib/python3.7/site-packages/django/template/loader.py:62:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.template.backends.django.Template object at 0x7f7793c91b70>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_description': 'The server cannot process the request to / due to something that is perceived to be a client error.'}]
request = <WSGIRequest: GET '/'>
def render(self, context=None, request=None):
context = make_context(context, request, autoescape=self.backend.engine.autoescape)
try:
> return self.template.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/backends/django.py:61:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.template.base.Template object at 0x7f7793ee8da0>
context = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_description': 'The server cannot process the request to / due to something that is perceived to be a client error.'}]
def render(self, context):
"Display stage -- can be called many times"
with context.render_context.push_state(self):
if context.template is None:
> with context.bind_template(self):
.tox/py3/lib/python3.7/site-packages/django/template/base.py:169:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <contextlib._GeneratorContextManager object at 0x7f7793c91a20>
def __enter__(self):
# do not keep args and kwds alive unnecessarily
# they are only needed for recreation, which is not possible anymore
del self.args, self.kwds, self.func
try:
> return next(self.gen)
/usr/lib/python3.7/contextlib.py:112:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = [{'True': True, 'False': False, 'None': None}, {}, {}, {'error_code': 400, 'error_message': 'Bad Request', 'error_description': 'The server cannot process the request to / due to something that is perceived to be a client error.'}]
template = <django.template.base.Template object at 0x7f7793ee8da0>
@contextmanager
def bind_template(self, template):
if self.template is not None:
raise RuntimeError("Context is already bound to a template")
self.template = template
# Set context processors according to the template engine's settings.
processors = (template.engine.template_context_processors +
self._processors)
updates = {}
for processor in processors:
> updates.update(processor(self.request))
.tox/py3/lib/python3.7/site-packages/django/template/context.py:246:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
request = <WSGIRequest: GET '/'>
def context_processor(request):
"""
Django context processor used to inject variables
in all swh-web templates.
"""
config = get_config()
if (
hasattr(request, "user")
and request.user.is_authenticated
and not hasattr(request.user, "backend")
):
# To avoid django.template.base.VariableDoesNotExist errors
# when rendering templates when standard Django user is logged in.
request.user.backend = "django.contrib.auth.backends.ModelBackend"
> site_base_url = request.build_absolute_uri("/")
.tox/py3/lib/python3.7/site-packages/swh/web/common/utils.py:259:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/'>, location = '/'
def build_absolute_uri(self, location=None):
"""
Build an absolute URI from the location and the variables available in
this request. If no ``location`` is specified, build the absolute URI
using request.get_full_path(). If the location is absolute, convert it
to an RFC 3987 compliant URI and return it. If location is relative or
is scheme-relative (i.e., ``//example.com/``), urljoin() it to a base
URL constructed from the request variables.
"""
if location is None:
# Make it an absolute url (but schemeless and domainless) for the
# edge case that the path starts with '//'.
location = '//%s' % self.get_full_path()
bits = urlsplit(location)
if not (bits.scheme and bits.netloc):
# Handle the simple, most common case. If the location is absolute
# and a scheme or host (netloc) isn't provided, skip an expensive
# urljoin() as long as no path segments are '.' or '..'.
if (bits.path.startswith('/') and not bits.scheme and not bits.netloc and
'/./' not in bits.path and '/../' not in bits.path):
# If location starts with '//' but has no netloc, reuse the
# schema and netloc from the current request. Strip the double
# slashes and continue as if it wasn't specified.
if location.startswith('//'):
location = location[2:]
> location = self._current_scheme_host + location
.tox/py3/lib/python3.7/site-packages/django/http/request.py:195:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.utils.functional.cached_property object at 0x7f779c3ecfd0>
instance = <WSGIRequest: GET '/'>
cls = <class 'django.core.handlers.wsgi.WSGIRequest'>
def __get__(self, instance, cls=None):
"""
Call the function and put the return value in instance.__dict__ so that
subsequent attribute access on the instance returns the cached value
instead of calling cached_property.__get__().
"""
if instance is None:
return self
> res = instance.__dict__[self.name] = self.func(instance)
.tox/py3/lib/python3.7/site-packages/django/utils/functional.py:80:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/'>
@cached_property
def _current_scheme_host(self):
> return '{}://{}'.format(self.scheme, self.get_host())
.tox/py3/lib/python3.7/site-packages/django/http/request.py:205:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/'>
def get_host(self):
"""Return the HTTP host using the environment or request headers."""
host = self._get_raw_host()
# Allow variants of localhost if ALLOWED_HOSTS is empty and DEBUG=True.
allowed_hosts = settings.ALLOWED_HOSTS
if settings.DEBUG and not allowed_hosts:
allowed_hosts = ['localhost', '127.0.0.1', '[::1]']
domain, port = split_domain_port(host)
if domain and validate_host(domain, allowed_hosts):
return host
else:
msg = "Invalid HTTP_HOST header: %r." % host
if domain:
msg += " You may need to add %r to ALLOWED_HOSTS." % domain
else:
msg += " The domain name provided is not valid according to RFC 1034/1035."
> raise DisallowedHost(msg)
E django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: 'webapp.staging.swh.network'. You may need to add 'webapp.staging.swh.network' to ALLOWED_HOSTS.
.tox/py3/lib/python3.7/site-packages/django/http/request.py:111: DisallowedHost
During handling of the above exception, another exception occurred:
client = <django.test.client.Client object at 0x7f7793cdb9b0>
def test_layout_with_staging_ribbon(client):
url = reverse("swh-web-homepage")
resp = check_http_get_response(
> client, url, status_code=200, server_name=random.choice(STAGING_SERVER_NAMES),
)
.tox/py3/lib/python3.7/site-packages/swh/web/tests/test_templates.py:23:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/web/tests/utils.py:63: in check_http_get_response
SERVER_NAME=server_name if server_name else "testserver",
.tox/py3/lib/python3.7/site-packages/django/test/client.py:535: in get
response = super().get(path, data=data, secure=secure, **extra)
.tox/py3/lib/python3.7/site-packages/django/test/client.py:347: in get
**extra,
.tox/py3/lib/python3.7/site-packages/django/test/client.py:422: in generic
return self.request(**r)
.tox/py3/lib/python3.7/site-packages/django/test/client.py:485: in request
response = self.handler(environ)
.tox/py3/lib/python3.7/site-packages/django/test/client.py:140: in __call__
response = self.get_response(request)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/base.py:75: in get_response
response = self._middleware_chain(request)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:36: in inner
response = response_for_exception(request, exc)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:82: in response_for_exception
response = get_exception_response(request, get_resolver(get_urlconf()), 400, exc)
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:111: in get_exception_response
response = handle_uncaught_exception(request, resolver, sys.exc_info())
.tox/py3/lib/python3.7/site-packages/django/core/handlers/exception.py:108: in get_exception_response
response = callback(request, **{**param_dict, 'exception': exception})
.tox/py3/lib/python3.7/site-packages/swh/web/common/exc.py:97: in swh_handle400
return _generate_error_page(request, 400, error_description)
.tox/py3/lib/python3.7/site-packages/swh/web/common/exc.py:84: in _generate_error_page
status=error_code,
.tox/py3/lib/python3.7/site-packages/django/shortcuts.py:36: in render
content = loader.render_to_string(template_name, context, request, using=using)
.tox/py3/lib/python3.7/site-packages/django/template/loader.py:62: in render_to_string
return template.render(context, request)
.tox/py3/lib/python3.7/site-packages/django/template/backends/django.py:61: in render
return self.template.render(context)
.tox/py3/lib/python3.7/site-packages/django/template/base.py:169: in render
with context.bind_template(self):
/usr/lib/python3.7/contextlib.py:112: in __enter__
return next(self.gen)
.tox/py3/lib/python3.7/site-packages/django/template/context.py:246: in bind_template
updates.update(processor(self.request))
.tox/py3/lib/python3.7/site-packages/swh/web/common/utils.py:259: in context_processor
site_base_url = request.build_absolute_uri("/")
.tox/py3/lib/python3.7/site-packages/django/http/request.py:195: in build_absolute_uri
location = self._current_scheme_host + location
.tox/py3/lib/python3.7/site-packages/django/utils/functional.py:80: in __get__
res = instance.__dict__[self.name] = self.func(instance)
.tox/py3/lib/python3.7/site-packages/django/http/request.py:205: in _current_scheme_host
return '{}://{}'.format(self.scheme, self.get_host())
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <WSGIRequest: GET '/'>
def get_host(self):
"""Return the HTTP host using the environment or request headers."""
host = self._get_raw_host()
# Allow variants of localhost if ALLOWED_HOSTS is empty and DEBUG=True.
allowed_hosts = settings.ALLOWED_HOSTS
if settings.DEBUG and not allowed_hosts:
allowed_hosts = ['localhost', '127.0.0.1', '[::1]']
domain, port = split_domain_port(host)
if domain and validate_host(domain, allowed_hosts):
return host
else:
msg = "Invalid HTTP_HOST header: %r." % host
if domain:
msg += " You may need to add %r to ALLOWED_HOSTS." % domain
else:
msg += " The domain name provided is not valid according to RFC 1034/1035."
> raise DisallowedHost(msg)
E django.core.exceptions.DisallowedHost: Invalid HTTP_HOST header: 'webapp.staging.swh.network'. You may need to add 'webapp.staging.swh.network' to ALLOWED_HOSTS.
.tox/py3/lib/python3.7/site-packages/django/http/request.py:111: DisallowedHost
TEST RESULT
TEST RESULT
- Run At
- Feb 18 2021, 11:55 AM