'Extend base class to support authenticating as a certain user.'

def build_wsgi_environ(self, *a, **kw):

    self.cookie.clear()
    csrf_token = kw.get(u'csrf_token', 'ThisIsATokenThatIsThirtyTwoBytes')
    if csrf_token:
        self.cookie['csrf_token'] = csrf_token
        kw['HTTP_X-CSRF-TOKEN'] = csrf_token
    auth_as = kw.pop(u'auth_as', None)
    if auth_as:
        user.User.from_username(auth_as).sign_in(self.cookie)
    for (k, v) in kw.pop(u'cookies', {}).items():
        self.cookie[k] = v
    return Client.build_wsgi_environ(self, *a, **kw)
