ridley 0.0.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.
- data/.gitignore +17 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/Guardfile +20 -0
- data/LICENSE +201 -0
- data/README.md +273 -0
- data/Thorfile +48 -0
- data/lib/ridley.rb +48 -0
- data/lib/ridley/connection.rb +131 -0
- data/lib/ridley/context.rb +25 -0
- data/lib/ridley/dsl.rb +58 -0
- data/lib/ridley/errors.rb +82 -0
- data/lib/ridley/log.rb +10 -0
- data/lib/ridley/middleware.rb +19 -0
- data/lib/ridley/middleware/chef_auth.rb +45 -0
- data/lib/ridley/middleware/chef_response.rb +28 -0
- data/lib/ridley/middleware/parse_json.rb +107 -0
- data/lib/ridley/resource.rb +305 -0
- data/lib/ridley/resources/client.rb +75 -0
- data/lib/ridley/resources/cookbook.rb +27 -0
- data/lib/ridley/resources/data_bag.rb +75 -0
- data/lib/ridley/resources/data_bag_item.rb +186 -0
- data/lib/ridley/resources/environment.rb +45 -0
- data/lib/ridley/resources/node.rb +34 -0
- data/lib/ridley/resources/role.rb +33 -0
- data/lib/ridley/version.rb +3 -0
- data/ridley.gemspec +39 -0
- data/spec/acceptance/client_resource_spec.rb +135 -0
- data/spec/acceptance/cookbook_resource_spec.rb +46 -0
- data/spec/acceptance/data_bag_item_resource_spec.rb +171 -0
- data/spec/acceptance/data_bag_resource_spec.rb +51 -0
- data/spec/acceptance/environment_resource_spec.rb +171 -0
- data/spec/acceptance/node_resource_spec.rb +218 -0
- data/spec/acceptance/role_resource_spec.rb +200 -0
- data/spec/fixtures/reset.pem +27 -0
- data/spec/spec_helper.rb +25 -0
- data/spec/support/each_matcher.rb +12 -0
- data/spec/support/shared_examples/ridley_resource.rb +237 -0
- data/spec/support/spec_helpers.rb +11 -0
- data/spec/unit/ridley/connection_spec.rb +167 -0
- data/spec/unit/ridley/errors_spec.rb +34 -0
- data/spec/unit/ridley/middleware/chef_auth_spec.rb +14 -0
- data/spec/unit/ridley/middleware/chef_response_spec.rb +213 -0
- data/spec/unit/ridley/middleware/parse_json_spec.rb +74 -0
- data/spec/unit/ridley/resource_spec.rb +214 -0
- data/spec/unit/ridley/resources/client_spec.rb +47 -0
- data/spec/unit/ridley/resources/cookbook_spec.rb +5 -0
- data/spec/unit/ridley/resources/data_bag_item_spec.rb +42 -0
- data/spec/unit/ridley/resources/data_bag_spec.rb +15 -0
- data/spec/unit/ridley/resources/environment_spec.rb +73 -0
- data/spec/unit/ridley/resources/node_spec.rb +5 -0
- data/spec/unit/ridley/resources/role_spec.rb +5 -0
- data/spec/unit/ridley_spec.rb +32 -0
- metadata +451 -0
@@ -0,0 +1,218 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Node API operations", type: "acceptance" do
|
4
|
+
let(:server_url) { "https://api.opscode.com" }
|
5
|
+
let(:client_name) { "reset" }
|
6
|
+
let(:client_key) { "/Users/reset/.chef/reset.pem" }
|
7
|
+
let(:organization) { "ridley" }
|
8
|
+
|
9
|
+
let(:connection) do
|
10
|
+
Ridley.connection(
|
11
|
+
server_url: server_url,
|
12
|
+
client_name: client_name,
|
13
|
+
client_key: client_key,
|
14
|
+
organization: organization
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
before(:all) { WebMock.allow_net_connect! }
|
19
|
+
after(:all) { WebMock.disable_net_connect! }
|
20
|
+
|
21
|
+
before(:each) do
|
22
|
+
connection.node.delete_all
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "finding a node" do
|
26
|
+
let(:target) do
|
27
|
+
Ridley::Node.new(
|
28
|
+
connection,
|
29
|
+
name: "ridley-one"
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
before(:each) do
|
34
|
+
connection.node.create(target)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "returns a Ridley::Node object" do
|
38
|
+
connection.node.find(target.name).should eql(target)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "creating a node" do
|
43
|
+
let(:target) do
|
44
|
+
Ridley::Node.new(
|
45
|
+
connection,
|
46
|
+
name: "ridley-one"
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "returns a new Ridley::Node object" do
|
51
|
+
connection.node.create(target).should eql(target)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "adds a new node to the server" do
|
55
|
+
connection.sync do
|
56
|
+
node.create(target)
|
57
|
+
|
58
|
+
node.all.should have(1).node
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "deleting a node" do
|
64
|
+
let(:target) do
|
65
|
+
Ridley::Node.new(
|
66
|
+
connection,
|
67
|
+
name: "ridley-one"
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
before(:each) do
|
72
|
+
connection.node.create(target)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "returns the deleted object" do
|
76
|
+
connection.node.delete(target).should eql(target)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "removes the node from the server" do
|
80
|
+
connection.sync do
|
81
|
+
node.delete(target)
|
82
|
+
|
83
|
+
node.find(target).should be_nil
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "deleting all nodes" do
|
89
|
+
it "deletes all nodes from the remote server" do
|
90
|
+
connection.sync do
|
91
|
+
node.delete_all
|
92
|
+
|
93
|
+
connection.node.all.should have(0).nodes
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "listing all nodes" do
|
99
|
+
before(:each) do
|
100
|
+
connection.sync do
|
101
|
+
node.create(name: "ridley-one")
|
102
|
+
node.create(name: "ridley-two")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
it "returns an array of Ridley::Node objects" do
|
107
|
+
connection.sync do
|
108
|
+
obj = node.all
|
109
|
+
|
110
|
+
obj.should each be_a(Ridley::Node)
|
111
|
+
obj.should have(2).nodes
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "updating a node" do
|
117
|
+
let(:target) do
|
118
|
+
Ridley::Node.new(
|
119
|
+
connection,
|
120
|
+
name: "ridley-one"
|
121
|
+
)
|
122
|
+
end
|
123
|
+
|
124
|
+
before(:each) do
|
125
|
+
connection.node.create(target)
|
126
|
+
end
|
127
|
+
|
128
|
+
it "returns the updated node" do
|
129
|
+
connection.node.update(target).should eql(target)
|
130
|
+
end
|
131
|
+
|
132
|
+
it "saves a new set of 'normal' attributes" do
|
133
|
+
target.normal = normal = {
|
134
|
+
attribute_one: "value_one",
|
135
|
+
nested: {
|
136
|
+
other: "val"
|
137
|
+
}
|
138
|
+
}
|
139
|
+
|
140
|
+
connection.sync do
|
141
|
+
node.update(target)
|
142
|
+
obj = node.find(target)
|
143
|
+
|
144
|
+
obj.normal.should eql(normal)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
it "saves a new set of 'default' attributes" do
|
149
|
+
target.default = defaults = {
|
150
|
+
attribute_one: "val_one",
|
151
|
+
nested: {
|
152
|
+
other: "val"
|
153
|
+
}
|
154
|
+
}
|
155
|
+
|
156
|
+
connection.sync do
|
157
|
+
node.update(target)
|
158
|
+
obj = node.find(target)
|
159
|
+
|
160
|
+
obj.default.should eql(defaults)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
it "saves a new set of 'automatic' attributes" do
|
165
|
+
target.automatic = automatics = {
|
166
|
+
attribute_one: "val_one",
|
167
|
+
nested: {
|
168
|
+
other: "val"
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
connection.sync do
|
173
|
+
node.update(target)
|
174
|
+
obj = node.find(target)
|
175
|
+
|
176
|
+
obj.automatic.should eql(automatics)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
it "saves a new set of 'override' attributes" do
|
181
|
+
target.override = overrides = {
|
182
|
+
attribute_one: "val_one",
|
183
|
+
nested: {
|
184
|
+
other: "val"
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
connection.sync do
|
189
|
+
node.update(target)
|
190
|
+
obj = node.find(target)
|
191
|
+
|
192
|
+
obj.override.should eql(overrides)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
it "places a node in a new 'chef_environment'" do
|
197
|
+
target.chef_environment = environment = "ridley"
|
198
|
+
|
199
|
+
connection.sync do
|
200
|
+
node.update(target)
|
201
|
+
obj = node.find(target)
|
202
|
+
|
203
|
+
obj.chef_environment.should eql(environment)
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
it "saves a new 'run_list' for the node" do
|
208
|
+
target.run_list = run_list = ["recipe[one]", "recipe[two]"]
|
209
|
+
|
210
|
+
connection.sync do
|
211
|
+
node.update(target)
|
212
|
+
obj = node.find(target)
|
213
|
+
|
214
|
+
obj.run_list.should eql(run_list)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
@@ -0,0 +1,200 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Role API operations", type: "acceptance" do
|
4
|
+
let(:server_url) { "https://api.opscode.com" }
|
5
|
+
let(:client_name) { "reset" }
|
6
|
+
let(:client_key) { "/Users/reset/.chef/reset.pem" }
|
7
|
+
let(:organization) { "ridley" }
|
8
|
+
|
9
|
+
let(:connection) do
|
10
|
+
Ridley.connection(
|
11
|
+
server_url: server_url,
|
12
|
+
client_name: client_name,
|
13
|
+
client_key: client_key,
|
14
|
+
organization: organization
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
before(:all) { WebMock.allow_net_connect! }
|
19
|
+
after(:all) { WebMock.disable_net_connect! }
|
20
|
+
|
21
|
+
before(:each) { connection.role.delete_all }
|
22
|
+
|
23
|
+
describe "finding a role" do
|
24
|
+
let(:target) do
|
25
|
+
Ridley::Role.new(
|
26
|
+
connection,
|
27
|
+
name: "ridley-test",
|
28
|
+
description: "a testing role for ridley"
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
before(:each) do
|
33
|
+
connection.role.create(target)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "returns the target Ridley::Role from the server" do
|
37
|
+
connection.role.find(target.name).should eql(target)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "creating a role" do
|
42
|
+
let(:target) do
|
43
|
+
Ridley::Role.new(
|
44
|
+
connection,
|
45
|
+
name: "ridley-test",
|
46
|
+
description: "a testing role for ridley"
|
47
|
+
)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "returns a new Ridley::Role" do
|
51
|
+
connection.role.create(target).should eql(target)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "adds a new role to the server" do
|
55
|
+
connection.sync do
|
56
|
+
role.create(target)
|
57
|
+
|
58
|
+
role.all.should have(1).role
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "deleting a role" do
|
64
|
+
let(:target) do
|
65
|
+
Ridley::Role.new(
|
66
|
+
connection,
|
67
|
+
name: "ridley-role-one"
|
68
|
+
)
|
69
|
+
end
|
70
|
+
|
71
|
+
before(:each) do
|
72
|
+
connection.role.create(target)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "returns the deleted Ridley::Role resource" do
|
76
|
+
connection.role.delete(target).should eql(target)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "removes the role from the server" do
|
80
|
+
connection.sync do
|
81
|
+
role.delete(target)
|
82
|
+
|
83
|
+
role.find(target).should be_nil
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "deleting all roles" do
|
89
|
+
it "deletes all nodes from the remote server" do
|
90
|
+
connection.sync do
|
91
|
+
role.delete_all
|
92
|
+
|
93
|
+
role.all.should have(0).roles
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe "listing all roles" do
|
99
|
+
before(:each) do
|
100
|
+
connection.sync do
|
101
|
+
role.create(name: "jamie")
|
102
|
+
role.create(name: "winsor")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
it "should return an array of Ridley::Role objects" do
|
107
|
+
connection.sync do
|
108
|
+
obj = role.all
|
109
|
+
|
110
|
+
obj.should have(2).roles
|
111
|
+
obj.should each be_a(Ridley::Role)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe "updating a role" do
|
117
|
+
let(:target) do
|
118
|
+
Ridley::Role.new(
|
119
|
+
connection,
|
120
|
+
name: "ridley-role-one"
|
121
|
+
)
|
122
|
+
end
|
123
|
+
|
124
|
+
before(:each) do
|
125
|
+
connection.role.create(target)
|
126
|
+
end
|
127
|
+
|
128
|
+
it "returns an updated Ridley::Role object" do
|
129
|
+
connection.role.update(target).should eql(target)
|
130
|
+
end
|
131
|
+
|
132
|
+
it "saves a new run_list" do
|
133
|
+
target.run_list = run_list = ["recipe[one]", "recipe[two]"]
|
134
|
+
|
135
|
+
connection.sync do
|
136
|
+
role.update(target)
|
137
|
+
obj = role.find(target)
|
138
|
+
|
139
|
+
obj.run_list.should eql(run_list)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
it "saves a new env_run_lists" do
|
144
|
+
target.env_run_lists = env_run_lists = {
|
145
|
+
production: ["recipe[one]"],
|
146
|
+
development: ["recipe[two]"]
|
147
|
+
}
|
148
|
+
|
149
|
+
connection.sync do
|
150
|
+
role.update(target)
|
151
|
+
obj = role.find(target)
|
152
|
+
|
153
|
+
obj.env_run_lists.should eql(env_run_lists)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
it "saves a new description" do
|
158
|
+
target.description = description = "a new description!"
|
159
|
+
|
160
|
+
connection.sync do
|
161
|
+
role.update(target)
|
162
|
+
obj = role.find(target)
|
163
|
+
|
164
|
+
obj.description.should eql(description)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
it "saves a new default_attributes" do
|
169
|
+
target.default_attributes = defaults = {
|
170
|
+
attribute_one: "value_one",
|
171
|
+
nested: {
|
172
|
+
other: false
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
176
|
+
connection.sync do
|
177
|
+
role.update(target)
|
178
|
+
obj = role.find(target)
|
179
|
+
|
180
|
+
obj.default_attributes.should eql(defaults)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
it "saves a new override_attributes" do
|
185
|
+
target.override_attributes = overrides = {
|
186
|
+
attribute_two: "value_two",
|
187
|
+
nested: {
|
188
|
+
other: false
|
189
|
+
}
|
190
|
+
}
|
191
|
+
|
192
|
+
connection.sync do
|
193
|
+
role.update(target)
|
194
|
+
obj = role.find(target)
|
195
|
+
|
196
|
+
obj.override_attributes.should eql(overrides)
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
-----BEGIN RSA PRIVATE KEY-----
|
2
|
+
MIIEpQIBAAKCAQEAyyUMqrTh1IzKOyE0fvXEWC7m0AdMI8/dr9JJMUKtK9vhhP0w
|
3
|
+
rm6m95GoybFM2IRryukFsAxpcir3M1ungTU3Smq4MshhMJ7H9FbvZVfQoknTbCsR
|
4
|
+
w6scg2fBepxT2+fcGRufr8nAh92M3uUkN9bMMTAkt18D4br6035YvdmvHDJERxYq
|
5
|
+
ByA/720AdI9VNSIvw+x8oqsIkXLEdF6dgT9MpG5iWZT66pbFsnNZpRrd4/bFNWBY
|
6
|
+
+13aOqdmjiTL08/EdgQFKMT5qimpos1TuQhA7mwInOjQgzVu9uCDkMiYejaLbUz0
|
7
|
+
lGyS8y4uxu6z2hA900Jg/z+JJuXymH5QAX3GZQIDAQABAoIBAQCtFXkwbYPI1Nht
|
8
|
+
/wG6du5+8B9K+hy+mppY9wPTy+q+Zs9Ev3Fd/fuXDm1QxBckl9c8AMUO1dR2KPOM
|
9
|
+
t7gFl/DvH/SnmCFvCqp1nijFIUgrLlnMXPn6zG0z7RBlxpKQ2IGohufNIEpBuNwR
|
10
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6xufaTYzMC3d
|
25
|
+
AZG9XPPjRqSLs+ylSXJpwHEwoeyLFDaJcO+GgW1/ut4MC2HppOx6aImwDdXMHUWR
|
26
|
+
KYGIFF4AU/IYoBcanAm4s078EH/Oz01B2c7tR2TqabisPgLYe7PXSCw=
|
27
|
+
-----END RSA PRIVATE KEY-----
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
require 'spork'
|
4
|
+
|
5
|
+
Spork.prefork do
|
6
|
+
require 'rspec'
|
7
|
+
require 'json_spec'
|
8
|
+
require 'webmock/rspec'
|
9
|
+
|
10
|
+
Dir[File.join(File.expand_path("../../spec/support/**/*.rb", __FILE__))].each { |f| require f }
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.include Ridley::SpecHelpers
|
14
|
+
config.include JsonSpec::Helpers
|
15
|
+
|
16
|
+
config.mock_with :rspec
|
17
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
18
|
+
config.filter_run focus: true
|
19
|
+
config.run_all_when_everything_filtered = true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
Spork.each_run do
|
24
|
+
require 'ridley'
|
25
|
+
end
|