示例#1
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')
示例#2
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')
示例#3
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')
示例#4
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')
示例#5
0
    def test_channel_stopped_irrelevant_channels(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,
        })

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

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

        write(path.join(locations_dirname, 'chan5.conf'), 'foo')
        plugin.channel_started(chan4)

        self.assertTrue(path.exists(path.join(locations_dirname,
                                              'chan4.conf')))

        self.assertTrue(path.exists(path.join(locations_dirname,
                                              'chan5.conf')))

        plugin.channel_stopped(chan4)
        plugin.channel_stopped(chan5)

        self.assertFalse(
            path.exists(path.join(locations_dirname, 'chan4.conf')))

        self.assertTrue(path.exists(path.join(locations_dirname,
                                              'chan5.conf')))
示例#6
0
    def test_channel_stopped_irrelevant_channels(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,
        })

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

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

        write(path.join(locations_dirname, 'chan5.conf'), 'foo')
        plugin.channel_started(chan4)

        self.assertTrue(
            path.exists(path.join(locations_dirname, 'chan4.conf')))

        self.assertTrue(
            path.exists(path.join(locations_dirname, 'chan5.conf')))

        plugin.channel_stopped(chan4)
        plugin.channel_stopped(chan5)

        self.assertFalse(
            path.exists(path.join(locations_dirname, 'chan4.conf')))

        self.assertTrue(
            path.exists(path.join(locations_dirname, 'chan5.conf')))