ridley 0.11.0.rc1 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -2
- data/Gemfile +1 -0
- data/Guardfile +2 -2
- data/Thorfile +2 -2
- data/lib/ridley/chef.rb +1 -0
- data/lib/ridley/chef/chefignore.rb +76 -0
- data/lib/ridley/chef/cookbook.rb +17 -7
- data/lib/ridley/chef/cookbook/metadata.rb +8 -0
- data/lib/ridley/chef_objects/cookbook_object.rb +21 -37
- data/lib/ridley/chef_objects/data_bag_item_obect.rb +9 -0
- data/lib/ridley/client.rb +2 -2
- data/lib/ridley/connection.rb +12 -6
- data/lib/ridley/errors.rb +14 -0
- data/lib/ridley/host_connector.rb +10 -3
- data/lib/ridley/resource.rb +25 -5
- data/lib/ridley/resources/cookbook_resource.rb +19 -9
- data/lib/ridley/resources/data_bag_item_resource.rb +8 -4
- data/lib/ridley/resources/search_resource.rb +5 -5
- data/lib/ridley/sandbox_uploader.rb +6 -0
- data/lib/ridley/version.rb +1 -1
- data/ridley.gemspec +1 -1
- data/spec/acceptance/client_resource_spec.rb +44 -62
- data/spec/acceptance/cookbook_resource_spec.rb +27 -0
- data/spec/acceptance/data_bag_item_resource_spec.rb +36 -54
- data/spec/acceptance/data_bag_resource_spec.rb +9 -21
- data/spec/acceptance/environment_resource_spec.rb +34 -63
- data/spec/acceptance/node_resource_spec.rb +27 -47
- data/spec/acceptance/role_resource_spec.rb +27 -67
- data/spec/acceptance/sandbox_resource_spec.rb +3 -13
- data/spec/acceptance/search_resource_spec.rb +5 -15
- data/spec/fixtures/chefignore +8 -0
- data/spec/spec_helper.rb +15 -1
- data/spec/support/chef_server.rb +77 -0
- data/spec/unit/ridley/chef/chefignore_spec.rb +40 -0
- data/spec/unit/ridley/chef/cookbook_spec.rb +30 -2
- data/spec/unit/ridley/chef_objects/cookbook_object_spec.rb +3 -3
- data/spec/unit/ridley/connection_spec.rb +1 -2
- data/spec/unit/ridley/resources/cookbook_resource_spec.rb +85 -48
- data/spec/unit/ridley/resources/data_bag_resource_spec.rb +1 -1
- data/spec/unit/ridley/resources/search_resource_spec.rb +39 -2
- data/spec/unit/ridley/sandbox_uploader_spec.rb +25 -0
- metadata +19 -7
@@ -1,24 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "DataBag API operations", type: "acceptance" do
|
4
|
-
let(:server_url)
|
4
|
+
let(:server_url) { Ridley::RSpec::ChefServer.server_url }
|
5
5
|
let(:client_name) { "reset" }
|
6
|
-
let(:client_key)
|
7
|
-
|
8
|
-
let(:connection) do
|
9
|
-
Ridley.new(
|
10
|
-
server_url: server_url,
|
11
|
-
client_name: client_name,
|
12
|
-
client_key: client_key
|
13
|
-
)
|
14
|
-
end
|
15
|
-
|
16
|
-
before(:all) { WebMock.allow_net_connect! }
|
17
|
-
after(:all) { WebMock.disable_net_connect! }
|
18
|
-
|
19
|
-
before(:each) do
|
20
|
-
connection.data_bag.delete_all
|
21
|
-
end
|
6
|
+
let(:client_key) { fixtures_path.join('reset.pem').to_s }
|
7
|
+
let(:connection) { Ridley.new(server_url: server_url, client_name: client_name, client_key: client_key) }
|
22
8
|
|
23
9
|
describe "listing data bags" do
|
24
10
|
context "when no data bags exist" do
|
@@ -28,9 +14,9 @@ describe "DataBag API operations", type: "acceptance" do
|
|
28
14
|
end
|
29
15
|
|
30
16
|
context "when the server has data bags" do
|
31
|
-
before
|
32
|
-
|
33
|
-
|
17
|
+
before do
|
18
|
+
chef_data_bag("ridley-one")
|
19
|
+
chef_data_bag("ridley-two")
|
34
20
|
end
|
35
21
|
|
36
22
|
it "returns an array of data bags" do
|
@@ -44,6 +30,8 @@ describe "DataBag API operations", type: "acceptance" do
|
|
44
30
|
end
|
45
31
|
|
46
32
|
describe "creating a data bag" do
|
47
|
-
|
33
|
+
it "returns a Ridley::DataBagObject" do
|
34
|
+
connection.data_bag.create(name: "ridley-one").should be_a(Ridley::DataBagObject)
|
35
|
+
end
|
48
36
|
end
|
49
37
|
end
|
@@ -1,63 +1,46 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "Environment API operations", type: "acceptance" do
|
4
|
-
let(:server_url)
|
4
|
+
let(:server_url) { Ridley::RSpec::ChefServer.server_url }
|
5
5
|
let(:client_name) { "reset" }
|
6
|
-
let(:client_key)
|
7
|
-
let(:
|
8
|
-
|
9
|
-
let(:connection) do
|
10
|
-
Ridley.new(
|
11
|
-
server_url: server_url,
|
12
|
-
client_name: client_name,
|
13
|
-
client_key: client_key
|
14
|
-
)
|
15
|
-
end
|
16
|
-
|
17
|
-
before(:all) { WebMock.allow_net_connect! }
|
18
|
-
after(:all) { WebMock.disable_net_connect! }
|
19
|
-
|
20
|
-
before(:each) do
|
21
|
-
connection.environment.delete_all
|
22
|
-
end
|
6
|
+
let(:client_key) { fixtures_path.join('reset.pem').to_s }
|
7
|
+
let(:connection) { Ridley.new(server_url: server_url, client_name: client_name, client_key: client_key) }
|
23
8
|
|
24
9
|
describe "finding an environment" do
|
25
|
-
|
10
|
+
before { chef_environment("ridley-test-env") }
|
26
11
|
|
27
|
-
|
28
|
-
connection.environment.
|
12
|
+
it "returns a valid Ridley::EnvironmentObject object" do
|
13
|
+
connection.environment.find("ridley-test-env").should be_a(Ridley::EnvironmentObject)
|
29
14
|
end
|
15
|
+
end
|
30
16
|
|
17
|
+
describe "creating an environment" do
|
31
18
|
it "returns a valid Ridley::EnvironmentObject object" do
|
32
|
-
connection.
|
33
|
-
obj = environment.find(target)
|
19
|
+
obj = connection.environment.create(name: "ridley-test-env", description: "a testing env for ridley")
|
34
20
|
|
35
|
-
|
36
|
-
|
37
|
-
|
21
|
+
obj.should be_a(Ridley::EnvironmentObject)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "adds an environment to the chef server" do
|
25
|
+
old = connection.environment.all.length
|
26
|
+
connection.environment.create(name: "ridley")
|
27
|
+
connection.environment.all.should have(old + 1).item
|
38
28
|
end
|
39
29
|
end
|
40
30
|
|
41
|
-
describe "
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
description: "a testing environment for ridley"
|
47
|
-
)
|
31
|
+
describe "deleting an environment" do
|
32
|
+
before { chef_environment("ridley-env") }
|
33
|
+
|
34
|
+
it "returns a Ridley::EnvironmentObject object" do
|
35
|
+
connection.environment.delete("ridley-env").should be_a(Ridley::EnvironmentObject)
|
48
36
|
end
|
49
37
|
|
50
|
-
it "
|
51
|
-
connection.
|
52
|
-
obj = environment.create(target)
|
38
|
+
it "removes the environment from the server" do
|
39
|
+
connection.environment.delete("ridley-env")
|
53
40
|
|
54
|
-
|
55
|
-
obj.should be_valid
|
56
|
-
end
|
41
|
+
connection.environment.find("ridley-env").should be_nil
|
57
42
|
end
|
58
|
-
end
|
59
43
|
|
60
|
-
describe "deleting an environment" do
|
61
44
|
it "raises Ridley::Errors::HTTPMethodNotAllowed when attempting to delete the '_default' environment" do
|
62
45
|
lambda {
|
63
46
|
connection.environment.delete("_default")
|
@@ -66,11 +49,9 @@ describe "Environment API operations", type: "acceptance" do
|
|
66
49
|
end
|
67
50
|
|
68
51
|
describe "deleting all environments" do
|
69
|
-
before
|
70
|
-
|
71
|
-
|
72
|
-
environment.create(name: "ridley-two")
|
73
|
-
end
|
52
|
+
before do
|
53
|
+
chef_environment("ridley-one")
|
54
|
+
chef_environment("ridley-two")
|
74
55
|
end
|
75
56
|
|
76
57
|
it "returns an array of Ridley::EnvironmentObject objects" do
|
@@ -78,12 +59,9 @@ describe "Environment API operations", type: "acceptance" do
|
|
78
59
|
end
|
79
60
|
|
80
61
|
it "deletes all environments but '_default' from the remote" do
|
81
|
-
connection.
|
82
|
-
environment.delete_all
|
62
|
+
connection.environment.delete_all
|
83
63
|
|
84
|
-
|
85
|
-
environment.find("_default").should_not be_nil
|
86
|
-
end
|
64
|
+
connection.environment.all.should have(1).item
|
87
65
|
end
|
88
66
|
end
|
89
67
|
|
@@ -94,21 +72,14 @@ describe "Environment API operations", type: "acceptance" do
|
|
94
72
|
end
|
95
73
|
|
96
74
|
describe "updating an environment" do
|
97
|
-
|
75
|
+
before { chef_environment("ridley-env") }
|
76
|
+
let(:target ) { connection.environment.find("ridley-env") }
|
98
77
|
|
99
|
-
|
100
|
-
connection.environment.create(target)
|
101
|
-
end
|
102
|
-
|
103
|
-
it "saves a new 'description'" do
|
78
|
+
it "saves a new #description" do
|
104
79
|
target.description = description = "ridley testing environment"
|
105
80
|
|
106
|
-
connection.
|
107
|
-
|
108
|
-
obj = environment.find(target)
|
109
|
-
|
110
|
-
obj.description.should eql(description)
|
111
|
-
end
|
81
|
+
connection.environment.update(target)
|
82
|
+
target.reload.description.should eql(description)
|
112
83
|
end
|
113
84
|
|
114
85
|
it "saves a new set of 'default_attributes'" do
|
@@ -1,48 +1,30 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "Node API operations", type: "acceptance" do
|
4
|
-
let(:server_url)
|
4
|
+
let(:server_url) { Ridley::RSpec::ChefServer.server_url }
|
5
5
|
let(:client_name) { "reset" }
|
6
|
-
let(:client_key)
|
7
|
-
let(:
|
8
|
-
|
9
|
-
let(:connection) do
|
10
|
-
Ridley.new(
|
11
|
-
server_url: server_url,
|
12
|
-
client_name: client_name,
|
13
|
-
client_key: client_key
|
14
|
-
)
|
15
|
-
end
|
16
|
-
|
17
|
-
before(:all) { WebMock.allow_net_connect! }
|
18
|
-
after(:all) { WebMock.disable_net_connect! }
|
19
|
-
|
20
|
-
before(:each) do
|
21
|
-
connection.node.delete_all
|
22
|
-
end
|
6
|
+
let(:client_key) { fixtures_path.join('reset.pem').to_s }
|
7
|
+
let(:connection) { Ridley.new(server_url: server_url, client_name: client_name, client_key: client_key) }
|
23
8
|
|
24
9
|
describe "finding a node" do
|
25
|
-
let(:
|
10
|
+
let(:node_name) { "ridley.localhost" }
|
11
|
+
before { chef_node(node_name) }
|
26
12
|
|
27
|
-
|
28
|
-
connection.node.
|
29
|
-
end
|
30
|
-
|
31
|
-
it "returns a Ridley::NodeResource object" do
|
32
|
-
connection.node.find(target.name).should eql(target)
|
13
|
+
it "returns a Ridley::NodeObject" do
|
14
|
+
connection.node.find(node_name).should be_a(Ridley::NodeObject)
|
33
15
|
end
|
34
16
|
end
|
35
17
|
|
36
18
|
describe "creating a node" do
|
37
|
-
let(:
|
19
|
+
let(:node_name) { "ridley.localhost" }
|
38
20
|
|
39
21
|
it "returns a new Ridley::NodeObject object" do
|
40
|
-
connection.node.create(
|
22
|
+
connection.node.create(name: node_name).should be_a(Ridley::NodeObject)
|
41
23
|
end
|
42
24
|
|
43
25
|
it "adds a new node to the server" do
|
44
26
|
connection.sync do
|
45
|
-
node.create(
|
27
|
+
node.create(name: node_name)
|
46
28
|
|
47
29
|
node.all.should have(1).node
|
48
30
|
end
|
@@ -50,26 +32,28 @@ describe "Node API operations", type: "acceptance" do
|
|
50
32
|
end
|
51
33
|
|
52
34
|
describe "deleting a node" do
|
53
|
-
let(:
|
54
|
-
|
55
|
-
before(:each) do
|
56
|
-
connection.node.create(target)
|
57
|
-
end
|
35
|
+
let(:node_name) { "ridley.localhost" }
|
36
|
+
before { chef_node(node_name) }
|
58
37
|
|
59
|
-
it "returns
|
60
|
-
connection.node.delete(
|
38
|
+
it "returns a Ridley::NodeObject" do
|
39
|
+
connection.node.delete(node_name).should be_a(Ridley::NodeObject)
|
61
40
|
end
|
62
41
|
|
63
42
|
it "removes the node from the server" do
|
64
43
|
connection.sync do
|
65
|
-
node.delete(
|
44
|
+
node.delete(node_name)
|
66
45
|
|
67
|
-
node.find(
|
46
|
+
node.find(node_name).should be_nil
|
68
47
|
end
|
69
48
|
end
|
70
49
|
end
|
71
50
|
|
72
51
|
describe "deleting all nodes" do
|
52
|
+
before do
|
53
|
+
chef_node("ridley.localhost")
|
54
|
+
chef_node("motherbrain.localhost")
|
55
|
+
end
|
56
|
+
|
73
57
|
it "deletes all nodes from the remote server" do
|
74
58
|
connection.sync do
|
75
59
|
node.delete_all
|
@@ -80,11 +64,9 @@ describe "Node API operations", type: "acceptance" do
|
|
80
64
|
end
|
81
65
|
|
82
66
|
describe "listing all nodes" do
|
83
|
-
before
|
84
|
-
|
85
|
-
|
86
|
-
node.create(name: "ridley-two")
|
87
|
-
end
|
67
|
+
before do
|
68
|
+
chef_node("ridley.localhost")
|
69
|
+
chef_node("motherbrain.localhost")
|
88
70
|
end
|
89
71
|
|
90
72
|
it "returns an array of Ridley::NodeObject" do
|
@@ -98,11 +80,9 @@ describe "Node API operations", type: "acceptance" do
|
|
98
80
|
end
|
99
81
|
|
100
82
|
describe "updating a node" do
|
101
|
-
let(:
|
102
|
-
|
103
|
-
|
104
|
-
connection.node.create(target)
|
105
|
-
end
|
83
|
+
let(:node_name) { "ridley.localhost" }
|
84
|
+
before { chef_node(node_name) }
|
85
|
+
let(:target) { connection.node.find(node_name) }
|
106
86
|
|
107
87
|
it "returns the updated node" do
|
108
88
|
connection.node.update(target).should eql(target)
|
@@ -1,58 +1,30 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe "Role API operations", type: "acceptance" do
|
4
|
-
let(:server_url)
|
4
|
+
let(:server_url) { Ridley::RSpec::ChefServer.server_url }
|
5
5
|
let(:client_name) { "reset" }
|
6
|
-
let(:client_key)
|
7
|
-
let(:
|
8
|
-
|
9
|
-
let(:connection) do
|
10
|
-
Ridley.new(
|
11
|
-
server_url: server_url,
|
12
|
-
client_name: client_name,
|
13
|
-
client_key: client_key
|
14
|
-
)
|
15
|
-
end
|
16
|
-
|
17
|
-
before(:all) { WebMock.allow_net_connect! }
|
18
|
-
after(:all) { WebMock.disable_net_connect! }
|
19
|
-
|
20
|
-
before(:each) { connection.role.delete_all }
|
6
|
+
let(:client_key) { fixtures_path.join('reset.pem').to_s }
|
7
|
+
let(:connection) { Ridley.new(server_url: server_url, client_name: client_name, client_key: client_key) }
|
21
8
|
|
22
9
|
describe "finding a role" do
|
23
|
-
let(:
|
24
|
-
|
25
|
-
resource,
|
26
|
-
name: "ridley-test",
|
27
|
-
description: "a testing role for ridley"
|
28
|
-
)
|
29
|
-
end
|
10
|
+
let(:role_name) { "ridley-role" }
|
11
|
+
before { chef_role(role_name) }
|
30
12
|
|
31
|
-
|
32
|
-
connection.role.
|
33
|
-
end
|
34
|
-
|
35
|
-
it "returns the target Ridley::RoleObject from the server" do
|
36
|
-
connection.role.find(target.name).should eql(target)
|
13
|
+
it "returns a Ridley::RoleObject" do
|
14
|
+
connection.role.find(role_name).should be_a(Ridley::RoleObject)
|
37
15
|
end
|
38
16
|
end
|
39
17
|
|
40
18
|
describe "creating a role" do
|
41
|
-
let(:
|
42
|
-
Ridley::RoleObject.new(
|
43
|
-
resource,
|
44
|
-
name: "ridley-test",
|
45
|
-
description: "a testing role for ridley"
|
46
|
-
)
|
47
|
-
end
|
19
|
+
let(:role_name) { "ridley-role" }
|
48
20
|
|
49
21
|
it "returns a new Ridley::RoleObject" do
|
50
|
-
connection.role.create(
|
22
|
+
connection.role.create(name: role_name).should be_a(Ridley::RoleObject)
|
51
23
|
end
|
52
24
|
|
53
25
|
it "adds a new role to the server" do
|
54
26
|
connection.sync do
|
55
|
-
role.create(
|
27
|
+
role.create(name: role_name)
|
56
28
|
|
57
29
|
role.all.should have(1).role
|
58
30
|
end
|
@@ -60,31 +32,28 @@ describe "Role API operations", type: "acceptance" do
|
|
60
32
|
end
|
61
33
|
|
62
34
|
describe "deleting a role" do
|
63
|
-
let(:
|
64
|
-
|
65
|
-
resource,
|
66
|
-
name: "ridley-role-one"
|
67
|
-
)
|
68
|
-
end
|
69
|
-
|
70
|
-
before(:each) do
|
71
|
-
connection.role.create(target)
|
72
|
-
end
|
35
|
+
let(:role_name) { "ridley-role" }
|
36
|
+
before { chef_role(role_name) }
|
73
37
|
|
74
38
|
it "returns the deleted Ridley::RoleObject resource" do
|
75
|
-
connection.role.delete(
|
39
|
+
connection.role.delete(role_name).should be_a(Ridley::RoleObject)
|
76
40
|
end
|
77
41
|
|
78
42
|
it "removes the role from the server" do
|
79
43
|
connection.sync do
|
80
|
-
role.delete(
|
44
|
+
role.delete(role_name)
|
81
45
|
|
82
|
-
role.find(
|
46
|
+
role.find(role_name).should be_nil
|
83
47
|
end
|
84
48
|
end
|
85
49
|
end
|
86
50
|
|
87
51
|
describe "deleting all roles" do
|
52
|
+
before do
|
53
|
+
chef_role("role_one")
|
54
|
+
chef_role("role_two")
|
55
|
+
end
|
56
|
+
|
88
57
|
it "deletes all nodes from the remote server" do
|
89
58
|
connection.sync do
|
90
59
|
role.delete_all
|
@@ -95,14 +64,12 @@ describe "Role API operations", type: "acceptance" do
|
|
95
64
|
end
|
96
65
|
|
97
66
|
describe "listing all roles" do
|
98
|
-
before
|
99
|
-
|
100
|
-
|
101
|
-
role.create(name: "winsor")
|
102
|
-
end
|
67
|
+
before do
|
68
|
+
chef_role("role_one")
|
69
|
+
chef_role("role_two")
|
103
70
|
end
|
104
71
|
|
105
|
-
it "should return an array of Ridley::
|
72
|
+
it "should return an array of Ridley::RoleObject" do
|
106
73
|
connection.sync do
|
107
74
|
obj = role.all
|
108
75
|
|
@@ -113,16 +80,9 @@ describe "Role API operations", type: "acceptance" do
|
|
113
80
|
end
|
114
81
|
|
115
82
|
describe "updating a role" do
|
116
|
-
let(:
|
117
|
-
|
118
|
-
|
119
|
-
name: "ridley-role-one"
|
120
|
-
)
|
121
|
-
end
|
122
|
-
|
123
|
-
before(:each) do
|
124
|
-
connection.role.create(target)
|
125
|
-
end
|
83
|
+
let(:role_name) { "ridley-role" }
|
84
|
+
before { chef_role(role_name) }
|
85
|
+
let(:target) { connection.role.find(role_name) }
|
126
86
|
|
127
87
|
it "returns an updated Ridley::RoleObject object" do
|
128
88
|
connection.role.update(target).should eql(target)
|