Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_search_records(self):
params = get_synced_params()
records = api.search_records(params, '')
self.assertEqual(len(records), len(params.record_cache))
records = api.search_records(params, 'RECORD')
self.assertEqual(len(records), len(params.record_cache))
records = api.search_records(params, 'Record 1')
self.assertEqual(len(records), 1)
records = api.search_records(params, 'INVALID')
self.assertEqual(len(records), 0)
def test_search_records(self):
params = get_synced_params()
records = api.search_records(params, '')
self.assertEqual(len(records), len(params.record_cache))
records = api.search_records(params, 'RECORD')
self.assertEqual(len(records), len(params.record_cache))
records = api.search_records(params, 'Record 1')
self.assertEqual(len(records), 1)
records = api.search_records(params, 'INVALID')
self.assertEqual(len(records), 0)
def test_search_records(self):
params = get_synced_params()
records = api.search_records(params, '')
self.assertEqual(len(records), len(params.record_cache))
records = api.search_records(params, 'RECORD')
self.assertEqual(len(records), len(params.record_cache))
records = api.search_records(params, 'Record 1')
self.assertEqual(len(records), 1)
records = api.search_records(params, 'INVALID')
self.assertEqual(len(records), 0)
def test_search_records(self):
params = get_synced_params()
records = api.search_records(params, '')
self.assertEqual(len(records), len(params.record_cache))
records = api.search_records(params, 'RECORD')
self.assertEqual(len(records), len(params.record_cache))
records = api.search_records(params, 'Record 1')
self.assertEqual(len(records), 1)
records = api.search_records(params, 'INVALID')
self.assertEqual(len(records), 0)
from keepercommander.params import KeeperParams
from keepercommander import display, api
my_params = KeeperParams()
while not my_params.user:
my_params.user = getpass.getpass(prompt='User(Email): ', stream=None)
while not my_params.password:
my_params.password = getpass.getpass(prompt='Master Password: ', stream=None)
searchstring = getpass.getpass(prompt='Search String: ', stream=None)
api.sync_down(my_params)
# Search records
results = api.search_records(my_params, searchstring)
for r in results:
print('Record UID ' + r.record_uid + ' matches')
# Note: see record.py for available fields or
# call display.formatted_records(results) to show all record details
# Search shared folders
results = api.search_shared_folders(my_params, searchstring)
for sf in results:
print('Shared Folder UID ' + sf.shared_folder_uid + ' matches')
# Search teams
results = api.search_teams(my_params, searchstring)
for t in results:
print('Team UID ' + t.team_uid + ' matches')
def execute(self, params, **kwargs):
pattern = kwargs['pattern'] if 'pattern' in kwargs else None
results = api.search_records(params, pattern or '')
if results:
if len(results) < 5:
api.get_record_shares(params, [x.record_uid for x in results])
display.formatted_records(results)
def execute(self, params, **kwargs):
pattern = (kwargs['pattern'] if 'pattern' in kwargs else None) or ''
# Search records
results = api.search_records(params, pattern)
if results:
print('')
display.formatted_records(results)
# Search shared folders
results = api.search_shared_folders(params, pattern)
if results:
print('')
display.formatted_shared_folders(results, params=params, skip_details=True)
# Search teams
results = api.search_teams(params, pattern)
if results:
print('')
display.formatted_teams(results, params=params, skip_details=True)
if len(endpoints) > 0:
if len(endpoints) == 1:
record_uid = endpoints[0].record_uid
rotate_name = endpoints[0].name
else:
logging.error('There are more than one rotation records with name %s. Please use record UID.', name)
return
if record_uid:
rotate_password(params, record_uid, name=rotate_name)
if print_result:
record = api.get_record(params, record_uid)
record.display()
else:
logging.error('Rotate {0}: not found'.format(name))
elif match:
results = api.search_records(params, match)
for r in results:
rotate_password(params, r.record_uid)
if print_result:
record = api.get_record(params, r.record_uid)
record.display()
else:
RecordRotateCommand.find_endpoints(params)
if RecordRotateCommand.Endpoints:
logging.info("Available records for password rotation")
logging.info('')
headers = ["#", 'Name', 'Type', 'Record UID', 'Record Title', 'Folder(s)']
table = []
for i in range(len(RecordRotateCommand.Endpoints)):
endpoint = RecordRotateCommand.Endpoints[i]
title = endpoint.record_title
folder = endpoint.paths[0] if len(endpoint.paths) > 0 else '/'