vault 0.1.0 → 0.1.1
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/.gitignore +41 -0
- data/.rspec +2 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +32 -0
- data/LICENSE +362 -0
- data/README.md +80 -54
- data/Rakefile +4 -40
- data/lib/vault.rb +33 -46
- data/lib/vault/api.rb +9 -0
- data/lib/vault/api/auth_token.rb +90 -0
- data/lib/vault/api/help.rb +23 -0
- data/lib/vault/api/logical.rb +66 -0
- data/lib/vault/api/secret.rb +23 -0
- data/lib/vault/api/sys.rb +24 -0
- data/lib/vault/api/sys/audit.rb +60 -0
- data/lib/vault/api/sys/auth.rb +58 -0
- data/lib/vault/api/sys/init.rb +46 -0
- data/lib/vault/api/sys/leader.rb +25 -0
- data/lib/vault/api/sys/lease.rb +51 -0
- data/lib/vault/api/sys/mount.rb +75 -0
- data/lib/vault/api/sys/policy.rb +76 -0
- data/lib/vault/api/sys/seal.rb +49 -0
- data/lib/vault/client.rb +285 -0
- data/lib/vault/configurable.rb +48 -0
- data/lib/vault/defaults.rb +68 -0
- data/lib/vault/errors.rb +48 -0
- data/lib/vault/request.rb +19 -0
- data/lib/vault/response.rb +20 -0
- data/lib/vault/version.rb +1 -6
- data/vault.gemspec +25 -0
- metadata +97 -98
- data/MIT-LICENSE +0 -20
- data/lib/vault/associations.rb +0 -39
- data/lib/vault/attribute_accessors.rb +0 -29
- data/lib/vault/bulk_attributes.rb +0 -17
- data/lib/vault/dirty.rb +0 -37
- data/lib/vault/finders.rb +0 -24
- data/lib/vault/persistance.rb +0 -47
- data/lib/vault/properties.rb +0 -68
- data/lib/vault/scoping.rb +0 -64
- data/lib/vault/storage.rb +0 -4
- data/lib/vault/storage/in_memory_store.rb +0 -14
- data/lib/vault/storage/yaml_store.rb +0 -52
- data/lib/vault/validations.rb +0 -13
- data/spec/active_model_compliance_spec.rb +0 -33
- data/spec/spec_helper.rb +0 -8
- data/spec/support/helpers.rb +0 -16
- data/spec/support/storage_api.rb +0 -14
- data/spec/vault/associations_spec.rb +0 -73
- data/spec/vault/finders_spec.rb +0 -69
- data/spec/vault/persistance_spec.rb +0 -126
- data/spec/vault/properties_spec.rb +0 -59
- data/spec/vault/scoping_spec.rb +0 -53
- data/spec/vault/storage/in_memory_store_spec.rb +0 -5
- data/spec/vault/storage/yaml_store_spec.rb +0 -29
- data/spec/vault_spec.rb +0 -33
data/spec/vault/finders_spec.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Vault do
|
4
|
-
let :person_klass do
|
5
|
-
model do
|
6
|
-
key :name
|
7
|
-
property :email
|
8
|
-
property :age
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
let :john do
|
13
|
-
person_klass.new(:name => "John", :email => "john@example.org", :age => 28)
|
14
|
-
end
|
15
|
-
|
16
|
-
let :mary do
|
17
|
-
person_klass.new(:name => "Mary", :email => "mary@example.org", :age => 23)
|
18
|
-
end
|
19
|
-
|
20
|
-
let :bob do
|
21
|
-
person_klass.new(:name => "Bob", :email => "bob@example.org", :age => 29)
|
22
|
-
end
|
23
|
-
|
24
|
-
let :jane do
|
25
|
-
person_klass.new(:name => "Jane", :email => "jane@example.org", :age => 28)
|
26
|
-
end
|
27
|
-
|
28
|
-
before do
|
29
|
-
john.save
|
30
|
-
mary.save
|
31
|
-
bob.save
|
32
|
-
jane.save
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "#all" do
|
36
|
-
subject { person_klass.all }
|
37
|
-
|
38
|
-
it { should have(4).elements }
|
39
|
-
|
40
|
-
it "includes all the persisted objects" do
|
41
|
-
should include(john)
|
42
|
-
should include(mary)
|
43
|
-
should include(bob)
|
44
|
-
should include(jane)
|
45
|
-
end
|
46
|
-
|
47
|
-
it { should be_an(Enumerable) }
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "#[]" do
|
51
|
-
it "finds an object by key" do
|
52
|
-
person_klass["Bob"].should == bob
|
53
|
-
end
|
54
|
-
|
55
|
-
it "returns nil if it doesn't find it" do
|
56
|
-
person_klass["Jamie"].should be_nil
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "#size" do
|
61
|
-
it "returns the amount of elements in the store" do
|
62
|
-
person_klass.size.should == 4
|
63
|
-
end
|
64
|
-
|
65
|
-
it "is aliased to #count" do
|
66
|
-
person_klass.count.should == person_klass.size
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
@@ -1,126 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Vault do
|
4
|
-
let :book_klass do
|
5
|
-
model do
|
6
|
-
key :isbn
|
7
|
-
property :title
|
8
|
-
property :author
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
let :store do
|
13
|
-
book_klass.store
|
14
|
-
end
|
15
|
-
|
16
|
-
let :alice do
|
17
|
-
book_klass.new("title" => "Alice in Wonderland",
|
18
|
-
"author" => "Lewis Carroll",
|
19
|
-
"isbn" => "978-0862033248")
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "#save" do
|
23
|
-
it "returns true" do
|
24
|
-
alice.save.should be(true)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "marks the object as persisted" do
|
28
|
-
alice.save
|
29
|
-
alice.should be_persisted
|
30
|
-
end
|
31
|
-
|
32
|
-
it "stores the object in the model's store" do
|
33
|
-
alice.save
|
34
|
-
store[alice.isbn].should include("title", "author")
|
35
|
-
end
|
36
|
-
|
37
|
-
it "doesn't store the key among the object properties" do
|
38
|
-
alice.save
|
39
|
-
store[alice.isbn].should_not include("isbn")
|
40
|
-
end
|
41
|
-
|
42
|
-
it "updates an already saved object's attributes" do
|
43
|
-
alice.save
|
44
|
-
alice.update(:title => "Alice in Wonderland Illustrated")
|
45
|
-
alice.save
|
46
|
-
|
47
|
-
store[alice.isbn]["title"].should == "Alice in Wonderland Illustrated"
|
48
|
-
end
|
49
|
-
|
50
|
-
it "clears the tracked changed attributes" do
|
51
|
-
alice.save
|
52
|
-
alice.should_not be_changed
|
53
|
-
end
|
54
|
-
|
55
|
-
it "doesn't keep the old key when you change it" do
|
56
|
-
alice.save
|
57
|
-
alice.update("isbn" => "978-0517223628")
|
58
|
-
old_isbn = alice.isbn_was
|
59
|
-
alice.save
|
60
|
-
|
61
|
-
store[old_isbn].should be_blank
|
62
|
-
store[alice.isbn].should_not be_blank
|
63
|
-
end
|
64
|
-
|
65
|
-
context "when the object is invalid" do
|
66
|
-
let :person_klass do
|
67
|
-
named_model :Person do
|
68
|
-
key :email
|
69
|
-
property :name
|
70
|
-
|
71
|
-
validates :email, :presence => true
|
72
|
-
validates :name, :presence => true
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
let :store do
|
77
|
-
person_klass.store
|
78
|
-
end
|
79
|
-
|
80
|
-
let :nameless_person do
|
81
|
-
person_klass.new(:email => "john.doe@example.org")
|
82
|
-
end
|
83
|
-
|
84
|
-
it "returns false" do
|
85
|
-
nameless_person.save.should be(false)
|
86
|
-
end
|
87
|
-
|
88
|
-
it "doesn't persist the object" do
|
89
|
-
nameless_person.save
|
90
|
-
nameless_person.should_not be_persisted
|
91
|
-
end
|
92
|
-
|
93
|
-
context "but you skip validations" do
|
94
|
-
it "returns true" do
|
95
|
-
nameless_person.save(false).should be(true)
|
96
|
-
end
|
97
|
-
|
98
|
-
it "persists the object anyway" do
|
99
|
-
nameless_person.save(false)
|
100
|
-
nameless_person.should be_persisted
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe "#destroy" do
|
107
|
-
before do
|
108
|
-
alice.save
|
109
|
-
end
|
110
|
-
|
111
|
-
it "should no longer be persisted after being destroyed" do
|
112
|
-
alice.destroy
|
113
|
-
alice.should_not be_persisted
|
114
|
-
end
|
115
|
-
|
116
|
-
it "removes the object from the model's store" do
|
117
|
-
alice.destroy
|
118
|
-
store[alice.isbn].should be_blank
|
119
|
-
end
|
120
|
-
|
121
|
-
it "freezes the model" do
|
122
|
-
alice.destroy
|
123
|
-
alice.should be_frozen
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Vault, "defining properties" do
|
4
|
-
it "defines accessors for each property" do
|
5
|
-
person_klass = model do
|
6
|
-
property :name
|
7
|
-
property :age
|
8
|
-
end
|
9
|
-
|
10
|
-
person = person_klass.new
|
11
|
-
person.should respond_to(:name, :name=, :age, :age=)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "doesn't define duplicated properties" do
|
15
|
-
person_klass = model do
|
16
|
-
property :name
|
17
|
-
property :name
|
18
|
-
end
|
19
|
-
|
20
|
-
person_klass.should have(1).properties
|
21
|
-
end
|
22
|
-
|
23
|
-
it "doesn't support more than one key" do
|
24
|
-
person_klass = model do
|
25
|
-
key :name
|
26
|
-
key :age
|
27
|
-
end
|
28
|
-
|
29
|
-
person = person_klass.new(:name => "John", :age => 28)
|
30
|
-
person.save
|
31
|
-
person.to_key.should == [person.age]
|
32
|
-
end
|
33
|
-
|
34
|
-
it "can specify default values" do
|
35
|
-
person_klass = model do
|
36
|
-
property(:name) { "John" }
|
37
|
-
property(:age) { 28 }
|
38
|
-
end
|
39
|
-
|
40
|
-
person = person_klass.new
|
41
|
-
person.name.should == "John"
|
42
|
-
person.age.should == 28
|
43
|
-
end
|
44
|
-
|
45
|
-
it "doesn't flag an attribute as changed if you revert the change" do
|
46
|
-
person_klass = model do
|
47
|
-
property :name
|
48
|
-
end
|
49
|
-
|
50
|
-
person = person_klass.new(:name => "John")
|
51
|
-
person.name = "Joe"
|
52
|
-
person.name = "John"
|
53
|
-
person.should_not be_changed
|
54
|
-
end
|
55
|
-
|
56
|
-
it "provides 'dirty' attribute tracking" do
|
57
|
-
model.included_modules.should include(ActiveModel::Dirty)
|
58
|
-
end
|
59
|
-
end
|
data/spec/vault/scoping_spec.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Vault do
|
4
|
-
let :book_klass do
|
5
|
-
model do
|
6
|
-
scope :by_lewis_carroll do
|
7
|
-
{ "author" => "Lewis Carroll" }
|
8
|
-
end
|
9
|
-
|
10
|
-
scope :titled_alice do
|
11
|
-
{ "title" => "Alice in Wonderland" }
|
12
|
-
end
|
13
|
-
|
14
|
-
key :isbn
|
15
|
-
property :title
|
16
|
-
property :author
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
let :alice_in_wonderland do
|
21
|
-
book_klass.new(:isbn => "978-0517223628",
|
22
|
-
:title => "Alice in Wonderland",
|
23
|
-
:author => "Lewis Carroll")
|
24
|
-
end
|
25
|
-
|
26
|
-
let :through_the_looking_glass do
|
27
|
-
book_klass.new(:isbn => "978-0140367096",
|
28
|
-
:title => "Through the Looking Glass",
|
29
|
-
:author => "Lewis Carroll")
|
30
|
-
end
|
31
|
-
|
32
|
-
let :the_wonderful_wizard_of_oz do
|
33
|
-
book_klass.new(:isbn => "978-0451530295",
|
34
|
-
:title => "The Wonderful Wizard of Oz",
|
35
|
-
:author => "Lyman Frank Baum")
|
36
|
-
end
|
37
|
-
|
38
|
-
before do
|
39
|
-
alice_in_wonderland.save
|
40
|
-
through_the_looking_glass.save
|
41
|
-
the_wonderful_wizard_of_oz.save
|
42
|
-
end
|
43
|
-
|
44
|
-
it "filters the collection by the given scope" do
|
45
|
-
scoped = book_klass.by_lewis_carroll
|
46
|
-
scoped.all.should =~ [alice_in_wonderland, through_the_looking_glass]
|
47
|
-
end
|
48
|
-
|
49
|
-
it "lets you chain scopes" do
|
50
|
-
scoped = book_klass.by_lewis_carroll.titled_alice
|
51
|
-
scoped.all.should == [alice_in_wonderland]
|
52
|
-
end
|
53
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
require "tempfile"
|
3
|
-
|
4
|
-
describe Vault::Storage::YamlStore do
|
5
|
-
let :path do
|
6
|
-
begin
|
7
|
-
file = Tempfile.new("store.yml")
|
8
|
-
file.path
|
9
|
-
ensure
|
10
|
-
file.close
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
subject do
|
15
|
-
described_class.new(path)
|
16
|
-
end
|
17
|
-
|
18
|
-
before do
|
19
|
-
subject["key_a"] = { "attr_1" => "value_1", "attr_2" => "value_2" }
|
20
|
-
subject["key_b"] = { "attr_3" => "value_3" }
|
21
|
-
end
|
22
|
-
|
23
|
-
it_should_behave_like "A storage adapter"
|
24
|
-
|
25
|
-
it "serializes the file to disk on #flush" do
|
26
|
-
subject.flush
|
27
|
-
YAML.load_file(path).should include("key_a", "key_b")
|
28
|
-
end
|
29
|
-
end
|
data/spec/vault_spec.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Vault do
|
4
|
-
let :book_klass do
|
5
|
-
model do
|
6
|
-
key :isbn
|
7
|
-
property :title
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
it "can initialize a new model from a hash of attributes" do
|
12
|
-
book = book_klass.new(:title => "Some Book", :isbn => "1234567890")
|
13
|
-
book.title.should == "Some Book"
|
14
|
-
book.isbn.should == "1234567890"
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "#update" do
|
18
|
-
let :book do
|
19
|
-
book_klass.new(:title => "Some Book", :isbn => "1234567890")
|
20
|
-
end
|
21
|
-
|
22
|
-
it "effectively changes the attribute values" do
|
23
|
-
book.update(:title => "Awesome Book", :isbn => "0987654321")
|
24
|
-
book.title.should == "Awesome Book"
|
25
|
-
book.isbn.should == "0987654321"
|
26
|
-
end
|
27
|
-
|
28
|
-
it "flags attributes as changed when bulk-updating" do
|
29
|
-
book.update(:title => "Awesome Book")
|
30
|
-
book.changes.should include(:title)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|