403Webshell
Server IP : 199.250.200.62  /  Your IP : 216.73.217.61
Web Server : Apache
System : Linux vps37394.inmotionhosting.com 3.10.0-1160.119.1.vz7.224.4 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64
User : jasonp18 ( 1000)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /proc/2/cwd/proc/2/cwd/opt/imh-python/lib/python3.9/site-packages/cherrypy/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/2/cwd/proc/2/cwd/opt/imh-python/lib/python3.9/site-packages/cherrypy/test/test_params.py
import sys
import textwrap

import cherrypy
from cherrypy.test import helper


class ParamsTest(helper.CPWebCase):
    @staticmethod
    def setup_server():
        class Root:
            @cherrypy.expose
            @cherrypy.tools.json_out()
            @cherrypy.tools.params()
            def resource(self, limit=None, sort=None):
                return type(limit).__name__
            # for testing on Py 2
            resource.__annotations__ = {'limit': int}
        conf = {'/': {'tools.params.on': True}}
        cherrypy.tree.mount(Root(), config=conf)

    def test_pass(self):
        self.getPage('/resource')
        self.assertStatus(200)
        self.assertBody('"NoneType"')

        self.getPage('/resource?limit=0')
        self.assertStatus(200)
        self.assertBody('"int"')

    def test_error(self):
        self.getPage('/resource?limit=')
        self.assertStatus(400)
        self.assertInBody('invalid literal for int')

        cherrypy.config['tools.params.error'] = 422
        self.getPage('/resource?limit=')
        self.assertStatus(422)
        self.assertInBody('invalid literal for int')

        cherrypy.config['tools.params.exception'] = TypeError
        self.getPage('/resource?limit=')
        self.assertStatus(500)

    def test_syntax(self):
        if sys.version_info < (3,):
            return self.skip('skipped (Python 3 only)')
        code = textwrap.dedent("""
            class Root:
                @cherrypy.expose
                @cherrypy.tools.params()
                def resource(self, limit: int):
                    return type(limit).__name__
            conf = {'/': {'tools.params.on': True}}
            cherrypy.tree.mount(Root(), config=conf)
            """)
        exec(code)

        self.getPage('/resource?limit=0')
        self.assertStatus(200)
        self.assertBody('int')

Youez - 2016 - github.com/yon3zu
LinuXploit