How to use the amplify.agent.objects.nginx.config.config.NginxConfig function in amplify

To help you get started, we’ve selected a few amplify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nginxinc / nginx-amplify-agent / test / unit / agent / objects / nginx / config / config.py View on Github external
def test_proxy_buffers_complex(self):
        config = NginxConfig(proxy_buffers_complex_config)
        config.full_parse()

        assert_that(config.subtree, has_item(
            has_entries({
                'directive': 'http',
                'block': has_items(
                    has_entries({'directive': 'proxy_buffering'}),
                    has_entries({'directive': 'proxy_buffers'}),
                    has_entries({
                        'directive': 'server',
                        'block': has_item(
                            has_entries({
                                'directive': 'location',
                                'args': ['/'],
                                'block': has_items(
                                    has_entries({'directive': 'proxy_pass'}),
github nginxinc / nginx-amplify-agent / test / unit / agent / objects / nginx / config / config.py View on Github external
def test_json(self):
        config = NginxConfig(json_config)
        config.full_parse()

        assert_that(config.log_formats, has_key('json'))
        assert_that(
            config.log_formats['json'],
            equal_to('{ "time_iso8601": "$time_iso8601", "browser": [{"modern_browser": "$modern_browser", '
                     '"ancient_browser": "$ancient_browser", "msie": "$msie"}], "core": [{"args": "$args", "arg": '
github nginxinc / nginx-amplify-agent / test / unit / agent / objects / nginx / config / config.py View on Github external
def test_broken_includes(self):
        config = NginxConfig(huge_config)
        config.full_parse()

        assert_that(config.tree, has_entries({
            'status': 'failed',
            'errors': has_length(9),
            'config': contains(
                has_entries({
                    'file': '/amplify/test/fixtures/nginx/huge/nginx.conf',
                    'status': 'failed',
                    'errors': contains(
                        {'error': "[Errno 2] No such file or directory: '/amplify/test/fixtures/nginx/huge/mime.types2'", 'line': 13},
                        {'error': "[Errno 2] No such file or directory: '/amplify/test/fixtures/nginx/huge/dir.map'", 'line': 31},
                        {'error': "[Errno 2] No such file or directory: '/amplify/test/fixtures/nginx/huge/ec2-public-networks.conf'", 'line': 114},
                        {'error': "[Errno 2] No such file or directory: '/amplify/test/fixtures/nginx/huge/ec2-public-networks.conf'", 'line': 117},
                        {'error': "[Errno 2] No such file or directory: '/amplify/test/fixtures/nginx/huge/ec2-public-networks.conf'", 'line': 120},
                        {'error': "[Errno 2] No such file or directory: '/amplify/test/fixtures/nginx/huge/ec2-public-networks.conf'", 'line': 123},
github nginxinc / nginx-amplify-agent / test / unit / agent / objects / nginx / config / config.py View on Github external
def test_logs_definitions_with_tabs(self):
        config = NginxConfig(tabs_everywhere)
        config.full_parse()

        assert_that(config.access_logs, has_key('/var/log/nginx/bbb.aaa.org.log'))
github nginxinc / nginx-amplify-agent / test / unit / agent / objects / nginx / config / config.py View on Github external
def test_status_urls(self):
        """
        Tests that statuses are found correctly
        """
        config = NginxConfig(status_urls)
        config.full_parse()

        assert_that(config, has_property('stub_status_urls', ['http://127.0.0.1:80/', 'http://127.0.0.1:80/nginx_status']))
        assert_that(config, has_property('plus_status_external_urls', ['http://www.example.com:80/status']))
        assert_that(config, has_property('plus_status_internal_urls', ['http://127.0.0.1:80/status']))
github nginxinc / nginx-amplify-agent / test / unit / agent / objects / nginx / config / config.py View on Github external
def test_proxy_buffers_simple(self):
        config = NginxConfig(proxy_buffers_simple_config)
        config.full_parse()

        assert_that(config.subtree, has_item(
            has_entries({
                'directive': 'http',
                'block': has_items(
                    has_entries({'directive': 'proxy_buffering'}),
                    has_entries({'directive': 'proxy_buffers'})
                )
            })
        ))

        assert_that(config.parser_errors, empty())
        assert_that(config.test_errors, empty())
github nginxinc / nginx-amplify-agent / test / unit / agent / objects / nginx / config / config.py View on Github external
def test_parse_huge(self):
        config = NginxConfig(huge_config)
        config.full_parse()

        # error logs
        assert_that(config.error_logs, has_length(1))
        assert_that(config.error_logs, has_key('/var/log/nginx-error.log'))
        assert_that(config.error_logs.values(), only_contains(
            has_entries(
                log_level=is_in(ERROR_LOG_LEVELS),
                permissions=matches_regexp('[0-7]{4}'),
                readable=instance_of(bool)
            )
        ))

        # access logs
        assert_that(config.access_logs, has_length(6))
        assert_that(config.access_logs, has_item('/var/log/default.log'))
github nginxinc / nginx-amplify-agent / test / unit / agent / objects / nginx / config / config.py View on Github external
def test_parse_simple(self):
        config = NginxConfig(simple_config)
        config.full_parse()

        # error logs
        assert_that(config.error_logs, has_length(1))
        assert_that(config.error_logs, has_key('/var/log/nginx/error.log'))
        assert_that(config.error_logs.values(), only_contains(
            has_entries(
                log_level=is_in(ERROR_LOG_LEVELS),
                permissions=matches_regexp('[0-7]{4}'),
                readable=instance_of(bool)
            )
        ))

        # access logs
        assert_that(config.access_logs, has_length(2))
        assert_that(config.access_logs, has_item('/var/log/nginx/access.log'))
github nginxinc / nginx-amplify-agent / amplify / agent / tanks / nginx_config.py View on Github external
def __getitem__(self, ident):
        # if the config does not exist, create it
        filename, prefix, bin_path = ident
        if ident not in self._configs:
            self._configs[ident] = NginxConfig(filename=filename, prefix=prefix, binary=bin_path)

        return self._configs[ident]
github nginxinc / nginx-amplify-agent / tools / cfgparser.py View on Github external
def dump(heading, *payloads):
        if heading:
            print '\033[32m{} for {}\033[0m'.format(heading, args.config)
        for x in payloads:
            if isinstance(x, dict) and args.pretty:
                print json.dumps(x, indent=4, sort_keys=True)
            elif isinstance(x, dict):
                print json.dumps(x, separators=(',', ':'), sort_keys=True)
            else:
                print json.dumps(x)  # never prettify print lists
        print

    start = time.time()

    cfg = NginxConfig(filename=args.config)
    if args.light:
        structure = cfg.collect_structure(include_ssl_certs=True)
    else:
        cfg.full_parse()

    runtime = time.time() - start

    if args.quiet:
        print 'Parsed in %s seconds' % runtime
        return

    if args.light:
        dump(None, *structure)
    elif args.simple:
        dump(None, cfg.subtree)
    elif args.dirmap: