Example #1
0
def test_get_secure_cookie(tmp_path):
    config = {
        "http": {
            "hostname": "127.0.0.1",
            "port": 6680,
            "zeroconf": "",
            "default_app": "mopidy",
        },
        "core": {
            "data_dir": tmp_path
        },
    }
    core = mock.Mock()

    http_server = actor.HttpServer(config=config,
                                   core=core,
                                   sockets=[],
                                   apps=[],
                                   statics=[])

    # first secret, generating
    secret_1 = http_server._get_cookie_secret()

    assert isinstance(secret_1, str)
    assert secret_1 != ""
    assert len(secret_1) == 64

    # second secret, from file
    secret_2 = http_server._get_cookie_secret()
    assert secret_1 == secret_2
Example #2
0
    def get_app(self):
        self._dirpath = tempfile.mkdtemp()

        config = {
            "http": {
                "hostname": "127.0.0.1",
                "port": 6680,
                "zeroconf": "",
                "default_app": "mopidy",
            },
            "core": {
                "data_dir": self._dirpath
            },
        }
        core = mock.Mock()

        apps = [{
            "name": "cookie_secret",
            "factory": cookie_secret_app_factory
        }]

        http_server = actor.HttpServer(config=config,
                                       core=core,
                                       sockets=[],
                                       apps=apps,
                                       statics=[])

        return tornado.web.Application(
            http_server._get_request_handlers(),
            cookie_secret=http_server._get_cookie_secret(),
        )
Example #3
0
    def get_app(self):
        config = {
            'http': {
                'hostname': '127.0.0.1',
                'port': 6680,
                'static_dir': None,
                'zeroconf': '',
            }
        }
        core = mock.Mock()

        statics = [dict(name='static', path=os.path.dirname(__file__))]

        http_server = actor.HttpServer(
            config=config, core=core, sockets=[], apps=[], statics=statics)

        return tornado.web.Application(http_server._get_request_handlers())
Example #4
0
    def get_app(self):
        core = mock.Mock()
        core.get_version = mock.MagicMock(name='get_version')
        core.get_version.return_value = mopidy.__version__

        testapps = [dict(name='testapp')]
        teststatics = [dict(name='teststatic')]

        apps = [{
            'name': 'mopidy',
            'factory': handlers.make_mopidy_app_factory(testapps, teststatics),
        }]

        http_server = actor.HttpServer(
            config=self.get_config(), core=core, sockets=[],
            apps=apps, statics=[])

        return tornado.web.Application(http_server._get_request_handlers())
Example #5
0
    def get_app(self):
        config = {
            'http': {
                'hostname': '127.0.0.1',
                'port': 6680,
                'static_dir': None,
                'zeroconf': '',
            }
        }
        core = mock.Mock()

        apps = [{
            'name': 'wsgi',
            'factory': wsgi_app_factory,
        }]

        http_server = actor.HttpServer(
            config=config, core=core, sockets=[], apps=apps, statics=[])

        return tornado.web.Application(http_server._get_request_handlers())
Example #6
0
    def get_app(self):
        config = {
            "http": {
                "hostname": "127.0.0.1",
                "port": 6680,
                "zeroconf": "",
                "default_app": "default_app",
            }
        }
        core = mock.Mock()

        statics = [dict(name="default_app", path=os.path.dirname(__file__))]

        http_server = actor.HttpServer(config=config,
                                       core=core,
                                       sockets=[],
                                       apps=[],
                                       statics=statics)

        return tornado.web.Application(http_server._get_request_handlers())
Example #7
0
    def get_app(self):
        config = {
            "http": {
                "hostname": "127.0.0.1",
                "port": 6680,
                "zeroconf": "",
                "default_app": "default_app",
            }
        }
        core = mock.Mock()

        apps = [dict(name="default_app", factory=default_webapp_factory)]

        http_server = actor.HttpServer(config=config,
                                       core=core,
                                       sockets=[],
                                       apps=apps,
                                       statics=[])

        return tornado.web.Application(http_server._get_request_handlers())
Example #8
0
    def get_app(self):
        core = mock.Mock()
        core.get_version = mock.MagicMock(name="get_version")
        core.get_version.return_value = mopidy.__version__

        testapps = [dict(name="testapp")]
        teststatics = [dict(name="teststatic")]

        apps = [{
            "name":
            "mopidy",
            "factory":
            handlers.make_mopidy_app_factory(testapps, teststatics),
        }]

        http_server = actor.HttpServer(
            config=self.get_config(),
            core=core,
            sockets=[],
            apps=apps,
            statics=[],
        )

        return tornado.web.Application(http_server._get_request_handlers())