Ejemplo n.º 1
0
    def test_channel_started(self):
        plugin = NginxPlugin()
        locations_dirname = self.make_temp_dir()

        plugin.start_plugin({
            'server_name': 'http//www.example.org',
            'vhost_file': self.make_temp_file(),
            'locations_dir': locations_dirname
        }, JunebugConfig({}))

        properties = self.create_channel_properties(
            web_path='/foo/bar',
            web_port=2323)

        channel = yield self.create_channel(
            self.service, self.redis, id='chan4', properties=properties)

        plugin.channel_started(channel)

        self.assertEqual(
            read(path.join(locations_dirname, 'chan4.conf')),
            read(plugin.config.location_template) % {
                'external_path': '/foo/bar',
                'internal_url': 'http://localhost:2323/foo/bar'
            })
Ejemplo n.º 2
0
    def test_channel_started(self):
        plugin = NginxPlugin()
        locations_dirname = self.make_temp_dir()

        plugin.start_plugin(
            {
                'server_name': 'http//www.example.org',
                'vhost_file': self.make_temp_file(),
                'locations_dir': locations_dirname
            }, JunebugConfig({}))

        properties = self.create_channel_properties(config={
            'web_path': '/foo/bar',
            'web_port': 2323,
        })

        channel = yield self.create_channel(self.service,
                                            self.redis,
                                            id='chan4',
                                            properties=properties)

        plugin.channel_started(channel)

        self.assertEqual(
            read(path.join(locations_dirname, 'chan4.conf')),
            read(plugin.config.location_template) % {
                'external_path': '/foo/bar',
                'internal_url': 'http://localhost:2323/foo/bar'
            })
Ejemplo n.º 3
0
    def test_channel_started_custom_template(self):
        plugin = NginxPlugin()
        locations_dirname = self.make_temp_dir()
        location_template_filename = self.make_temp_file()
        write(location_template_filename, '%(external_path)s')

        plugin.start_plugin(
            {
                'server_name': 'http//www.example.org',
                'vhost_file': self.make_temp_file(),
                'locations_dir': locations_dirname,
                'location_template': location_template_filename
            }, JunebugConfig({}))

        properties = self.create_channel_properties(web_path='/foo/bar',
                                                    web_port=2323)

        channel = yield self.create_channel(self.service,
                                            self.redis,
                                            id='chan4',
                                            properties=properties)

        plugin.channel_started(channel)

        self.assertEqual(read(path.join(locations_dirname, 'chan4.conf')),
                         '/foo/bar')
Ejemplo n.º 4
0
    def test_channel_started_custom_template(self):
        plugin = NginxPlugin()
        locations_dirname = self.make_temp_dir()
        location_template_filename = self.make_temp_file()
        write(location_template_filename, '%(external_path)s')

        plugin.start_plugin({
            'server_name': 'http//www.example.org',
            'vhost_file': self.make_temp_file(),
            'locations_dir': locations_dirname,
            'location_template': location_template_filename
        }, JunebugConfig({}))

        properties = self.create_channel_properties(config={
            'web_path': '/foo/bar',
            'web_port': 2323,
        })

        channel = yield self.create_channel(
            self.service, self.redis, id='chan4', properties=properties)

        plugin.channel_started(channel)

        self.assertEqual(
            read(path.join(locations_dirname, 'chan4.conf')),
            '/foo/bar')
Ejemplo n.º 5
0
    def test_start_plugin_create_vhost_config(self):
        plugin = NginxPlugin()

        locations_dirname = self.make_temp_dir()
        vhost_filename = self.make_temp_file()

        plugin.start_plugin({
            'server_name': 'http//www.example.org',
            'vhost_file': vhost_filename,
            'locations_dir': locations_dirname
        }, JunebugConfig({}))

        self.assertEqual(
            read(vhost_filename),
            read(plugin.config.vhost_template) % {
                'server_name': 'http//www.example.org',
                'includes': path.join(locations_dirname, '*.conf')
            })
Ejemplo n.º 6
0
    def test_start_plugin_create_vhost_config(self):
        plugin = NginxPlugin()

        locations_dirname = self.make_temp_dir()
        vhost_filename = self.make_temp_file()

        plugin.start_plugin(
            {
                'server_name': 'http//www.example.org',
                'vhost_file': vhost_filename,
                'locations_dir': locations_dirname
            }, JunebugConfig({}))

        self.assertEqual(
            read(vhost_filename),
            read(plugin.config.vhost_template) % {
                'server_name': 'http//www.example.org',
                'includes': path.join(locations_dirname, '*.conf')
            })
Ejemplo n.º 7
0
    def test_start_plugin_create_vhost_config_custom_template(self):
        plugin = NginxPlugin()

        vhost_filename = self.make_temp_file()
        vhost_template_filename = self.make_temp_file()
        write(vhost_template_filename, '%(server_name)s')

        plugin.start_plugin({
            'server_name': 'http//www.example.org',
            'vhost_file': vhost_filename,
            'locations_dir': self.make_temp_dir(),
            'vhost_template': vhost_template_filename,
        }, JunebugConfig({}))

        self.assertEqual(read(vhost_filename), 'http//www.example.org')
Ejemplo n.º 8
0
    def test_start_plugin_create_vhost_config_custom_template(self):
        plugin = NginxPlugin()

        vhost_filename = self.make_temp_file()
        vhost_template_filename = self.make_temp_file()
        write(vhost_template_filename, '%(server_name)s')

        plugin.start_plugin(
            {
                'server_name': 'http//www.example.org',
                'vhost_file': vhost_filename,
                'locations_dir': self.make_temp_dir(),
                'vhost_template': vhost_template_filename,
            }, JunebugConfig({}))

        self.assertEqual(read(vhost_filename), 'http//www.example.org')