occi-core 4.2.14 → 4.2.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/occi/core/attributes.rb +10 -4
- data/lib/occi/parser.rb +13 -3
- data/lib/occi/version.rb +1 -1
- data/spec/occi/core/action_instance_spec.rb +5 -5
- data/spec/occi/core/attributes_spec.rb +30 -13
- data/spec/occi/core/category_spec.rb +3 -3
- data/spec/occi/core/entity_spec.rb +3 -3
- data/spec/occi/core/resource_spec.rb +1 -1
- data/spec/occi/infrastructure/compute_spec.rb +2 -2
- data/spec/occi/parser/text_spec.rb +4 -4
- data/spec/occi/parser_spec.rb +28 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e3409b60570656c2f8e0b3ec71f6d55ae1ecc82
|
4
|
+
data.tar.gz: 6de77b6298980b43be27ee89b727e4ba48149141
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9f6afb503d3d7f42be2d6630a3ffe2dfb493228072c8afe48a30d70468ace5b0b1ed93869f36ad651a64753e79dae586687afe78e011935385f5ca45b63cd14
|
7
|
+
data.tar.gz: 41456629fbb35cfc23d881a7b132c719466c9991cde17fd94b6ad7ef60f7afc34e49f218bcc601e4f8a6d08510ba94f88d5e555f564376c24b6e822ffbaad20d
|
data/lib/occi/core/attributes.rb
CHANGED
@@ -130,7 +130,7 @@ module Occi
|
|
130
130
|
# @return [String]
|
131
131
|
def to_string
|
132
132
|
attributes = ';'
|
133
|
-
attributes <<
|
133
|
+
attributes << to_array.join(';')
|
134
134
|
|
135
135
|
attributes == ';' ? '' : attributes
|
136
136
|
end
|
@@ -159,9 +159,10 @@ module Occi
|
|
159
159
|
text
|
160
160
|
end
|
161
161
|
|
162
|
-
# @return [
|
163
|
-
def
|
162
|
+
# @return [Array] of attributes put in an array
|
163
|
+
def to_array
|
164
164
|
attributes = []
|
165
|
+
|
165
166
|
names.each_pair do |name, value|
|
166
167
|
# TODO: find a better way to skip properties
|
167
168
|
next if name.include? '._'
|
@@ -175,7 +176,12 @@ module Occi
|
|
175
176
|
end
|
176
177
|
end
|
177
178
|
|
178
|
-
attributes
|
179
|
+
attributes
|
180
|
+
end
|
181
|
+
|
182
|
+
# @return [String] of attributes put in an array and then concatenated into a string
|
183
|
+
def to_header
|
184
|
+
to_array.join(',')
|
179
185
|
end
|
180
186
|
|
181
187
|
def to_json(*a)
|
data/lib/occi/parser.rb
CHANGED
@@ -114,9 +114,19 @@ module Occi
|
|
114
114
|
def headers_to_arys(header)
|
115
115
|
# remove the HTTP_ prefix if present and capitalize keys
|
116
116
|
header = Hash[header.map { |k, v| [k.gsub('HTTP_', '').capitalize, v] }]
|
117
|
-
header['X-OCCI-Location'] = header['X-occi-location'] if header['X-occi-location']
|
118
|
-
header['X-OCCI-Attribute'] = header['X-occi-attribute'] if header['X-occi-attribute']
|
119
117
|
|
118
|
+
# normalize different header-passing mechanisms and representations
|
119
|
+
if header['X-OCCI-Location'].blank?
|
120
|
+
header['X-OCCI-Location'] = header['X_occi_location'] unless header['X_occi_location'].blank?
|
121
|
+
header['X-OCCI-Location'] = header['X-occi-location'] unless header['X-occi-location'].blank?
|
122
|
+
end
|
123
|
+
|
124
|
+
if header['X-OCCI-Attribute'].blank?
|
125
|
+
header['X-OCCI-Attribute'] = header['X_occi_attribute'] unless header['X_occi_attribute'].blank?
|
126
|
+
header['X-OCCI-Attribute'] = header['X-occi-attribute'] unless header['X-occi-attribute'].blank?
|
127
|
+
end
|
128
|
+
|
129
|
+
# clean-up
|
120
130
|
header.delete_if { |k, v| v.blank? || !OCCI_HEADERS.include?(k) }
|
121
131
|
|
122
132
|
header = header.map do |k, v|
|
@@ -125,7 +135,7 @@ module Occi
|
|
125
135
|
v.to_s.split(',').collect { |w| "#{k}: #{w}".strip }
|
126
136
|
end
|
127
137
|
|
128
|
-
header.flatten
|
138
|
+
header.flatten.sort
|
129
139
|
end
|
130
140
|
|
131
141
|
end
|
data/lib/occi/version.rb
CHANGED
@@ -41,7 +41,7 @@ module Occi
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'does not fail without attributes' do
|
44
|
-
expect { Occi::Core::ActionInstance.new action, nil }.not_to raise_error
|
44
|
+
expect { Occi::Core::ActionInstance.new action, nil }.not_to raise_error
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'does not fail with an Occi::Core::Action instance' do
|
@@ -61,7 +61,7 @@ module Occi
|
|
61
61
|
end
|
62
62
|
|
63
63
|
it 'does not fail with un-convertable attribute values' do
|
64
|
-
expect { Occi::Core::ActionInstance.new action, attributes_unconvertable}.not_to raise_error
|
64
|
+
expect { Occi::Core::ActionInstance.new action, attributes_unconvertable}.not_to raise_error
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
@@ -292,14 +292,14 @@ X-OCCI-Attribute: org.opennebula.network.id=1|
|
|
292
292
|
context '#empty?' do
|
293
293
|
|
294
294
|
it 'returns false for a new instance with defaults' do
|
295
|
-
expect(ai.empty?).to
|
295
|
+
expect(ai.empty?).to be false
|
296
296
|
end
|
297
297
|
|
298
298
|
it 'returns true for an instance without an action' do
|
299
299
|
ai_changed = ai.clone
|
300
300
|
ai_changed.action = nil
|
301
301
|
|
302
|
-
expect(ai_changed.empty?).to
|
302
|
+
expect(ai_changed.empty?).to be true
|
303
303
|
end
|
304
304
|
|
305
305
|
it 'returns true for an instance with an empty action' do
|
@@ -307,7 +307,7 @@ X-OCCI-Attribute: org.opennebula.network.id=1|
|
|
307
307
|
ai_changed.action = Occi::Core::Action.new
|
308
308
|
ai_changed.action.term = nil
|
309
309
|
|
310
|
-
expect(ai_changed.empty?).to
|
310
|
+
expect(ai_changed.empty?).to be true
|
311
311
|
end
|
312
312
|
|
313
313
|
end
|
@@ -19,7 +19,7 @@ module Occi
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'accepts keys with underscores in other positions' do
|
22
|
-
expect{ attributes['t_est']={} }.to_not raise_error
|
22
|
+
expect{ attributes['t_est']={} }.to_not raise_error
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -90,7 +90,7 @@ module Occi
|
|
90
90
|
it 'matches a clone' do
|
91
91
|
expect(attrs==clone).to eql true
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
it 'matches a new instance with the same content' do
|
95
95
|
expect(attrs==newattrs).to eql true
|
96
96
|
end
|
@@ -112,7 +112,7 @@ module Occi
|
|
112
112
|
it 'matches a clone' do
|
113
113
|
expect(attrs.eql?(clone)).to eql true
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
it 'matches a new instance with the same content' do
|
117
117
|
expect(attrs.eql?(newattrs)).to eql true
|
118
118
|
end
|
@@ -171,7 +171,7 @@ module Occi
|
|
171
171
|
|
172
172
|
|
173
173
|
context 'rendering' do
|
174
|
-
let(:attrs){ attrs = Occi::Core::Attributes.new
|
174
|
+
let(:attrs){ attrs = Occi::Core::Attributes.new
|
175
175
|
attrs['numbertype'] = { :type => 'number', :default => 42, :mutable => true, :pattern => '^[0-9]+' }
|
176
176
|
attrs['stringtype'] = { :type => 'string', :pattern => '[adefltuv]+', :default => 'defaultvalue', :mutable => true }
|
177
177
|
attrs['booleantype'] = { :type => 'boolean', :default => true, :mutable => true}
|
@@ -227,6 +227,12 @@ module Occi
|
|
227
227
|
expected = ""
|
228
228
|
expect(empty.to_string).to eql expected
|
229
229
|
end
|
230
|
+
|
231
|
+
it 'copes with attribute values containing commas' do
|
232
|
+
attrs['stringtype'] = "flute,magic"
|
233
|
+
expected = ";numbertype=42;stringtype=\"flute,magic\";booleantype=true;booleantypefalse=false;booleantypepattern=true;nest.nested=11;properties=\"prop\";category=\"http://schemas.ogf.org/occi/core#category\";entity=\"/entity/testid\""
|
234
|
+
expect(attrs.to_string).to eql expected
|
235
|
+
end
|
230
236
|
end
|
231
237
|
|
232
238
|
context '#to_string_short' do
|
@@ -278,6 +284,17 @@ module Occi
|
|
278
284
|
end
|
279
285
|
end
|
280
286
|
|
287
|
+
context '#to_array' do
|
288
|
+
it 'renders attributes correctly' do
|
289
|
+
expected = ["numbertype=42","stringtype=\"flute\"","booleantype=true","booleantypefalse=false","booleantypepattern=true","nest.nested=11","properties=\"prop\"","category=\"http://schemas.ogf.org/occi/core#category\"","entity=\"/entity/testid\""]
|
290
|
+
expect(attrs.to_array).to eql expected
|
291
|
+
end
|
292
|
+
|
293
|
+
it 'copes with empty attributes' do
|
294
|
+
expect(empty.to_array).to be_empty
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
281
298
|
context '#to_json' do
|
282
299
|
it 'renders attributes correctly' do
|
283
300
|
expected = '{"numbertype":42,"stringtype":"flute","booleantype":true,"booleantypefalse":false,"booleantypepattern":true,"nest":{"nested":11},"properties":"prop","category":"http://schemas.ogf.org/occi/core#category","entity":"/entity/testid"}'
|
@@ -301,7 +318,7 @@ module Occi
|
|
301
318
|
expected.nest!.nested = 11
|
302
319
|
expected["category"] = "http://schemas.ogf.org/occi/core#category"
|
303
320
|
expected["properties"] = "prop"
|
304
|
-
expected["entity"] = "/entity/testid"
|
321
|
+
expected["entity"] = "/entity/testid"
|
305
322
|
|
306
323
|
expect(attrs.as_json).to eql expected
|
307
324
|
end
|
@@ -324,16 +341,16 @@ module Occi
|
|
324
341
|
:pattern => '^[0-9]+' }
|
325
342
|
defs['stringtype'] = { :type => 'string',
|
326
343
|
:pattern => '[adefltuv]+',
|
327
|
-
:default => 'defaultvalue',
|
344
|
+
:default => 'defaultvalue',
|
328
345
|
:mutable => true }
|
329
346
|
defs['booleantype'] = { :type => 'boolean',
|
330
|
-
:default => true,
|
347
|
+
:default => true,
|
331
348
|
:mutable => true}
|
332
349
|
defs['booleantypefalse'] = { :type => 'boolean', #Regression test
|
333
|
-
:default => false,
|
350
|
+
:default => false,
|
334
351
|
:mutable => true }
|
335
352
|
defs['booleantypepattern'] = { :type => 'boolean',
|
336
|
-
:default => true,
|
353
|
+
:default => true,
|
337
354
|
:mutable => true,
|
338
355
|
:pattern => true }
|
339
356
|
defs['nonmandatory'] = { :type => 'string',
|
@@ -342,7 +359,7 @@ module Occi
|
|
342
359
|
defs }
|
343
360
|
|
344
361
|
context 'unsupported types and attributes' do
|
345
|
-
before(:each){ Occi::Settings['compatibility']=false
|
362
|
+
before(:each){ Occi::Settings['compatibility']=false
|
346
363
|
Occi::Settings['verify_attribute_pattern']=true }
|
347
364
|
after(:each) { Occi::Settings.reload! }
|
348
365
|
it 'refuses undefined attribute' do
|
@@ -405,7 +422,7 @@ module Occi
|
|
405
422
|
end
|
406
423
|
|
407
424
|
context 'defaults' do
|
408
|
-
before(:each){ Occi::Settings['compatibility']=false
|
425
|
+
before(:each){ Occi::Settings['compatibility']=false
|
409
426
|
Occi::Settings['verify_attribute_pattern']=true }
|
410
427
|
after(:each) { Occi::Settings.reload! }
|
411
428
|
|
@@ -540,7 +557,7 @@ module Occi
|
|
540
557
|
attrs['numbertype'] = inattrs['numbertype']
|
541
558
|
expect(attrs).to eql inattrs
|
542
559
|
end
|
543
|
-
|
560
|
+
|
544
561
|
it 'correctly accepts Occi::Core::Properties' do
|
545
562
|
attrs['properties'] = Occi::Core::Properties.new
|
546
563
|
|
@@ -550,7 +567,7 @@ module Occi
|
|
550
567
|
|
551
568
|
expect(attrs).to eql expected
|
552
569
|
end
|
553
|
-
|
570
|
+
|
554
571
|
it 'correctly accepts Hash' do
|
555
572
|
attrs['hash'] = { :type => 'string', :pattern => '.*', :mutable => false, :required => false }
|
556
573
|
|
@@ -190,21 +190,21 @@ module Occi
|
|
190
190
|
context '#empty?' do
|
191
191
|
|
192
192
|
it 'returns false for a new instance with defaults' do
|
193
|
-
expect(category.empty?).to
|
193
|
+
expect(category.empty?).to be false
|
194
194
|
end
|
195
195
|
|
196
196
|
it 'returns true for an instance without a term' do
|
197
197
|
cat = category.clone
|
198
198
|
cat.term = nil
|
199
199
|
|
200
|
-
expect(cat.empty?).to
|
200
|
+
expect(cat.empty?).to be true
|
201
201
|
end
|
202
202
|
|
203
203
|
it 'returns true for an instance without a scheme' do
|
204
204
|
cat = category.clone
|
205
205
|
cat.scheme = nil
|
206
206
|
|
207
|
-
expect(cat.empty?).to
|
207
|
+
expect(cat.empty?).to be true
|
208
208
|
end
|
209
209
|
|
210
210
|
end
|
@@ -350,21 +350,21 @@ Link: </TestLoc/1?action=testaction>;rel="http://schemas.ogf.org/occi/core/entit
|
|
350
350
|
context '#empty?' do
|
351
351
|
|
352
352
|
it 'returns false for a new instance with defaults' do
|
353
|
-
expect(entity.empty?).to
|
353
|
+
expect(entity.empty?).to be false
|
354
354
|
end
|
355
355
|
|
356
356
|
it 'returns true for an instance without a kind' do
|
357
357
|
ent = entity.clone
|
358
358
|
ent.kind = nil
|
359
359
|
|
360
|
-
expect(ent.empty?).to
|
360
|
+
expect(ent.empty?).to be true
|
361
361
|
end
|
362
362
|
|
363
363
|
it 'returns true for an instance without an identifier' do
|
364
364
|
ent = entity.clone
|
365
365
|
ent.id = nil
|
366
366
|
|
367
|
-
expect(ent.empty?).to
|
367
|
+
expect(ent.empty?).to be true
|
368
368
|
end
|
369
369
|
|
370
370
|
end
|
@@ -17,7 +17,7 @@ module Occi
|
|
17
17
|
context '#storagelink' do
|
18
18
|
it "creates a single storagelink" do
|
19
19
|
compute.storagelink target
|
20
|
-
expect(compute.links).to
|
20
|
+
expect(compute.links.count).to eq 1
|
21
21
|
end
|
22
22
|
|
23
23
|
it "creates a storagelink to a storage resource" do
|
@@ -70,7 +70,7 @@ module Occi
|
|
70
70
|
context '#networkinterface' do
|
71
71
|
it "creates a single networkinterface" do
|
72
72
|
compute.networkinterface target
|
73
|
-
expect(compute.links).to
|
73
|
+
expect(compute.links.count).to eq 1
|
74
74
|
end
|
75
75
|
|
76
76
|
it "creates a networkinterface to a storage resource" do
|
@@ -33,10 +33,10 @@ module Occi
|
|
33
33
|
category_string = 'Category: restart;scheme="http://schemas.ogf.org/occi/infrastructure/compute/action#";class="action";title="Restart Compute instance";attributes="method{required} test{immutable}"'
|
34
34
|
category = Occi::Parser::Text.category category_string
|
35
35
|
|
36
|
-
expect(category.attributes['method'].required).to
|
37
|
-
expect(category.attributes['method'].mutable).to
|
38
|
-
expect(category.attributes['test'].required).to
|
39
|
-
expect(category.attributes['test'].mutable).to
|
36
|
+
expect(category.attributes['method'].required).to be true
|
37
|
+
expect(category.attributes['method'].mutable).to be true
|
38
|
+
expect(category.attributes['test'].required).to be false
|
39
|
+
expect(category.attributes['test'].mutable).to be false
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'parses attributes correctly' do
|
data/spec/occi/parser_spec.rb
CHANGED
@@ -40,7 +40,7 @@ module Occi
|
|
40
40
|
context 'resources from OCCI messages with text/occi MIME type' do
|
41
41
|
let(:rendered_collection){ collection.to_header }
|
42
42
|
let(:real_world_example_model) {
|
43
|
-
{"
|
43
|
+
{"Category" => "compute;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/compute/\",console;scheme=\"http://schemas.ogf.org/occi/infrastructure/compute#\";class=\"kind\";location=\"/console/\",entity;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";location=\"/entity/\",link;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";location=\"/link/\",network;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/network/\",networkinterface;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/networkinterface/\",resource;scheme=\"http://schemas.ogf.org/occi/core#\";class=\"kind\";location=\"/resource/\",storage;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/storage/\",storagelink;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\";location=\"/storagelink/\",compute;scheme=\"http://opennebula.org/occi/infrastructure#\";class=\"mixin\";location=\"/mixin/compute/\",extra_large;scheme=\"http://sitespecific.cesnet.cz/occi/infrastructure/resource_tpl#\";class=\"mixin\";location=\"/mixin/extra_large/\",ipnetwork;scheme=\"http://schemas.ogf.org/occi/infrastructure/network#\";class=\"mixin\";location=\"/mixin/ipnetwork/\",ipnetworkinterface;scheme=\"http://schemas.ogf.org/occi/infrastructure/networkinterface#\";class=\"mixin\";location=\"/mixin/ipnetworkinterface/\",large;scheme=\"http://sitespecific.cesnet.cz/occi/infrastructure/resource_tpl#\";class=\"mixin\";location=\"/mixin/large/\",medium;scheme=\"http://sitespecific.cesnet.cz/occi/infrastructure/resource_tpl#\";class=\"mixin\";location=\"/mixin/medium/\",network;scheme=\"http://opennebula.org/occi/infrastructure#\";class=\"mixin\";location=\"/mixin/network/\",networkinterface;scheme=\"http://opennebula.org/occi/infrastructure#\";class=\"mixin\";location=\"/mixin/networkinterface/\",os_tpl;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"mixin\";location=\"/mixin/os_tpl/\",public_key;scheme=\"http://schemas.openstack.org/instance/credentials#\";class=\"mixin\";location=\"/mixin/public_key/\",resource_tpl;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"mixin\";location=\"/mixin/resource_tpl/\",small;scheme=\"http://sitespecific.cesnet.cz/occi/infrastructure/resource_tpl#\";class=\"mixin\";location=\"/mixin/small/\",storage;scheme=\"http://opennebula.org/occi/infrastructure#\";class=\"mixin\";location=\"/mixin/storage/\",storagelink;scheme=\"http://opennebula.org/occi/infrastructure#\";class=\"mixin\";location=\"/mixin/storagelink/\",user_data;scheme=\"http://schemas.openstack.org/compute/instance#\";class=\"mixin\";location=\"/mixin/user_data/\",uuid_egi_compss_62;scheme=\"http://occi.localhost/occi/infrastructure/os_tpl#\";class=\"mixin\";location=\"/mixin/uuid_egi_compss_62/\",uuid_egi_compss_cesnet_57;scheme=\"http://occi.localhost/occi/infrastructure/os_tpl#\";class=\"mixin\";location=\"/mixin/uuid_egi_compss_cesnet_57/\",uuid_egi_compss_debian_7_0_x86_64_0001_cloud_dukan_74;scheme=\"http://occi.localhost/occi/infrastructure/os_tpl#\";class=\"mixin\";location=\"/mixin/uuid_egi_compss_debian_7_0_x86_64_0001_cloud_dukan_74/\",uuid_egi_sl6goldenimage_cesnet_50;scheme=\"http://occi.localhost/occi/infrastructure/os_tpl#\";class=\"mixin\";location=\"/mixin/uuid_egi_sl6goldenimage_cesnet_50/\",uuid_egi_test_compss_69;scheme=\"http://occi.localhost/occi/infrastructure/os_tpl#\";class=\"mixin\";location=\"/mixin/uuid_egi_test_compss_69/\",uuid_esa_sl64_cesnet_58;scheme=\"http://occi.localhost/occi/infrastructure/os_tpl#\";class=\"mixin\";location=\"/mixin/uuid_esa_sl64_cesnet_58/\",uuid_generic_vm_54;scheme=\"http://occi.localhost/occi/infrastructure/os_tpl#\";class=\"mixin\";location=\"/mixin/uuid_generic_vm_54/\",uuid_generic_www_60;scheme=\"http://occi.localhost/occi/infrastructure/os_tpl#\";class=\"mixin\";location=\"/mixin/uuid_generic_www_60/\",uuid_genericcloud_debian_7_0_x86_64_0001_cloud_dukan_71;scheme=\"http://occi.localhost/occi/infrastructure/os_tpl#\";class=\"mixin\";location=\"/mixin/uuid_genericcloud_debian_7_0_x86_64_0001_cloud_dukan_71/\",uuid_genericcloud_scilinux_6_5_x86_64_0001_cloud_dukan_73;scheme=\"http://occi.localhost/occi/infrastructure/os_tpl#\";class=\"mixin\";location=\"/mixin/uuid_genericcloud_scilinux_6_5_x86_64_0001_cloud_dukan_73/\",uuid_genericcloud_ubuntu_12_04_lts_x86_64_0001_cloud_dukan_72;scheme=\"http://occi.localhost/occi/infrastructure/os_tpl#\";class=\"mixin\";location=\"/mixin/uuid_genericcloud_ubuntu_12_04_lts_x86_64_0001_cloud_dukan_72/\",uuid_monitoring_20;scheme=\"http://occi.localhost/occi/infrastructure/os_tpl#\";class=\"mixin\";location=\"/mixin/uuid_monitoring_20/\",uuid_octave_55;scheme=\"http://occi.localhost/occi/infrastructure/os_tpl#\";class=\"mixin\";location=\"/mixin/uuid_octave_55/\",uuid_r_56;scheme=\"http://occi.localhost/occi/infrastructure/os_tpl#\";class=\"mixin\";location=\"/mixin/uuid_r_56/\""}
|
44
44
|
}
|
45
45
|
|
46
46
|
it 'parses self-generated collection with resources' do
|
@@ -54,17 +54,19 @@ module Occi
|
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'parses self-generated collection with added mixin' do
|
57
|
-
resource.mixins << Occi::Core::Mixin.new
|
57
|
+
resource.mixins << Occi::Core::Mixin.new('http://schemas.ogf.org/occi/mymixins#', 'test')
|
58
58
|
expect(Occi::Parser.parse('text/occi', '', false, Occi::Core::Resource, rendered_collection).to_header).to eql rendered_collection
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'parses self-generated collection with added link' do
|
62
62
|
collection << link
|
63
|
-
|
63
|
+
parsed = Occi::Parser.parse('text/occi', '', false, Occi::Core::Resource, rendered_collection)
|
64
|
+
expect(parsed.to_header).to eql rendered_collection
|
65
|
+
expect(parsed.resources.first.links).not_to be_empty
|
64
66
|
end
|
65
67
|
|
66
68
|
it 'parses a real-world example of the OCCI model' do
|
67
|
-
expect(Occi::Parser.parse('text/occi', '', true, Occi::Core::Resource, real_world_example_model).to_header.to_hash).to eql(
|
69
|
+
expect(Occi::Parser.parse('text/occi', '', true, Occi::Core::Resource, real_world_example_model).to_header.to_hash).to eql(real_world_example_model)
|
68
70
|
end
|
69
71
|
end
|
70
72
|
|
@@ -110,6 +112,20 @@ module Occi
|
|
110
112
|
end
|
111
113
|
|
112
114
|
context '.parse_headers' do
|
115
|
+
let(:resource_in_headers) do
|
116
|
+
resource = {}
|
117
|
+
resource['Category'] = "network;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"kind\",network;scheme=\"http://opennebula.org/occi/infrastructure#\";class=\"mixin\",ipnetwork;scheme=\"http://schemas.ogf.org/occi/infrastructure#\";class=\"mixin\""
|
118
|
+
resource['X-OCCI-Attribute'] = "occi.core.id=\"e4bd81c4-adda-5626-840d-39bb7959db97\",occi.core.title=\"monitoring\",occi.network.address=\"192.168.254.0\",occi.network.allocation=\"dynamic\",occi.network.state=\"active\",org.opennebula.network.id=\"6\",org.opennebula.network.bridge=\"xenbr0\",org.opennebula.network.vlan=\"NO\""
|
119
|
+
resource
|
120
|
+
end
|
121
|
+
|
122
|
+
let(:rack_resource_in_headers) do
|
123
|
+
resource = {}
|
124
|
+
resource['HTTP_CATEGORY'] = resource_in_headers['Category']
|
125
|
+
resource['HTTP_X_OCCI_ATTRIBUTE'] = resource_in_headers['X-OCCI-Attribute']
|
126
|
+
resource
|
127
|
+
end
|
128
|
+
|
113
129
|
it 'parses categories' do
|
114
130
|
categories_string = File.open("spec/occi/parser/text_samples/occi_categories.text", "rb").read
|
115
131
|
expected = Marshal.load(File.open("spec/occi/parser/text_samples/occi_categories.dump", "rb"))
|
@@ -117,10 +133,15 @@ module Occi
|
|
117
133
|
expect(categories).to eql expected
|
118
134
|
end
|
119
135
|
|
120
|
-
it 'parses resources' do
|
121
|
-
resource_string = File.open("spec/occi/parser/text_samples/occi_network_rocci_server.text", "rb").read
|
136
|
+
it 'parses resources from headers' do
|
122
137
|
expected = Marshal.load(File.open("spec/occi/parser/text_samples/occi_network_rocci_server.resource.dump", "rb"))
|
123
|
-
resource = Occi::Parser.parse('text/
|
138
|
+
resource = Occi::Parser.parse('text/occi', '', false, Occi::Core::Resource, resource_in_headers)
|
139
|
+
expect(resource).to eql expected
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'parses resources from rack-compliant headers' do
|
143
|
+
expected = Marshal.load(File.open("spec/occi/parser/text_samples/occi_network_rocci_server.resource.dump", "rb"))
|
144
|
+
resource = Occi::Parser.parse('text/occi', '', false, Occi::Core::Resource, rack_resource_in_headers)
|
124
145
|
expect(resource).to eql expected
|
125
146
|
end
|
126
147
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: occi-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Feldhaus
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-06-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|