profitbricks-sdk-ruby 3.0.2 → 4.0.0
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 +4 -4
- data/README.md +2124 -44
- data/lib/profitbricks.rb +6 -0
- data/lib/profitbricks/contract.rb +29 -0
- data/lib/profitbricks/datacenter.rb +43 -1
- data/lib/profitbricks/errors.rb +1 -0
- data/lib/profitbricks/group.rb +76 -0
- data/lib/profitbricks/image.rb +7 -7
- data/lib/profitbricks/lan.rb +18 -11
- data/lib/profitbricks/model.rb +6 -0
- data/lib/profitbricks/profitbricks.rb +14 -7
- data/lib/profitbricks/resource.rb +42 -0
- data/lib/profitbricks/share.rb +66 -0
- data/lib/profitbricks/user.rb +92 -0
- data/lib/profitbricks/usermanagement.rb +61 -0
- data/lib/profitbricks/version.rb +1 -1
- data/spec/contract_spec.rb +24 -0
- data/spec/datacenter_spec.rb +54 -29
- data/spec/firewall_spec.rb +13 -5
- data/spec/group_spec.rb +65 -0
- data/spec/image_spec.rb +23 -0
- data/spec/ipblock_spec.rb +16 -6
- data/spec/lan_spec.rb +54 -11
- data/spec/loadbalancer_spec.rb +22 -10
- data/spec/location_spec.rb +6 -0
- data/spec/nic_spec.rb +17 -5
- data/spec/request_spec.rb +5 -0
- data/spec/resource_spec.rb +102 -0
- data/spec/server_spec.rb +71 -51
- data/spec/share_spec.rb +66 -0
- data/spec/snapshot_spec.rb +27 -4
- data/spec/spec_helper.rb +1 -1
- data/spec/support/resource_helper.rb +220 -83
- data/spec/user_spec.rb +96 -0
- data/spec/usermanagement_spec.rb +113 -0
- data/spec/volume_spec.rb +40 -11
- metadata +34 -16
@@ -0,0 +1,92 @@
|
|
1
|
+
module ProfitBricks
|
2
|
+
# User class
|
3
|
+
class User < ProfitBricks::Model
|
4
|
+
# Delete the user.
|
5
|
+
def delete
|
6
|
+
response = ProfitBricks.request(
|
7
|
+
method: :delete,
|
8
|
+
path: "/um/users/#{id}",
|
9
|
+
expects: 202
|
10
|
+
)
|
11
|
+
self.requestId = response[:requestId]
|
12
|
+
self
|
13
|
+
end
|
14
|
+
|
15
|
+
# Update the user.
|
16
|
+
def update(options = {})
|
17
|
+
response = ProfitBricks.request(
|
18
|
+
method: :put,
|
19
|
+
path: "/um/users/#{id}",
|
20
|
+
expects: 202,
|
21
|
+
body: { properties: options }.to_json
|
22
|
+
)
|
23
|
+
if response
|
24
|
+
self.requestId = response['requestId']
|
25
|
+
@properties = @properties.merge(response['properties'])
|
26
|
+
end
|
27
|
+
self
|
28
|
+
end
|
29
|
+
|
30
|
+
class << self
|
31
|
+
# Create a new user.
|
32
|
+
def create(options = {})
|
33
|
+
response = ProfitBricks.request(
|
34
|
+
method: :post,
|
35
|
+
path: "/um/users",
|
36
|
+
expects: 202,
|
37
|
+
body: { properties: options }.to_json
|
38
|
+
)
|
39
|
+
add_parent_identities(response)
|
40
|
+
instantiate_objects(response)
|
41
|
+
end
|
42
|
+
|
43
|
+
# List all users.
|
44
|
+
def list(options = {})
|
45
|
+
path = "/um/users"
|
46
|
+
path = "/um/groups/#{options[:group_id]}/users" if options[:group_id]
|
47
|
+
response = ProfitBricks.request(
|
48
|
+
method: :get,
|
49
|
+
path: path,
|
50
|
+
expects: 200,
|
51
|
+
query: options
|
52
|
+
)
|
53
|
+
add_parent_identities(response)
|
54
|
+
instantiate_objects(response)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Retrieve an user.
|
58
|
+
def get(user_id,options = {})
|
59
|
+
response = ProfitBricks.request(
|
60
|
+
method: :get,
|
61
|
+
path: "/um/users/#{user_id}",
|
62
|
+
expects: 200,
|
63
|
+
query: options
|
64
|
+
)
|
65
|
+
add_parent_identities(response)
|
66
|
+
instantiate_objects(response)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Add an user to a group
|
70
|
+
def add_to_group(group_id, user_id)
|
71
|
+
response = ProfitBricks.request(
|
72
|
+
method: :post,
|
73
|
+
path: "/um/groups/#{group_id}/users",
|
74
|
+
expects: 202,
|
75
|
+
body: {id: user_id}.to_json
|
76
|
+
)
|
77
|
+
add_parent_identities(response)
|
78
|
+
instantiate_objects(response)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Remove an user from a group
|
82
|
+
def remove_from_group(group_id, user_id)
|
83
|
+
response = ProfitBricks.request(
|
84
|
+
method: :delete,
|
85
|
+
path: "/um/groups/#{group_id}/users/#{user_id}",
|
86
|
+
expects: 202
|
87
|
+
)
|
88
|
+
return true
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module ProfitBricks
|
2
|
+
# UserManagement class
|
3
|
+
class UserManagement < ProfitBricks::Model
|
4
|
+
class << self
|
5
|
+
# List all groups.
|
6
|
+
def list_group(options = {})
|
7
|
+
ProfitBricks::Group.list(options)
|
8
|
+
end
|
9
|
+
|
10
|
+
# Retrieve a group.
|
11
|
+
def get_group(group_id)
|
12
|
+
ProfitBricks::Group.get(group_id)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Create a new group.
|
16
|
+
def create_group(options = {})
|
17
|
+
ProfitBricks::Group.create(options)
|
18
|
+
end
|
19
|
+
|
20
|
+
# List all shares.
|
21
|
+
def list_share(group_id, options = {})
|
22
|
+
ProfitBricks::Share.list(group_id, options)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Retrieve a share.
|
26
|
+
def get_share(group_id, share_id)
|
27
|
+
ProfitBricks::Share.get(group_id, share_id)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Create a new share.
|
31
|
+
def create_share(group_id, options = {})
|
32
|
+
ProfitBricks::Share.create(group_id, options)
|
33
|
+
end
|
34
|
+
|
35
|
+
# List all groups.
|
36
|
+
def list_user(options = {})
|
37
|
+
ProfitBricks::User.list(options)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Retrieve a user.
|
41
|
+
def get_user(user_id)
|
42
|
+
ProfitBricks::User.get(user_id)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Create a new user.
|
46
|
+
def create_user(options = {})
|
47
|
+
ProfitBricks::User.create(options)
|
48
|
+
end
|
49
|
+
|
50
|
+
# List all resources.
|
51
|
+
def list_resource(options = {})
|
52
|
+
ProfitBricks::Resource.list(options)
|
53
|
+
end
|
54
|
+
|
55
|
+
# Retrieve a resource.
|
56
|
+
def get_resoruce(resource_type, resource_id, options = {})
|
57
|
+
ProfitBricks::Resource.get(resource_type, resource_id, options)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/profitbricks/version.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ProfitBricks::Contract do
|
4
|
+
before(:all) do
|
5
|
+
@contract = ProfitBricks::Contract.get
|
6
|
+
end
|
7
|
+
|
8
|
+
it '#get' do
|
9
|
+
expect(@contract.type).to eq('contract')
|
10
|
+
expect(@contract.properties['contractNumber']).to be_kind_of(Integer)
|
11
|
+
expect(@contract.properties['owner']).to be_kind_of(String)
|
12
|
+
expect(@contract.properties['status']).to be_kind_of(String)
|
13
|
+
end
|
14
|
+
|
15
|
+
it '#get_by_contract_id' do
|
16
|
+
contract = ProfitBricks::Contract.get_by_contract_id(@contract.properties['contractNumber'])
|
17
|
+
|
18
|
+
expect(contract.type).to eq('contract')
|
19
|
+
expect(contract.properties['contractNumber']).to be_kind_of(Integer)
|
20
|
+
expect(contract.properties['contractNumber']).to eq(@contract.properties['contractNumber'])
|
21
|
+
expect(contract.properties['owner']).to be_kind_of(String)
|
22
|
+
expect(contract.properties['status']).to be_kind_of(String)
|
23
|
+
end
|
24
|
+
end
|
data/spec/datacenter_spec.rb
CHANGED
@@ -5,6 +5,9 @@ describe ProfitBricks::Datacenter do
|
|
5
5
|
@datacenter = ProfitBricks::Datacenter.create(options[:datacenter])
|
6
6
|
@datacenter.wait_for { ready? }
|
7
7
|
|
8
|
+
@composite_datacenter= ProfitBricks::Datacenter.create(options[:datacenter_composite])
|
9
|
+
@datacenter.wait_for { ready? }
|
10
|
+
|
8
11
|
@server = @datacenter.create_server(options[:server])
|
9
12
|
@server.wait_for { ready? }
|
10
13
|
|
@@ -20,14 +23,32 @@ describe ProfitBricks::Datacenter do
|
|
20
23
|
|
21
24
|
after(:all) do
|
22
25
|
@datacenter.delete
|
26
|
+
@composite_datacenter.delete
|
23
27
|
end
|
24
28
|
|
25
|
-
it '#create' do
|
29
|
+
it '#create simple' do
|
26
30
|
expect(@datacenter.type).to eq('datacenter')
|
27
31
|
expect(@datacenter.id).to match(options[:uuid])
|
28
|
-
expect(@datacenter.properties['name']).to eq('Ruby SDK
|
29
|
-
expect(@datacenter.properties['description']).to eq('SDK test
|
30
|
-
expect(@datacenter.properties['location']).to eq('
|
32
|
+
expect(@datacenter.properties['name']).to eq('Ruby SDK Test')
|
33
|
+
expect(@datacenter.properties['description']).to eq('Ruby SDK test datacenter')
|
34
|
+
expect(@datacenter.properties['location']).to eq('us/las')
|
35
|
+
end
|
36
|
+
|
37
|
+
it '#create failure' do
|
38
|
+
expect { ProfitBricks::Datacenter.create(options[:bad_datacenter]) }.to raise_error(Excon::Error::UnprocessableEntity, /Attribute 'location' is required/)
|
39
|
+
end
|
40
|
+
|
41
|
+
it '#create composite' do
|
42
|
+
@composite_datacenter.wait_for(300) { ready? }
|
43
|
+
@composite_datacenter.reload
|
44
|
+
|
45
|
+
expect(@composite_datacenter.type).to eq('datacenter')
|
46
|
+
expect(@composite_datacenter.id).to match(options[:uuid])
|
47
|
+
expect(@composite_datacenter.properties['name']).to eq('Ruby SDK Test Composite')
|
48
|
+
expect(@composite_datacenter.properties['description']).to eq('Ruby SDK test composite datacenter')
|
49
|
+
expect(@composite_datacenter.properties['location']).to eq('us/las')
|
50
|
+
expect(@composite_datacenter.entities['servers']['items'].count).to be > 0
|
51
|
+
expect(@composite_datacenter.entities['volumes']['items'].count).to be > 0
|
31
52
|
end
|
32
53
|
|
33
54
|
it '#list' do
|
@@ -43,21 +64,25 @@ describe ProfitBricks::Datacenter do
|
|
43
64
|
|
44
65
|
expect(datacenter.type).to eq('datacenter')
|
45
66
|
expect(datacenter.id).to eq(@datacenter.id)
|
46
|
-
expect(datacenter.properties['name']).to eq('Ruby SDK
|
47
|
-
expect(datacenter.properties['description']).to eq('SDK test
|
48
|
-
expect(datacenter.properties['location']).to eq('
|
67
|
+
expect(datacenter.properties['name']).to eq('Ruby SDK Test')
|
68
|
+
expect(datacenter.properties['description']).to eq('Ruby SDK test datacenter')
|
69
|
+
expect(datacenter.properties['location']).to eq('us/las')
|
49
70
|
expect(datacenter.properties['version']).to be_kind_of(Integer)
|
50
71
|
end
|
51
72
|
|
73
|
+
it '#get failure' do
|
74
|
+
expect { ProfitBricks::Datacenter.get("bad_id") }.to raise_error(Excon::Error::NotFound, /Resource does not exist/)
|
75
|
+
end
|
76
|
+
|
52
77
|
it '#update' do
|
53
78
|
datacenter = ProfitBricks::Datacenter.get(@datacenter.id)
|
54
|
-
datacenter.update(name: '
|
79
|
+
datacenter.update(name: 'Ruby SDK Test - RENAME')
|
55
80
|
|
56
81
|
expect(datacenter.id).to eq(@datacenter.id)
|
57
|
-
expect(datacenter.properties['name']).to eq('
|
58
|
-
expect(datacenter.properties['
|
59
|
-
expect(datacenter.properties['location']).to eq('de/fkb')
|
82
|
+
expect(datacenter.properties['name']).to eq('Ruby SDK Test - RENAME')
|
83
|
+
expect(datacenter.properties['location']).to eq('us/las')
|
60
84
|
expect(datacenter.properties['version']).to be_kind_of(Integer)
|
85
|
+
expect(datacenter.properties['version']).to be > 0
|
61
86
|
end
|
62
87
|
|
63
88
|
it '#delete' do
|
@@ -73,10 +98,10 @@ describe ProfitBricks::Datacenter do
|
|
73
98
|
|
74
99
|
expect(servers[0].type).to eq('server')
|
75
100
|
expect(servers[0].id).to match(options[:uuid])
|
76
|
-
expect(servers[0].properties['name']).to eq('
|
101
|
+
expect(servers[0].properties['name']).to eq('Ruby SDK Test')
|
77
102
|
expect(servers[0].properties['cores']).to be_kind_of(Integer)
|
78
103
|
expect(servers[0].properties['ram']).to eq(1024)
|
79
|
-
expect(servers[0].properties['availabilityZone']).to eq('
|
104
|
+
expect(servers[0].properties['availabilityZone']).to eq('ZONE_1')
|
80
105
|
expect(servers[0].properties['vmState']).to eq('RUNNING')
|
81
106
|
expect(servers[0].properties['bootVolume']).to be nil
|
82
107
|
expect(servers[0].properties['bootCdrom']).to be nil
|
@@ -87,10 +112,10 @@ describe ProfitBricks::Datacenter do
|
|
87
112
|
|
88
113
|
expect(server.type).to eq('server')
|
89
114
|
expect(server.id).to match(options[:uuid])
|
90
|
-
expect(server.properties['name']).to eq('
|
115
|
+
expect(server.properties['name']).to eq('Ruby SDK Test')
|
91
116
|
expect(server.properties['cores']).to be_kind_of(Integer)
|
92
117
|
expect(server.properties['ram']).to eq(1024)
|
93
|
-
expect(server.properties['availabilityZone']).to eq('
|
118
|
+
expect(server.properties['availabilityZone']).to eq('ZONE_1')
|
94
119
|
expect(server.properties['vmState']).to eq('RUNNING')
|
95
120
|
expect(server.properties['bootVolume']).to be nil
|
96
121
|
expect(server.properties['bootCdrom']).to be nil
|
@@ -101,10 +126,10 @@ describe ProfitBricks::Datacenter do
|
|
101
126
|
|
102
127
|
expect(server.type).to eq('server')
|
103
128
|
expect(server.id).to eq(@server.id)
|
104
|
-
expect(server.properties['name']).to eq('
|
129
|
+
expect(server.properties['name']).to eq('Ruby SDK Test')
|
105
130
|
expect(server.properties['cores']).to be_kind_of(Integer)
|
106
131
|
expect(server.properties['ram']).to eq(1024)
|
107
|
-
expect(server.properties['availabilityZone']).to eq('
|
132
|
+
expect(server.properties['availabilityZone']).to eq('ZONE_1')
|
108
133
|
expect(server.properties['vmState']).to eq('RUNNING')
|
109
134
|
expect(server.properties['bootVolume']).to be nil
|
110
135
|
expect(server.properties['bootCdrom']).to be nil
|
@@ -115,8 +140,8 @@ describe ProfitBricks::Datacenter do
|
|
115
140
|
|
116
141
|
expect(volumes[0].type).to eq('volume')
|
117
142
|
expect(volumes[0].id).to match(options[:uuid])
|
118
|
-
expect(volumes[0].properties['name']).to eq('
|
119
|
-
expect(volumes[0].properties['size']).to eq(
|
143
|
+
expect(volumes[0].properties['name']).to eq('Ruby SDK Test')
|
144
|
+
expect(volumes[0].properties['size']).to eq(2)
|
120
145
|
expect(volumes[0].properties['bus']).to be nil
|
121
146
|
expect(volumes[0].properties['image']).to be nil
|
122
147
|
expect(volumes[0].properties['imagePassword']).to be nil
|
@@ -130,8 +155,8 @@ describe ProfitBricks::Datacenter do
|
|
130
155
|
|
131
156
|
expect(volume.type).to eq('volume')
|
132
157
|
expect(volume.id).to match(options[:uuid])
|
133
|
-
expect(volume.properties['name']).to eq('
|
134
|
-
expect(volume.properties['size']).to eq(
|
158
|
+
expect(volume.properties['name']).to eq('Ruby SDK Test')
|
159
|
+
expect(volume.properties['size']).to eq(2)
|
135
160
|
expect(volume.properties['bus']).to be nil
|
136
161
|
expect(volume.properties['image']).to be nil
|
137
162
|
expect(volume.properties['imagePassword']).to be nil
|
@@ -146,8 +171,8 @@ describe ProfitBricks::Datacenter do
|
|
146
171
|
|
147
172
|
expect(volume.type).to eq('volume')
|
148
173
|
expect(volume.id).to match(options[:uuid])
|
149
|
-
expect(volume.properties['name']).to eq('
|
150
|
-
expect(volume.properties['size']).to eq(
|
174
|
+
expect(volume.properties['name']).to eq('Ruby SDK Test')
|
175
|
+
expect(volume.properties['size']).to eq(2)
|
151
176
|
expect(volume.properties['bus']).to be nil
|
152
177
|
expect(volume.properties['image']).to be nil
|
153
178
|
expect(volume.properties['imagePassword']).to be nil
|
@@ -161,7 +186,7 @@ describe ProfitBricks::Datacenter do
|
|
161
186
|
|
162
187
|
expect(loadbalancers[0].type).to eq('loadbalancer')
|
163
188
|
expect(loadbalancers[0].id).to be_kind_of(String)
|
164
|
-
expect(loadbalancers[0].properties['name']).to eq('
|
189
|
+
expect(loadbalancers[0].properties['name']).to eq('Ruby SDK Test')
|
165
190
|
expect(loadbalancers[0].properties['ip']).to be nil
|
166
191
|
expect(loadbalancers[0].properties['dhcp']).to be true
|
167
192
|
end
|
@@ -171,7 +196,7 @@ describe ProfitBricks::Datacenter do
|
|
171
196
|
|
172
197
|
expect(loadbalancer.type).to eq('loadbalancer')
|
173
198
|
expect(loadbalancer.id).to be_kind_of(String)
|
174
|
-
expect(loadbalancer.properties['name']).to eq('
|
199
|
+
expect(loadbalancer.properties['name']).to eq('Ruby SDK Test')
|
175
200
|
expect(loadbalancer.properties['ip']).to be nil
|
176
201
|
expect(loadbalancer.properties['dhcp']).to be true
|
177
202
|
end
|
@@ -182,7 +207,7 @@ describe ProfitBricks::Datacenter do
|
|
182
207
|
|
183
208
|
expect(loadbalancer.type).to eq('loadbalancer')
|
184
209
|
expect(loadbalancer.id).to be_kind_of(String)
|
185
|
-
expect(loadbalancer.properties['name']).to eq('
|
210
|
+
expect(loadbalancer.properties['name']).to eq('Ruby SDK Test')
|
186
211
|
expect(loadbalancer.properties['ip']).to be nil
|
187
212
|
expect(loadbalancer.properties['dhcp']).to be true
|
188
213
|
end
|
@@ -192,7 +217,7 @@ describe ProfitBricks::Datacenter do
|
|
192
217
|
|
193
218
|
expect(lans[0].type).to eq('lan')
|
194
219
|
expect(lans[0].id).to match(/^\d+$/)
|
195
|
-
expect(lans[0].properties['name']).to eq('
|
220
|
+
expect(lans[0].properties['name']).to eq('Ruby SDK Test')
|
196
221
|
expect(lans[0].properties['public']).to be true
|
197
222
|
end
|
198
223
|
|
@@ -201,7 +226,7 @@ describe ProfitBricks::Datacenter do
|
|
201
226
|
|
202
227
|
expect(lan.type).to eq('lan')
|
203
228
|
expect(lan.id).to match(/^\d+$/)
|
204
|
-
expect(lan.properties['name']).to eq('
|
229
|
+
expect(lan.properties['name']).to eq('Ruby SDK Test')
|
205
230
|
expect(lan.properties['public']).to be true
|
206
231
|
end
|
207
232
|
|
@@ -210,7 +235,7 @@ describe ProfitBricks::Datacenter do
|
|
210
235
|
|
211
236
|
expect(lan.type).to eq('lan')
|
212
237
|
expect(lan.id).to match(/^\d+$/)
|
213
|
-
expect(lan.properties['name']).to eq('
|
238
|
+
expect(lan.properties['name']).to eq('Ruby SDK Test')
|
214
239
|
expect(lan.properties['public']).to be true
|
215
240
|
end
|
216
241
|
end
|
data/spec/firewall_spec.rb
CHANGED
@@ -33,6 +33,10 @@ describe ProfitBricks::Firewall do
|
|
33
33
|
expect(@fwrule.properties['icmpCode']).to be nil
|
34
34
|
end
|
35
35
|
|
36
|
+
it '#create failure' do
|
37
|
+
expect { ProfitBricks::Firewall.create(@datacenter.id, @server.id, @nic.id, { name: 'Ruby SDK Test' }) }.to raise_error(Excon::Error::UnprocessableEntity, /Attribute 'protocol' is required/)
|
38
|
+
end
|
39
|
+
|
36
40
|
it '#list' do
|
37
41
|
fwrules = ProfitBricks::Firewall.list(@datacenter.id, @server.id, @nic.id)
|
38
42
|
|
@@ -66,24 +70,28 @@ describe ProfitBricks::Firewall do
|
|
66
70
|
expect(fwrule.properties['icmpCode']).to be nil
|
67
71
|
end
|
68
72
|
|
73
|
+
it '#get failure' do
|
74
|
+
expect { ProfitBricks::Firewall.get(@datacenter.id, @server.id, @nic.id, options[:bad_id]) }.to raise_error(Excon::Error::NotFound, /Resource does not exist/)
|
75
|
+
end
|
76
|
+
|
69
77
|
it '#update' do
|
70
78
|
fwrule = @fwrule.update(
|
71
|
-
|
72
|
-
targetIp: '123.100.101.102'
|
79
|
+
name: 'SSH - RENAME'
|
73
80
|
)
|
74
81
|
fwrule.wait_for { ready? }
|
75
82
|
|
76
83
|
expect(fwrule.type).to eq('firewall-rule')
|
77
84
|
expect(fwrule.id).to eq(@fwrule.id)
|
78
|
-
expect(fwrule.properties['name']).to eq('SSH')
|
85
|
+
expect(fwrule.properties['name']).to eq('SSH - RENAME')
|
79
86
|
expect(fwrule.properties['protocol']).to eq('TCP')
|
80
|
-
expect(fwrule.properties['sourceMac']).to eq('01:
|
87
|
+
expect(fwrule.properties['sourceMac']).to eq('01:23:45:67:89:00')
|
81
88
|
expect(fwrule.properties['sourceIp']).to be nil
|
82
|
-
expect(fwrule.properties['targetIp']).to
|
89
|
+
expect(fwrule.properties['targetIp']).to be nil
|
83
90
|
expect(fwrule.properties['portRangeStart']).to eq(22)
|
84
91
|
expect(fwrule.properties['portRangeEnd']).to eq(22)
|
85
92
|
expect(fwrule.properties['icmpType']).to be nil
|
86
93
|
expect(fwrule.properties['icmpCode']).to be nil
|
94
|
+
#expect(fwrule.properties['version']).to eq('1')
|
87
95
|
end
|
88
96
|
|
89
97
|
it '#delete' do
|
data/spec/group_spec.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe ProfitBricks::Group do
|
4
|
+
before(:all) do
|
5
|
+
@group = ProfitBricks::Group.create(options[:group])
|
6
|
+
@group.wait_for { ready? }
|
7
|
+
end
|
8
|
+
|
9
|
+
after(:all) do
|
10
|
+
@group.delete()
|
11
|
+
end
|
12
|
+
|
13
|
+
it '#create failure' do
|
14
|
+
expect { ProfitBricks::Group.create(options[:bad_group]) }.to raise_error(Excon::Error::UnprocessableEntity)
|
15
|
+
end
|
16
|
+
|
17
|
+
it '#create' do
|
18
|
+
expect(@group.id).to match(options[:uuid])
|
19
|
+
expect(@group.type).to eq('group')
|
20
|
+
expect(@group.properties['name']).to eq('Ruby SDK Test')
|
21
|
+
#expect(@group.properties.createDataCenter).to be true
|
22
|
+
#expect(@group.properties.createSnapshot).to be true
|
23
|
+
#expect(@group.properties.reserveIp).to be true
|
24
|
+
#expect(@group.properties.accessActivityLog).to be true
|
25
|
+
end
|
26
|
+
|
27
|
+
it '#list' do
|
28
|
+
groups = ProfitBricks::Group.list()
|
29
|
+
|
30
|
+
expect(groups.count).to be > 0
|
31
|
+
expect(groups[0].type).to eq('group')
|
32
|
+
end
|
33
|
+
|
34
|
+
it '#get' do
|
35
|
+
group = ProfitBricks::Group.get(@group.id)
|
36
|
+
expect(@group.type).to eq('group')
|
37
|
+
expect(@group.properties['name']).to eq('Ruby SDK Test')
|
38
|
+
#expect(@group.properties.createDataCenter).to be true
|
39
|
+
#expect(@group.properties.createSnapshot).to be true
|
40
|
+
#expect(@group.properties.reserveIp).to be true
|
41
|
+
#expect(@group.properties.accessActivityLog).to be true
|
42
|
+
end
|
43
|
+
|
44
|
+
it '#get failure' do
|
45
|
+
expect { ProfitBricks::Group.get(options[:bad_id]) }.to raise_error(Excon::Error::NotFound)
|
46
|
+
end
|
47
|
+
|
48
|
+
it '#update' do
|
49
|
+
group = @group.update(
|
50
|
+
name: 'Ruby SDK Test - RENAME',
|
51
|
+
#create_datacenter: false
|
52
|
+
)
|
53
|
+
|
54
|
+
expect(@group.type).to eq('group')
|
55
|
+
expect(@group.properties['name']).to eq('Ruby SDK Test - RENAME')
|
56
|
+
#expect(@group.properties.createDataCenter).to be false
|
57
|
+
end
|
58
|
+
|
59
|
+
it '#delete' do
|
60
|
+
group = ProfitBricks::Group.create(options[:group])
|
61
|
+
group.wait_for { ready? }
|
62
|
+
|
63
|
+
expect(group.delete.requestId).to match(options[:uuid])
|
64
|
+
end
|
65
|
+
end
|