def test_tagsearch_prefixsuffix(self): results = search.tagsearch(['tagprefix:']) self.assertEquals(1, len(results.resource_matches)) self.assertEquals(1, len(results.password_matches)) results = search.tagsearch([':tagone']) self.assertEquals(1, len(results.resource_matches)) self.assertEquals(2, len(results.password_matches))
def test_tagsearch_partial(self): results = search.tagsearch(['tagone', 'tagtwo'], search_resources=False) self.assertEquals(0, len(results.resource_matches)) self.assertEquals(2, len(results.password_matches)) results = search.tagsearch(['tagone', 'tagtwo'], search_passwords=False) self.assertEquals(2, len(results.resource_matches)) self.assertEquals(0, len(results.password_matches))
def tagsearch(self, tags): """ Perform a search for specified tags (only). :param tags: A list of tags to search for (and). :type tags: list :returns: A dict like {'resources': [r1,r2,...], 'passwords': [p1,p2,...]} :rtype: dict """ results = search.tagsearch(tags) auditlog.log(auditlog.CODE_SEARCH, comment=repr(tags)) return { 'resources': [r.to_dict(decrypt=False) for r in results.resource_matches], 'passwords': [r.to_dict(decrypt=False) for r in results.password_matches], }
def test_tagsearch_basic(self): results = search.tagsearch(['tagone']) self.assertEquals(3, len(results.resource_matches)) self.assertEquals(2, len(results.password_matches))
def test_tagsearch_prefix_naive(self): results = search.tagsearch(['tagprefix']) self.assertEquals(1, len(results.resource_matches)) self.assertEquals(2, len(results.password_matches))
def test_tagsearch_multi(self): results = search.tagsearch(['tagone', 'tagtwo']) self.assertEquals(2, len(results.resource_matches)) self.assertEquals(2, len(results.password_matches))