コード例 #1
0
ファイル: test_common.py プロジェクト: x0rzkov/detectem
    def test_matches(self, plugin, yaml_dict):
        pm = self._get_plugin_match(plugin, yaml_dict)

        # More than one value could be asserted, then we need to create this dict
        asserter = {
            k: v
            for k, v in yaml_dict.items()
            if k in ["version", "name", "presence"]
        }
        assert pm == create_pm(**asserter)
コード例 #2
0
    def test_real_generic_plugin(
        self, plugin_name, matcher_type, har_content, name, plugins
    ):
        plugin = plugins.get(plugin_name)
        har_entry = create_har_entry(matcher_type, value=har_content)

        # Verify presence using matcher class
        matchers = plugin.get_matchers(matcher_type)
        matcher_class = MATCHERS[matcher_type]

        assert matcher_class.get_info(har_entry, *matchers) == create_pm(presence=True)

        assert plugin.get_information(har_entry)["name"] == name
コード例 #3
0
 def test_get_version_with_har(self, entry):
     version_re = r"foo-(?P<version>[\d\.]+)"
     assert UrlMatcher.get_info(entry,
                                version_re) == create_pm(version="1.1")
コード例 #4
0
 def test_get_name(self, matcher_class, entry, matcher, name):
     assert matcher_class.get_info(entry, matcher) == create_pm(name=name)
コード例 #5
0
 def test_get_presence(self, matcher_class, entry, matcher, presence):
     assert matcher_class.get_info(entry,
                                   matcher) == create_pm(presence=presence)
コード例 #6
0
 def test_get_version(self, matcher_class, entry, matcher, version):
     assert matcher_class.get_info(entry,
                                   matcher) == create_pm(version=version)