ruby-keepassx 0.2.0beta11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +9 -0
- data/.rvmrc +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +5 -0
- data/README.md +28 -0
- data/Rakefile +5 -0
- data/lib/keepassx.rb +56 -0
- data/lib/keepassx/aes_crypt.rb +19 -0
- data/lib/keepassx/database.rb +431 -0
- data/lib/keepassx/entry.rb +155 -0
- data/lib/keepassx/entry_field.rb +27 -0
- data/lib/keepassx/exceptions.rb +4 -0
- data/lib/keepassx/field.rb +205 -0
- data/lib/keepassx/group.rb +138 -0
- data/lib/keepassx/group_field.rb +22 -0
- data/lib/keepassx/header.rb +178 -0
- data/lib/keepassx/item.rb +128 -0
- data/lib/keepassx/utilities.rb +226 -0
- data/ruby-keepassx.gemspec +23 -0
- data/spec/fixtures/test_data_array.yaml +54 -0
- data/spec/fixtures/test_data_hash.yaml +36 -0
- data/spec/fixtures/test_database.kdb +0 -0
- data/spec/keepassx/database_spec.rb +338 -0
- data/spec/keepassx/entry_spec.rb +72 -0
- data/spec/keepassx/group_spec.rb +47 -0
- data/spec/spec_helper.rb +64 -0
- metadata +126 -0
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Keepassx::Entry do
|
4
|
+
|
5
|
+
include_context :keepassx
|
6
|
+
|
7
|
+
let :entry_schema do
|
8
|
+
Respect::HashSchema.define do |s|
|
9
|
+
s.string :title
|
10
|
+
s.integer :icon
|
11
|
+
s.integer :lastmod
|
12
|
+
s.integer :lastaccess
|
13
|
+
s.integer :creation
|
14
|
+
s.integer :expire
|
15
|
+
s.string :password
|
16
|
+
s.string :username
|
17
|
+
s.string :uuid #, :format => :uuid FIXME: Implement uuid validator
|
18
|
+
s.string :url, :format => :uri
|
19
|
+
# s.string 'binary_desc' # 'binary_desc' comes empty in test data
|
20
|
+
# s.string 'binary_data' # 'binary_data' comes empty in test data
|
21
|
+
s.string :comment
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
let :test_date do
|
27
|
+
1410124392
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
let :test_entry do
|
32
|
+
Keepassx::Entry.new :title => 'test_entry', :icon => 20,
|
33
|
+
:username => 'test', :password => 'test', :url => 'https://example.com',
|
34
|
+
:group => test_group, :creation => test_date,
|
35
|
+
:comment => 'Test comment'
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
describe '#new' do
|
40
|
+
|
41
|
+
it 'raise error when group is missing' do
|
42
|
+
expect { Keepassx::Entry.new :title => 'test_entry',
|
43
|
+
:icon => 20 }.to raise_error
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
it 'does not raise errors' do
|
48
|
+
expect {test_entry}.to_not raise_error
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
describe '#fields' do
|
54
|
+
it 'returns the list of fields' do
|
55
|
+
expect(Keepassx::Entry.fields.length).to eq 13 # FIXME: Define 'let' constant
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
describe '#to_hash' do
|
61
|
+
|
62
|
+
it 'returns Hash entry representation' do
|
63
|
+
expect(entry_schema.validate? test_entry.to_hash).to be true
|
64
|
+
end unless RUBY_VERSION =~ /1.8/ # Respect does not support ruby 1.8.x
|
65
|
+
|
66
|
+
it 'set timestamps properly' do
|
67
|
+
expect(test_entry.to_hash[:creation]).to eq test_date
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Keepassx::Group do
|
4
|
+
|
5
|
+
include_context :keepassx
|
6
|
+
|
7
|
+
let :group_schema do
|
8
|
+
Respect::HashSchema.define do |s|
|
9
|
+
s.integer :id
|
10
|
+
s.string :title
|
11
|
+
s.integer :icon
|
12
|
+
# s.datetime :lastmod
|
13
|
+
# s.datetime :lastaccess
|
14
|
+
# s.datetime :creation
|
15
|
+
# s.datetime :expire
|
16
|
+
s.integer :level
|
17
|
+
s.integer :flags
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
describe '#new' do
|
23
|
+
it 'raise error when id is missing' do
|
24
|
+
expect { Keepassx::Group.new :title => 'test_group', :icon => 20 }.
|
25
|
+
to raise_error
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'does not raise errors' do
|
29
|
+
expect { test_group }.to_not raise_error
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
describe '#fields' do
|
35
|
+
it 'returns the list of fields' do
|
36
|
+
expect(Keepassx::Group.fields.length).to eq 9
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
describe '#to_hash' do
|
42
|
+
it 'returns Hash group representation' do
|
43
|
+
expect(group_schema.validate? test_group.to_hash).to be true
|
44
|
+
end
|
45
|
+
end unless RUBY_VERSION =~ /1.8/ # Respect does not support ruby 1.8.x
|
46
|
+
|
47
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'keepassx'
|
3
|
+
require 'rspec'
|
4
|
+
require 'yaml'
|
5
|
+
require 'respect'
|
6
|
+
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
# ...
|
10
|
+
config.expect_with :rspec do |c|
|
11
|
+
c.syntax = :expect
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
FIXTURE_PATH = File.expand_path(File.join File.dirname(__FILE__), 'fixtures')
|
17
|
+
TEST_DATABASE_PATH = File.join FIXTURE_PATH, '../fixtures/test_database.kdb'
|
18
|
+
NEW_DATABASE_PATH = File.join FIXTURE_PATH, '../fixtures/new_database.kdb'
|
19
|
+
|
20
|
+
shared_context :keepassx do
|
21
|
+
|
22
|
+
# require 'coveralls'
|
23
|
+
# Coveralls.wear!
|
24
|
+
|
25
|
+
before :all do
|
26
|
+
@test_db = Keepassx.open TEST_DATABASE_PATH
|
27
|
+
|
28
|
+
File.delete NEW_DATABASE_PATH if File.exist? NEW_DATABASE_PATH
|
29
|
+
@new_db = Keepassx.new NEW_DATABASE_PATH
|
30
|
+
|
31
|
+
# @data_array_db = Keepassx::Database.new data_array
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
let :data_array do
|
36
|
+
YAML.load File.read File.join FIXTURE_PATH, 'test_data_array.yaml'
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
let :original_data_array do
|
41
|
+
YAML.load File.read File.join FIXTURE_PATH, 'test_data_array.yaml'
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
let :data_array_db do
|
46
|
+
Keepassx.new data_array
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
let :test_db do
|
51
|
+
@test_db
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
let :new_db do
|
56
|
+
@new_db
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
let :test_group do
|
61
|
+
Keepassx::Group.new :title => 'test_group', :id => 0, :icon => 20
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-keepassx
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0beta11
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tony Pitluga
|
8
|
+
- Paul Hinze
|
9
|
+
- Tio Teath
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
|
14
|
+
date: 2014-09-18 00:00:00 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: backports
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 3.6.0
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rspec
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "3.0"
|
34
|
+
type: :development
|
35
|
+
version_requirements: *id002
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: pry
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.9.12
|
44
|
+
type: :development
|
45
|
+
version_requirements: *id003
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: "0.8"
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.8.7
|
57
|
+
type: :development
|
58
|
+
version_requirements: *id004
|
59
|
+
description: This is fork of Tony Pitluga's Ruby API for keepassx with read-write support.
|
60
|
+
email:
|
61
|
+
- tony.pitluga@gmail.com
|
62
|
+
- paul.t.hinze@gmail.com
|
63
|
+
- tio.teath@gmail.com
|
64
|
+
executables: []
|
65
|
+
|
66
|
+
extensions: []
|
67
|
+
|
68
|
+
extra_rdoc_files: []
|
69
|
+
|
70
|
+
files:
|
71
|
+
- .coveralls.yml
|
72
|
+
- .gitignore
|
73
|
+
- .rvmrc
|
74
|
+
- .travis.yml
|
75
|
+
- Gemfile
|
76
|
+
- README.md
|
77
|
+
- Rakefile
|
78
|
+
- lib/keepassx.rb
|
79
|
+
- lib/keepassx/aes_crypt.rb
|
80
|
+
- lib/keepassx/database.rb
|
81
|
+
- lib/keepassx/entry.rb
|
82
|
+
- lib/keepassx/entry_field.rb
|
83
|
+
- lib/keepassx/exceptions.rb
|
84
|
+
- lib/keepassx/field.rb
|
85
|
+
- lib/keepassx/group.rb
|
86
|
+
- lib/keepassx/group_field.rb
|
87
|
+
- lib/keepassx/header.rb
|
88
|
+
- lib/keepassx/item.rb
|
89
|
+
- lib/keepassx/utilities.rb
|
90
|
+
- ruby-keepassx.gemspec
|
91
|
+
- spec/fixtures/test_data_array.yaml
|
92
|
+
- spec/fixtures/test_data_hash.yaml
|
93
|
+
- spec/fixtures/test_database.kdb
|
94
|
+
- spec/keepassx/database_spec.rb
|
95
|
+
- spec/keepassx/entry_spec.rb
|
96
|
+
- spec/keepassx/group_spec.rb
|
97
|
+
- spec/spec_helper.rb
|
98
|
+
homepage: https://github.com/tioteath/ruby-keepassx.git
|
99
|
+
licenses: []
|
100
|
+
|
101
|
+
metadata: {}
|
102
|
+
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: "0"
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.3.1
|
118
|
+
requirements: []
|
119
|
+
|
120
|
+
rubyforge_project:
|
121
|
+
rubygems_version: 2.0.14
|
122
|
+
signing_key:
|
123
|
+
specification_version: 4
|
124
|
+
summary: Ruby API access for KeePassX databases
|
125
|
+
test_files: []
|
126
|
+
|