diff options
| author | mo <mo.khan@gmail.com> | 2018-06-14 12:20:55 -0600 |
|---|---|---|
| committer | mo <mo.khan@gmail.com> | 2018-06-14 12:20:55 -0600 |
| commit | d309a3c74cd6569fa619bdcdeeb3ab421c890a90 (patch) | |
| tree | f8fd821c68a1d458272d0fccd665d9b4bd403a0a | |
| parent | 796e99cd1ae0e2b5dd72b22f38be41451bffa84b (diff) | |
add spec to read the kdbx database.
| -rw-r--r-- | lib/trunk.rb | 3 | ||||
| -rw-r--r-- | lib/trunk/cli.rb | 7 | ||||
| -rw-r--r-- | lib/trunk/kdbx.rb | 12 | ||||
| -rw-r--r-- | spec/kdbx_spec.rb | 15 |
4 files changed, 36 insertions, 1 deletions
diff --git a/lib/trunk.rb b/lib/trunk.rb index a217793..dd9197e 100644 --- a/lib/trunk.rb +++ b/lib/trunk.rb @@ -5,12 +5,13 @@ require 'thor' require 'yaml' require "trunk/cli" +require "trunk/kdbx" require "trunk/serializers/base_64" require "trunk/serializers/composite" require "trunk/serializers/crypto" require "trunk/storage" -require "trunk/yaml_storage" require "trunk/version" +require "trunk/yaml_storage" module Trunk end diff --git a/lib/trunk/cli.rb b/lib/trunk/cli.rb index 9539d5f..dc01bc0 100644 --- a/lib/trunk/cli.rb +++ b/lib/trunk/cli.rb @@ -27,6 +27,13 @@ module Trunk [database_path, private_key_path].each { |x| FileUtils.chmod(0600, x) } end + desc "import KDBX", "import a kdbx database" + def import(file) + Trunk::KDBX.new(file).each do |item| + puts item.inspect + end + end + private def storage diff --git a/lib/trunk/kdbx.rb b/lib/trunk/kdbx.rb new file mode 100644 index 0000000..5d631ed --- /dev/null +++ b/lib/trunk/kdbx.rb @@ -0,0 +1,12 @@ +module Trunk + class KDBX + include Enumerable + + def initialize(file, password:) + @file = file + end + + def each(&block) + end + end +end diff --git a/spec/kdbx_spec.rb b/spec/kdbx_spec.rb new file mode 100644 index 0000000..f305d07 --- /dev/null +++ b/spec/kdbx_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +RSpec.describe Trunk::KDBX do + subject { described_class.new(path, password: password) } + let(:path) { 'spec/fixtures/trunk.kdbx' } + let(:password) { 'password' } + + describe "#each" do + specify { expect(subject.count).to eql(1) } + specify { expect(subject.first[:title]).to eql('voltron') } + specify { expect(subject.first[:username]).to eql('hunk') } + specify { expect(subject.first[:password]).to eql('TsuyoshiGarett') } + specify { expect(subject.first[:url]).to eql('http://voltron.wikia.com') } + end +end |
