예제 #1
0
    def run(self, args: Namespace):
        storage: StorageService = container.get(StorageService)

        with storage.on_standby() as data:
            data.credentials.append(
                Credential.make(args.entry_name, args.username, args.password,
                                args.extra or None, args.tags or []))
예제 #2
0
파일: get.py 프로젝트: shiroyuki/keymaster
    def run(self, args: Namespace):
        entry_id = args.id

        db: Databank = container.get(Databank)
        entry: Secret = db.get('credentials', entry_id) or db.get(
            'notes', entry_id)

        if not entry:
            raise InlineRuntimeError('Found nothing')

        print('')
        print(yaml.dump(asdict(entry)))
        print('')
예제 #3
0
 def execute(self, args):
     role = DefaultRole.USER
     if args.owner and args.admin:
         raise RuntimeError(
             "A user can only be either an admin or an owner, but not both."
         )
     elif args.owner:
         role = DefaultRole.OWNER
     elif args.admin:
         role = DefaultRole.ADMIN
     us: UserService = container.get(UserService)
     print('Adding a new user...')
     new_user_receipt = us.create(role, args.name, args.username,
                                  args.password)
     print('A new user has been registered.\n\n')
     print(yaml.dump(asdict(new_user_receipt), Dumper=yaml.SafeDumper))
예제 #4
0
    def run(self, args: Namespace):
        db: Databank = container.get(Databank)
        entry: Credential = db.get('credentials', args.id)

        if isinstance(entry, Note):
            raise InlineRuntimeError('The request ID is not a credential.')

        if not entry:
            print('The requested ID does not exist.')
            return

        for pn in ('uuid', 'name', 'tags'):
            print(f'{pn.upper()}: {getattr(entry, pn) or "<null>"}')

        pyperclip.copy(entry.password)
        print('The password has been copied to your clipboard.')
예제 #5
0
 def execute(self, args):
     db: Database = container.get(Database)
     db.deinitialize()
     print('Server: DB deinitialized')
예제 #6
0
 def execute(self, args):
     db: Database = container.get(Database)
     db.initialize(Entry, OfflineClient, EntryTag, User)
     print('Server: DB initialized')
예제 #7
0
 def __init__(self):
     self.__randomizer: Randomizer = container.get(Randomizer)
    def test_simple(self):
        obj = c.get(SimpleSampleService)

        self.assertIsInstance(obj, SimpleSampleService)
        self.assertEqual('fooooooo', obj.foo())
 def test_auto_wiring(self):
     _ = c.get(NormalAutoWiredService)
    def test_parameterized(self):
        obj = c.get(ParameterizedSampleService)

        self.assertIsInstance(obj, ParameterizedSampleService)
        self.assertEqual('fooooooo', obj.foo())