def _keys(args): # pragma: no cover check = check_repo() if args.create is True and args.import_keys is True: log.error('Only one options is allowed at a time') sys.exit(1) if args.create is True and check is True: log.error('You can not create off-line keys on your dev machine') sys.exit(1) if args.import_keys is True and check is False: _repo_error() if args.create is True and check is False: k = Keys() app_name = get_correct_answer('Please enter app name', required=True) k.make_keypack(app_name) log.info('Keypack placed in cwd') return if args.import_keys is True and check is True: loader = Loader() config = loader.load_config() ki = KeyImporter() imported = ki.start() if imported is True: log.info('Keypack import successfully') loader.save_config(config) else: log.warning('Keypack import failed')
def _cmd_keys(*args): # pragma: no cover check = check_repo_ex() ns = args[0] # We try to prevent developers from creating root keys on the dev # machines. if ns.create is True and ns.import_keys is True: log.error('Only one options is allowed at a time') return # Okay the actual check is pretty weak but we are all grown ups here :) if ns.create is True and check is True: log.error('You can not create off-line keys on your dev machine') return # Can't import if we don't have a config to place it in. if ns.import_keys is True and check is False: return # We are supposed to be on another secure computer. # Security is in the eye of the beholder. # That was deep. if ns.create is True and check is False: if hasattr(ns, 'test'): log.debug('We are testing!') app_name = 'test' # Starting up with some testing in mind. k = Keys(test=True) else: k = Keys() # Get the app name for the soon to be generated keypack.pyu app_name = get_correct_answer('Please enter app name', required=True) # Create the keypack for this particular application. # make_keypack will return True if successful. if k.make_keypack(app_name): log.info('Keypack placed in cwd') else: log.error('Failed to create keypack') return # Save the keypack.pyu that's in the current directory to the # .pyupdater/config.pyu file. if ns.import_keys is True and check is True: cm = ConfigManager() config = cm.load_config() ki = KeyImporter() if ki.start(): log.info('Keypack import successfully') cm.save_config(config) else: log.warning('Keypack import failed')
def _cmd_keys(*args): # pragma: no cover check = check_repo_ex() ns = args[0] # We try to prevent developers from creating root keys on the dev # machines. if ns.create_keys is True and ns.import_keys is True: log.error('Only one options is allowed at a time') return # Okay the actual check is pretty weak but we are all grown ups here :) if ns.create_keys is True and check is True: log.error('You can not create off-line keys on your dev machine') return # Can't import if we don't have a config to place it in. if ns.import_keys is True and check is False: return # We are supposed to be on another secure computer. # Security is in the eye of the beholder. # That was deep. if ns.create_keys is True and check is False: if hasattr(ns, 'test'): log.debug('We are testing!') app_name = 'test' # Starting up with some testing in mind. k = Keys(test=True) else: k = Keys() # Get the app name for the soon to be generated keypack.pyu app_name = get_correct_answer('Please enter app name', required=True) # Create the keypack for this particular application. # make_keypack will return True if successful. if k.make_keypack(app_name): log.info('Keypack placed in cwd') else: log.error('Failed to create keypack') return # Save the keypack.pyu that's in the current directory to the # .pyupdater/config.pyu file. if ns.import_keys is True and check is True: cm = ConfigManager() config = cm.load_config() ki = KeyImporter() if ki.start(): log.info('Keypack import successfully') cm.save_config(config) else: log.error('Keypack import failed')
def create_keypack(): keys = Keys(test=True) keys.make_keypack('test')
def test_create_keypack(self): k = Keys(test=True) for name in ['one', 'two', 'three']: assert k.make_keypack(name) is True assert os.path.exists(k.data_dir) is True
def test_key_importer(self): k = Keys(test=True) k.make_keypack('one') ki = KeyImporter() assert ki.start() is True