The redirect failed in case of a non-ASCII page name
====================================================

Challenges by redirecting to a login form.

To illustrate, we'll create a test request:

  >>> from zope.publisher.browser import TestRequest
  >>> request = TestRequest()

and confirm its response's initial status and 'location' header:

  >>> request.response.getStatus()
  599
  >>> request.response.getHeader('location')

When we issue a challenge using a session plugin:

  >>> from z3c.authenticator.credential import SessionCredentialsPlugin
  >>> plugin = SessionCredentialsPlugin()

The redirect failed in case of a non-ASCII page name:
(REQUEST_URI is utf-8, _traversal_stack is unicode)

  >>> env = {
  ...     'REQUEST_URI': '/foo/bar/folder/page%C3%BC.html?q=value',
  ...     'QUERY_STRING': 'q=value'
  ...     }
  >>> request = TestRequest(environ=env)
  >>> request._traversed_names = [u'foo', u'bar']
  >>> request._traversal_stack = [u'page\xfc.html', u'folder']
  >>> request['REQUEST_URI']
  '/foo/bar/folder/page%C3%BC.html?q=value'

When we challenge:

  >>> plugin.challenge(request)
  True

We see the 'camefrom' points to the requested URL:

  >>> request.response.getHeader('location') # doctest: +ELLIPSIS
  '.../@@loginForm.html?camefrom=%2Ffoo%2Fbar%2Ffolder%2Fpage%C3%BC.html%3Fq%3Dvalue'

