!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache/2.4.18 (Ubuntu). PHP/7.0.33-0ubuntu0.16.04.16 

uname -a: Linux digifus 3.13.0-57-generic #95-Ubuntu SMP Fri Jun 19 09:28:15 UTC 2015 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/usr/local/lib/python2.7/dist-packages/flask_api/tests/   drwxr-sr-x
Free 9.5 GB of 29.4 GB (32.31%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     test_negotiation.py (3.58 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
# coding: utf8
from __future__ import unicode_literals
import unittest
import flask_api
from flask_api import exceptions
from flask_api.negotiation import BaseNegotiation, DefaultNegotiation


app = flask_api.FlaskAPI(__name__)


class JSON(object):
    media_type = 'application/json'


class HTML(object):
    media_type = 'application/html'


class URLEncodedForm(object):
    media_type = 'application/x-www-form-urlencoded'


class TestRendererNegotiation(unittest.TestCase):
    def test_select_renderer_client_preference(self):
        negotiation = DefaultNegotiation()
        renderers = [JSON, HTML]
        headers = {'Accept': 'application/html'}
        with app.test_request_context(headers=headers):
            renderer, media_type = negotiation.select_renderer(renderers)
            self.assertEqual(renderer, HTML)
            self.assertEqual(str(media_type), 'application/html')

    def test_select_renderer_no_accept_header(self):
        negotiation = DefaultNegotiation()
        renderers = [JSON, HTML]
        with app.test_request_context():
            renderer, media_type = negotiation.select_renderer(renderers)
            self.assertEqual(renderer, JSON)
            self.assertEqual(str(media_type), 'application/json')

    def test_select_renderer_server_preference(self):
        negotiation = DefaultNegotiation()
        renderers = [JSON, HTML]
        headers = {'Accept': '*/*'}
        with app.test_request_context(headers=headers):
            renderer, media_type = negotiation.select_renderer(renderers)
            self.assertEqual(renderer, JSON)
            self.assertEqual(str(media_type), 'application/json')

    def test_select_renderer_failed(self):
        negotiation = DefaultNegotiation()
        renderers = [JSON, HTML]
        headers = {'Accept': 'application/xml'}
        with app.test_request_context(headers=headers):
            with self.assertRaises(exceptions.NotAcceptable):
                renderer, media_type = negotiation.select_renderer(renderers)

    def test_renderer_negotiation_not_implemented(self):
        negotiation = BaseNegotiation()
        with self.assertRaises(NotImplementedError) as context:
            negotiation.select_renderer([])
        msg = str(context.exception)
        expected = '`select_renderer()` method must be implemented for class "BaseNegotiation"'
        self.assertEqual(msg, expected)


class TestParserNegotiation(unittest.TestCase):
    def test_select_parser(self):
        negotiation = DefaultNegotiation()
        parsers = [JSON, URLEncodedForm]
        headers = {'Content-Type': 'application/x-www-form-urlencoded'}
        with app.test_request_context(headers=headers):
            renderer, media_type = negotiation.select_parser(parsers)
            self.assertEqual(renderer, URLEncodedForm)
            self.assertEqual(str(media_type), 'application/x-www-form-urlencoded')

    def test_select_parser_failed(self):
        negotiation = DefaultNegotiation()
        parsers = [JSON, URLEncodedForm]
        headers = {'Content-Type': 'application/xml'}
        with app.test_request_context(headers=headers):
            with self.assertRaises(exceptions.UnsupportedMediaType):
                renderer, media_type = negotiation.select_parser(parsers)

    def test_parser_negotiation_not_implemented(self):
        negotiation = BaseNegotiation()
        with self.assertRaises(NotImplementedError) as context:
            negotiation.select_parser([])
        msg = str(context.exception)
        expected = '`select_parser()` method must be implemented for class "BaseNegotiation"'
        self.assertEqual(msg, expected)

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0053 ]--