From a0a01d6848c3fc1b51febda49e58df8de722311d Mon Sep 17 00:00:00 2001 From: Andrew Krasichkov Date: Mon, 3 Apr 2017 23:29:59 +0300 Subject: [PATCH 1/2] [tests] Allow to specify plugin options --- tests/plugins/test_simply.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/plugins/test_simply.py b/tests/plugins/test_simply.py index 78b009b..e93fb65 100644 --- a/tests/plugins/test_simply.py +++ b/tests/plugins/test_simply.py @@ -60,16 +60,27 @@ def test_from_config(): 'Plugin "{}" should have at least one simple test config with false positive'.format(plugin)) -def yoda_provider(plugin): +def parse_plugin_options(config_path): + with open(config_path, 'r') as f: + config_line = f.readline() + if config_line.startswith('# Options: '): + return json.loads(config_line[10:]) + return None + + +def yoda_provider(plugin, plugin_options=None): config = Config( allow_includes=False, plugins=[plugin] ) + if plugin_options: + config.set_for(plugin, plugin_options) return Gixy(config=config) def check_configuration(plugin, config_path, test_config): - with yoda_provider(plugin) as yoda: + plugin_options = parse_plugin_options(config_path) + with yoda_provider(plugin, plugin_options) as yoda: yoda.audit(config_path) results = RawFormatter().format(yoda) From 2a93331db2f71ac4b5a37fce0806df5215623baa Mon Sep 17 00:00:00 2001 From: Andrew Krasichkov Date: Mon, 3 Apr 2017 23:30:18 +0300 Subject: [PATCH 2/2] Added valid domains for origin tests --- tests/plugins/simply/origins/origin_wo_slash.conf | 4 ++++ tests/plugins/simply/origins/webvisor.conf | 2 ++ 2 files changed, 6 insertions(+) diff --git a/tests/plugins/simply/origins/origin_wo_slash.conf b/tests/plugins/simply/origins/origin_wo_slash.conf index 610c10c..03decaf 100644 --- a/tests/plugins/simply/origins/origin_wo_slash.conf +++ b/tests/plugins/simply/origins/origin_wo_slash.conf @@ -1,3 +1,7 @@ +# Options: {"domains": ["yandex.ru"]} + +http { if ($http_origin !~ '^https?:\/\/yandex\.ru') { +} } \ No newline at end of file diff --git a/tests/plugins/simply/origins/webvisor.conf b/tests/plugins/simply/origins/webvisor.conf index bd72852..7b4c085 100644 --- a/tests/plugins/simply/origins/webvisor.conf +++ b/tests/plugins/simply/origins/webvisor.conf @@ -1,3 +1,5 @@ +# Options: {"domains": ["webvisor.com", "yandex.com"]} + if ($http_referer !~ "^https?://([^/]+\.)?yandex\.com/|([^/]+\.)?webvisor\.com/"){ add_header X-Frame-Options SAMEORIGIN; } \ No newline at end of file