def test_forbidden(self): r = http.forbidden() assert r.status.startswith("403") assert r.headers["Content-Type"] == "text/plain" assert "403 Forbidden" in r.body r = http.forbidden([("Content-Type", "text/html")], "<p>403 Forbidden</p>") assert r.status.startswith("403") assert r.headers["Content-Type"] == "text/html" assert r.body == "<p>403 Forbidden</p>" exc = http.ForbiddenError() r = exc.make_response() assert r.status.startswith("403")
def test_forbidden(self): r = http.forbidden() assert r.status.startswith('403') assert r.headers['Content-Type'] == 'text/plain' assert '403 Forbidden' in r.body r = http.forbidden([('Content-Type', 'text/html')], '<p>403 Forbidden</p>') assert r.status.startswith('403') assert r.headers['Content-Type'] == 'text/html' assert r.body == '<p>403 Forbidden</p>' exc = http.ForbiddenError() r = exc.make_response() assert r.status.startswith('403')
def login(self, request, segments): """Log the user in, sort of, by verifying a given password.""" if self._user is None: return http.not_found() # We do not want to encrypt the plaintext password given in the POST # data. That would hash the password, but we need to have the # plaintext in order to pass into passlib. validator = Validator(cleartext_password=GetterSetter(unicode)) try: values = validator(request) except ValueError as error: return http.bad_request([], str(error)) is_valid, new_hash = config.password_context.verify( values['cleartext_password'], self._user.password) if is_valid: if new_hash is not None: self._user.password = new_hash return no_content() return http.forbidden()
def tarball_bad(self, request, segments): return http.forbidden( [('Content-Type', 'text/plain')], 'You need to specify the revision and test.\n', )