occi-api 4.0.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +15 -0
- data/.rspec +1 -0
- data/.travis.yml +43 -0
- data/.yardopts +1 -0
- data/AUTHORS +9 -0
- data/Gemfile +16 -0
- data/LICENSE +13 -0
- data/README.md +344 -0
- data/Rakefile +37 -0
- data/examples/dsl_example.rb +167 -0
- data/examples/x509auth_example.rb +161 -0
- data/ext/mkrf_conf.rb +34 -0
- data/features/cassettes/Create_an_OCCI_Resource/_http_http___141_5_99_69__text_plain_201_.yml +288 -0
- data/features/cassettes/Delete_an_OCCI_Resource/_http_http___141_5_99_69__text_plain_201_.yml +288 -0
- data/features/cassettes/Discovery_Interface/Retrieving_all_OCCI_Categories_supported_by_the_OCCI_Server/_http_http___141_5_99_69__application_json_200_.yml +333 -0
- data/features/cassettes/Discovery_Interface/Retrieving_all_OCCI_Categories_supported_by_the_OCCI_Server/_http_http___141_5_99_69__text_plain_200_.yml +529 -0
- data/features/cassettes/Discovery_Interface/Retrieving_all_OCCI_Categories_supported_by_the_OCCI_Server/_http_http___141_5_99_69__text_plain_200_action_.yml +288 -0
- data/features/cassettes/Miscellaneous_operation_on_an_OCCI_Resource/_http_http___141_5_99_69__text_plain_201_.yml +288 -0
- data/features/cassettes/Read_an_OCCI_Resource/_http_http___141_5_99_69__text_plain_201_.yml +288 -0
- data/features/cassettes/Update_an_OCCI_Resource/_http_http___141_5_99_69__text_plain_201_.yml +288 -0
- data/features/common/step_definitions/common_steps.rb +32 -0
- data/features/occi/core/create/create.feature +18 -0
- data/features/occi/core/create/step_definitions/create_steps.rb +0 -0
- data/features/occi/core/delete/delete.feature +18 -0
- data/features/occi/core/delete/step_definitions/delete_steps.rb +0 -0
- data/features/occi/core/discovery_interface/discovery_interface.feature +37 -0
- data/features/occi/core/discovery_interface/step_definitions/discovery_interface_steps.rb +19 -0
- data/features/occi/core/miscellaneous/miscellaneous.feature +18 -0
- data/features/occi/core/miscellaneous/step_definitions/miscellaneous_steps.rb +0 -0
- data/features/occi/core/read/read.feature +18 -0
- data/features/occi/core/read/step_definitions/read_steps.rb +0 -0
- data/features/occi/core/update/step_definitions/update_steps.rb +0 -0
- data/features/occi/core/update/update.feature +18 -0
- data/features/occi/infrastructure/create/create.feature +18 -0
- data/features/occi/infrastructure/create/step_definitions/create_steps.rb +0 -0
- data/features/support/env.rb +16 -0
- data/lib/occi/api/client/client_amqp.rb +766 -0
- data/lib/occi/api/client/client_base.rb +689 -0
- data/lib/occi/api/client/client_http.rb +541 -0
- data/lib/occi/api/client/errors/authn_error.rb +7 -0
- data/lib/occi/api/client/errors.rb +1 -0
- data/lib/occi/api/client/http/authn_plugins/base.rb +27 -0
- data/lib/occi/api/client/http/authn_plugins/basic.rb +22 -0
- data/lib/occi/api/client/http/authn_plugins/digest.rb +22 -0
- data/lib/occi/api/client/http/authn_plugins/dummy.rb +13 -0
- data/lib/occi/api/client/http/authn_plugins/keystone.rb +61 -0
- data/lib/occi/api/client/http/authn_plugins/x509.rb +46 -0
- data/lib/occi/api/client/http/authn_plugins.rb +6 -0
- data/lib/occi/api/client/http/authn_utils.rb +87 -0
- data/lib/occi/api/client/http/httparty_fix.rb +53 -0
- data/lib/occi/api/client/http/net_http_fix.rb +21 -0
- data/lib/occi/api/dsl.rb +146 -0
- data/lib/occi/api/version.rb +5 -0
- data/lib/occi-api.rb +14 -0
- data/occi-api.gemspec +38 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/creates_a_new_compute_resource.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/creates_a_new_network_resource.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/creates_a_new_storage_resource.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/deletes_a_compute_resource.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/deletes_a_network_resource.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/deletes_a_storage_resource.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/deploys_an_instance_based_on_OVF_OVA_file.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/describes_compute_resources.yml +368 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/describes_network_resources.yml +370 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/describes_storage_resources.yml +430 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/establishes_connection.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/finds_and_describes_scoped_os_tpl_mixin.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/finds_and_describes_scoped_resource_tpl_mixin.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/finds_and_describes_unscoped_mixin.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_compute_resource_using_type_identifier.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_compute_resource_using_type_name.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_network_resource_using_type_identifier.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_network_resource_using_type_name.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_storage_resource_using_type_identifier.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_storage_resource_using_type_name.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_entity_type_identifiers.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_entity_types.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_link_type_identifiers.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_link_types.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_mixin_type_identifiers.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_mixin_types.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_mixins.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_resource_type_identifiers.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_resource_types.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_compute_resources.yml +308 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_network_resources.yml +308 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_os_tpl_mixins.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_resource_tpl_mixins.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_storage_resources.yml +310 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/refreshes_its_model.yml +485 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/triggers_an_action_on_a_compute_resource.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/triggers_an_action_on_a_network_resource.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/triggers_an_action_on_a_storage_resource.yml +266 -0
- data/spec/occi/api/client/client_amqp_spec.rb +158 -0
- data/spec/occi/api/client/client_http_spec.rb +292 -0
- data/spec/occi/api/client/http/authn_utils_spec.rb +55 -0
- data/spec/occi/api/client/http/httparty_fix_spec.rb +0 -0
- data/spec/occi/api/client/http/net_http_fix_spec.rb +0 -0
- data/spec/occi/api/client/http/rocci-cred-cert.pem +3 -0
- data/spec/occi/api/client/http/rocci-cred-key-jruby.pem +3 -0
- data/spec/occi/api/client/http/rocci-cred-key.pem +3 -0
- data/spec/occi/api/client/http/rocci-cred.p12 +0 -0
- data/spec/occi/api/dsl_spec.rb +21 -0
- data/spec/spec_helper.rb +38 -0
- metadata +379 -0
@@ -0,0 +1,292 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
|
3
|
+
module Occi
|
4
|
+
module Api
|
5
|
+
module Client
|
6
|
+
|
7
|
+
vcr_options = { :record => :new_episodes }
|
8
|
+
describe ClientHttp, :vcr => vcr_options do
|
9
|
+
|
10
|
+
context "using media type text/plain" do
|
11
|
+
|
12
|
+
before(:each) do
|
13
|
+
@client = Occi::Api::Client::ClientHttp.new({
|
14
|
+
:endpoint => 'https://localhost:3300',
|
15
|
+
:auth => { :type => "none" },
|
16
|
+
:log => { :out => "/dev/null",
|
17
|
+
:level => Occi::Log::DEBUG },
|
18
|
+
:auto_connect => true,
|
19
|
+
:media_type => "text/plain,text/occi"
|
20
|
+
})
|
21
|
+
end
|
22
|
+
|
23
|
+
after(:each) do
|
24
|
+
@client.logger.close if @client && @client.logger
|
25
|
+
end
|
26
|
+
|
27
|
+
it "establishes connection" do
|
28
|
+
@client.connected.should be_true
|
29
|
+
end
|
30
|
+
|
31
|
+
it "instantiates a compute resource using type name" do
|
32
|
+
compute = @client.get_resource "compute"
|
33
|
+
|
34
|
+
compute.should be_a_kind_of Occi::Core::Resource
|
35
|
+
compute.kind.type_identifier.should eq "http://schemas.ogf.org/occi/infrastructure#compute"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "instantiates a compute resource using type identifier" do
|
39
|
+
compute = @client.get_resource "http://schemas.ogf.org/occi/infrastructure#compute"
|
40
|
+
|
41
|
+
compute.should be_a_kind_of Occi::Core::Resource
|
42
|
+
compute.kind.type_identifier.should eq "http://schemas.ogf.org/occi/infrastructure#compute"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "instantiates a network resource using type name" do
|
46
|
+
network = @client.get_resource "network"
|
47
|
+
|
48
|
+
network.should be_a_kind_of Occi::Core::Resource
|
49
|
+
network.kind.type_identifier.should eq "http://schemas.ogf.org/occi/infrastructure#network"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "instantiates a network resource using type identifier" do
|
53
|
+
network = @client.get_resource "http://schemas.ogf.org/occi/infrastructure#network"
|
54
|
+
|
55
|
+
network.should be_a_kind_of Occi::Core::Resource
|
56
|
+
network.kind.type_identifier.should eq "http://schemas.ogf.org/occi/infrastructure#network"
|
57
|
+
end
|
58
|
+
|
59
|
+
it "instantiates a storage resource using type name" do
|
60
|
+
storage = @client.get_resource "storage"
|
61
|
+
|
62
|
+
storage.should be_a_kind_of Occi::Core::Resource
|
63
|
+
storage.kind.type_identifier.should eq "http://schemas.ogf.org/occi/infrastructure#storage"
|
64
|
+
end
|
65
|
+
|
66
|
+
it "instantiates a storage resource using type identifier" do
|
67
|
+
storage = @client.get_resource "http://schemas.ogf.org/occi/infrastructure#storage"
|
68
|
+
|
69
|
+
storage.should be_a_kind_of Occi::Core::Resource
|
70
|
+
storage.kind.type_identifier.should eq "http://schemas.ogf.org/occi/infrastructure#storage"
|
71
|
+
end
|
72
|
+
|
73
|
+
it "lists all available resource types" do
|
74
|
+
@client.get_resource_types.should include("compute", "storage", "network")
|
75
|
+
end
|
76
|
+
|
77
|
+
it "lists all available resource type identifiers" do
|
78
|
+
@client.get_resource_type_identifiers.should include(
|
79
|
+
"http://schemas.ogf.org/occi/infrastructure#compute",
|
80
|
+
"http://schemas.ogf.org/occi/infrastructure#network",
|
81
|
+
"http://schemas.ogf.org/occi/infrastructure#storage"
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "lists all available entity types" do
|
86
|
+
@client.get_entity_types.should include("entity", "resource", "link")
|
87
|
+
end
|
88
|
+
|
89
|
+
it "lists all available entity type identifiers" do
|
90
|
+
@client.get_entity_type_identifiers.should include(
|
91
|
+
"http://schemas.ogf.org/occi/core#entity",
|
92
|
+
"http://schemas.ogf.org/occi/core#resource",
|
93
|
+
"http://schemas.ogf.org/occi/core#link"
|
94
|
+
)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "lists all available link types" do
|
98
|
+
@client.get_link_types.should include("storagelink", "networkinterface")
|
99
|
+
end
|
100
|
+
|
101
|
+
it "lists all available link type identifiers" do
|
102
|
+
@client.get_link_type_identifiers.should include(
|
103
|
+
"http://schemas.ogf.org/occi/infrastructure#storagelink",
|
104
|
+
"http://schemas.ogf.org/occi/infrastructure#networkinterface"
|
105
|
+
)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "lists all available mixin types" do
|
109
|
+
@client.get_mixin_types.should include("os_tpl", "resource_tpl")
|
110
|
+
end
|
111
|
+
|
112
|
+
it "lists all available mixin type identifiers" do
|
113
|
+
@client.get_mixin_type_identifiers.should include(
|
114
|
+
"http://schemas.ogf.org/occi/infrastructure#os_tpl",
|
115
|
+
"http://schemas.ogf.org/occi/infrastructure#resource_tpl"
|
116
|
+
)
|
117
|
+
end
|
118
|
+
|
119
|
+
it "lists compute resources" do
|
120
|
+
@client.list("compute").should eq ["https://localhost:3300/compute/c62fce01-0d8e-510c-ba07-973b0d6d5034"]
|
121
|
+
end
|
122
|
+
|
123
|
+
it "lists network resources" do
|
124
|
+
@client.list("network").should eq ["https://localhost:3300/network/1e8e0d63-e3c8-5be7-8a46-f4df226bca01"]
|
125
|
+
end
|
126
|
+
|
127
|
+
it "lists storage resources" do
|
128
|
+
@client.list("storage").should include(
|
129
|
+
"https://localhost:3300/storage/32fc6c92-88aa-54dc-b814-be0df741278e",
|
130
|
+
"https://localhost:3300/storage/5c1a7099-859e-5c3d-9386-740edbb610b8"
|
131
|
+
)
|
132
|
+
end
|
133
|
+
|
134
|
+
it "lists all available mixins" do
|
135
|
+
@client.get_mixins.should include(
|
136
|
+
"http://occi.localhost:3300/occi/infrastructure/resource_tpl#large",
|
137
|
+
"http://occi.localhost:3300/occi/infrastructure/resource_tpl#extra_large",
|
138
|
+
"http://occi.localhost:3300/occi/infrastructure/resource_tpl#medium",
|
139
|
+
"http://occi.localhost:3300/occi/infrastructure/resource_tpl#small",
|
140
|
+
"http://occi.localhost:3300/occi/infrastructure/os_tpl#mytesttemplate"
|
141
|
+
)
|
142
|
+
end
|
143
|
+
|
144
|
+
it "lists os_tpl mixins" do
|
145
|
+
@client.get_mixins("os_tpl").should eq ["http://occi.localhost:3300/occi/infrastructure/os_tpl#mytesttemplate"]
|
146
|
+
end
|
147
|
+
|
148
|
+
it "lists resource_tpl mixins" do
|
149
|
+
@client.get_mixins("resource_tpl").should include(
|
150
|
+
"http://occi.localhost:3300/occi/infrastructure/resource_tpl#large",
|
151
|
+
"http://occi.localhost:3300/occi/infrastructure/resource_tpl#extra_large",
|
152
|
+
"http://occi.localhost:3300/occi/infrastructure/resource_tpl#medium",
|
153
|
+
"http://occi.localhost:3300/occi/infrastructure/resource_tpl#small"
|
154
|
+
)
|
155
|
+
end
|
156
|
+
|
157
|
+
it "describes compute resources" do
|
158
|
+
cmpts = @client.describe("compute")
|
159
|
+
|
160
|
+
cmpts.length.should eq 1
|
161
|
+
cmpts.first.resources.first.attributes['occi.core.id'].should eq('c62fce01-0d8e-510c-ba07-973b0d6d5034')
|
162
|
+
cmpts.first.resources.first.attributes['occi.core.title'].should eq('one-3')
|
163
|
+
cmpts.first.resources.first.attributes['occi.compute.cores'].should eq(2)
|
164
|
+
cmpts.first.resources.first.attributes['org.opennebula.compute.cpu'].should eq(2.0)
|
165
|
+
cmpts.first.resources.first.attributes['occi.compute.memory'].should eq(1.564)
|
166
|
+
end
|
167
|
+
|
168
|
+
it "describes network resources" do
|
169
|
+
nets = @client.describe "network"
|
170
|
+
|
171
|
+
nets.length.should eq 1
|
172
|
+
nets.first.resources.first.attributes['occi.core.id'].should eq('1e8e0d63-e3c8-5be7-8a46-f4df226bca01')
|
173
|
+
nets.first.resources.first.attributes['occi.core.title'].should eq('private')
|
174
|
+
nets.first.resources.first.attributes['occi.network.allocation'].should eq('dynamic')
|
175
|
+
nets.first.resources.first.attributes['org.opennebula.network.id'].should eq("1")
|
176
|
+
end
|
177
|
+
|
178
|
+
it "describes storage resources" do
|
179
|
+
stors = @client.describe "storage"
|
180
|
+
|
181
|
+
stors.length.should eq 2
|
182
|
+
stors.last.resources.first.attributes['occi.core.id'].should eq('5c1a7099-859e-5c3d-9386-740edbb610b8')
|
183
|
+
stors.last.resources.first.attributes['occi.core.title'].should eq('ttylinux - VMware ')
|
184
|
+
stors.last.resources.first.attributes['occi.storage.state'].should eq('online')
|
185
|
+
stors.last.resources.first.attributes['org.opennebula.storage.id'].should eq("4")
|
186
|
+
|
187
|
+
stors.first.resources.first.attributes['occi.core.id'].should eq('32fc6c92-88aa-54dc-b814-be0df741278e')
|
188
|
+
end
|
189
|
+
|
190
|
+
it "finds and describes unscoped mixin" do
|
191
|
+
@client.find_mixin('mytesttemplate', nil, true)
|
192
|
+
end
|
193
|
+
|
194
|
+
it "finds and describes scoped os_tpl mixin" do
|
195
|
+
@client.find_mixin('mytesttemplate', "os_tpl", true)
|
196
|
+
end
|
197
|
+
|
198
|
+
it "finds and describes scoped resource_tpl mixin" do
|
199
|
+
@client.find_mixin('large', "resource_tpl", true)
|
200
|
+
end
|
201
|
+
|
202
|
+
it "creates a new compute resource"
|
203
|
+
|
204
|
+
it "creates a new storage resource"
|
205
|
+
|
206
|
+
it "creates a new network resource"
|
207
|
+
|
208
|
+
it "deploys an instance based on OVF/OVA file"
|
209
|
+
|
210
|
+
it "deletes a compute resource"
|
211
|
+
|
212
|
+
it "deletes a network resource"
|
213
|
+
|
214
|
+
it "deletes a storage resource"
|
215
|
+
|
216
|
+
it "triggers an action on a compute resource"
|
217
|
+
|
218
|
+
it "triggers an action on a storage resource"
|
219
|
+
|
220
|
+
it "triggers an action on a network resource"
|
221
|
+
|
222
|
+
it "refreshes its model" do
|
223
|
+
@client.refresh
|
224
|
+
end
|
225
|
+
|
226
|
+
end
|
227
|
+
|
228
|
+
context "using media type application/occi+json" do
|
229
|
+
|
230
|
+
before(:each) do
|
231
|
+
#@client = Occi::Api::ClientHttp.new({
|
232
|
+
# :endpoint => 'https://localhost:3300',
|
233
|
+
# :auth => { :type => "none" },
|
234
|
+
# :log => { :out => "/dev/null",
|
235
|
+
# :level => Occi::Log::DEBUG },
|
236
|
+
# :auto_connect => true,
|
237
|
+
# :media_type => "application/occi+json"
|
238
|
+
#})
|
239
|
+
end
|
240
|
+
|
241
|
+
it "establishes connection"
|
242
|
+
|
243
|
+
it "lists compute resources"
|
244
|
+
|
245
|
+
it "lists network resources"
|
246
|
+
|
247
|
+
it "lists storage resources"
|
248
|
+
|
249
|
+
it "lists all available mixins"
|
250
|
+
|
251
|
+
it "lists os_tpl mixins"
|
252
|
+
|
253
|
+
it "lists resource_tpl mixins"
|
254
|
+
|
255
|
+
it "describes compute resources"
|
256
|
+
|
257
|
+
it "describes network resources"
|
258
|
+
|
259
|
+
it "describes storage resources"
|
260
|
+
|
261
|
+
it "describes all available mixins"
|
262
|
+
|
263
|
+
it "describes os_tpl mixins"
|
264
|
+
|
265
|
+
it "describes resource_tpl mixins"
|
266
|
+
|
267
|
+
it "creates a new compute resource"
|
268
|
+
|
269
|
+
it "creates a new storage resource"
|
270
|
+
|
271
|
+
it "creates a new network resource"
|
272
|
+
|
273
|
+
it "deletes a compute resource"
|
274
|
+
|
275
|
+
it "deletes a network resource"
|
276
|
+
|
277
|
+
it "deletes a storage resource"
|
278
|
+
|
279
|
+
it "triggers an action on a compute resource"
|
280
|
+
|
281
|
+
it "triggers an action on a storage resource"
|
282
|
+
|
283
|
+
it "triggers an action on a network resource"
|
284
|
+
|
285
|
+
it "refreshes its model"
|
286
|
+
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'occi/api/client/http/authn_utils'
|
3
|
+
|
4
|
+
module Occi
|
5
|
+
module Api
|
6
|
+
module Client
|
7
|
+
|
8
|
+
describe AuthnUtils do
|
9
|
+
|
10
|
+
it "can handle PKCS#12 user credentials" do
|
11
|
+
path = File.expand_path("..", __FILE__)
|
12
|
+
|
13
|
+
pem_cert_pk = AuthnUtils.extract_pem_from_pkcs12(
|
14
|
+
path + "/rocci-cred.p12",
|
15
|
+
"passworD123"
|
16
|
+
)
|
17
|
+
|
18
|
+
pem_cert_ok = File.open(path + "/rocci-cred-cert.pem", "rb").read
|
19
|
+
|
20
|
+
if defined? JRUBY_VERSION
|
21
|
+
# PK is in PKCS#8 when running jRuby
|
22
|
+
pem_pk_ok = File.open(path + "/rocci-cred-key-jruby.pem", "rb").read
|
23
|
+
else
|
24
|
+
# PK is raw RSA key when running cRuby
|
25
|
+
pem_pk_ok = File.open(path + "/rocci-cred-key.pem", "rb").read
|
26
|
+
end
|
27
|
+
|
28
|
+
pem_cert_pk_ok = ""
|
29
|
+
pem_cert_pk_ok << pem_cert_ok << pem_pk_ok
|
30
|
+
|
31
|
+
|
32
|
+
# remove line wrapping
|
33
|
+
pem_cert_pk.delete! "\n"
|
34
|
+
pem_cert_pk_ok.delete! "\n"
|
35
|
+
|
36
|
+
# remove trailing new lines
|
37
|
+
pem_cert_pk.chomp!
|
38
|
+
pem_cert_pk_ok.chomp!
|
39
|
+
|
40
|
+
pem_cert_pk.should eq pem_cert_pk_ok
|
41
|
+
end
|
42
|
+
|
43
|
+
it "can read CA certificates from a file" do
|
44
|
+
path = File.expand_path("..", __FILE__)
|
45
|
+
|
46
|
+
ca_certs = AuthnUtils.certs_to_file_ary(path + "/rocci-cred-cert.pem")
|
47
|
+
|
48
|
+
ca_certs.should =~ [File.open(path + "/rocci-cred-cert.pem", "rb").read.chomp("\n")]
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,3 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIEFzCCAv+gAwIBAgIDEAABMA0GCSqGSIb3DQEBBQUAMIGWMQswCQYDVQQGEwJDWjEXMBUGA1UECAwOQ3plY2ggUmVwdWJsaWMxDTALBgNVBAcMBEJybm8xFTATBgNVBAoMDEZha2UgQ0EgaW5jLjERMA8GA1UECwwIck9DQ0kgQ0ExFTATBgNVBAMMDHJPQ0NJIHRlc3RlcjEeMBwGCSqGSIb3DQEJARYPc2VleWFAbG9jYWxob3N0MB4XDTEzMDIwODAxNTkzNloXDTIzMDIwNjAxNTkzNlowgYcxCzAJBgNVBAYTAkNaMRcwFQYDVQQIDA5DemVjaCBSZXB1YmxpYzEVMBMGA1UECgwMRmFrZSBDQSBpbmMuMREwDwYDVQQLDAhyT0NDSSBDQTEVMBMGA1UEAwwMck9DQ0kgdGVzdGVyMR4wHAYJKoZIhvcNAQkBFg9zZWV5YUBsb2NhbGhvc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDcjeRWvUe+p+bOTgl0JtUWpHCDrSoV5DQD59Rinol+1+471JDF6wloBrmo7nCyLtOpDUDUcRZIp9UKCZZLqx0FhmUySFCjU7wBtU1+IOhbEVH97+pff/2x9920C9uyV/06Vr7Ch8G8fYOZCplrmmWs5wj88mUSQBtSYMOZNQxkX18tj3oKgvLhAlRYoIAYJgkhFUsXegMUc7NRa9Kpt2ag2C7eKs9VMZuI9XF+e6xPK6lUPFV8lWzfKtrhiUkmEMbzb0A3CQLZNw8IPXYjNm4daoeZSZkLY9P6KlIXJnBZX1DfJ1WdpS19GUVlU7EmRqwccOeT7FkS3MAR8nK35nOVAgMBAAGjezB5MAkGA1UdEwQCMAAwLAY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yfre3XRWMaBEwRg7QIOJb0jYaZfWk2OtuYhgEhVXnNwPKUjyIDjuKu8l9BchLZDR4YCp2xlWcy8gU4h7/njA1RRmrllex01I8YmrGpUiwLVClQvgM7Enaw09h4RLeyiuVv3q5MN2S7DsCgYASah316SSCuSeH66rCEqVpSVcuRK9JLuj1ZVpVqHyFH3EUnYeshm+hNl+t120j3ctOKOZ3KApMueu6OeLNhk/P/8qlmk3IQH6ksYtZuS8Hks+hBRisVUw9/MAjgK5dDgM8Jsv1b5R7PaCYjJpe9GdtFZVJKPEo4Ey6UqWvINaAWwKBgQDj99/pv3YgIXywwl7yhvfaUFozEnV3JhBlrGfI9bvAvSw7uZiQ0K3R6f2ndMT1upF/MjpSQt/OE+r/UIPUbx5UMHlatbH9Vhz2cKCqjva3JCr5RPxFp64MHkqIu8rB2SiFrQo7cxb6cD0tkMwuusS++/qpvaGNmWRaF1NGT8qn9wKBgE8NRVgj7HcgvIgOA/VJVryuSbJC8ZTa9DmRoI6Na3Pp/qKKYJ/xsccjB4cGlGaX7QNWm9RufMRp5XIwpIa9mSv+1zYW+0nyysU4wdgQHoWqtmMs8AqbClCO6C4tME7e5g+daodwdXzEk5HwWYP6a8KupyGgwcFy9cbHfwT3zAmM
|
3
|
+
-----END RSA PRIVATE KEY-----
|
Binary file
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'occi-api'
|
3
|
+
require 'vcr'
|
4
|
+
|
5
|
+
# enable coverage reports
|
6
|
+
if ENV['COVERAGE']
|
7
|
+
require 'simplecov'
|
8
|
+
SimpleCov.start
|
9
|
+
end
|
10
|
+
|
11
|
+
# enable VCR for HTTP/HTTPS connections
|
12
|
+
# using RSPEC metadata integration;
|
13
|
+
# this will automatically generate a named
|
14
|
+
# cassette for each unit test
|
15
|
+
VCR.configure do |c|
|
16
|
+
c.hook_into :webmock
|
17
|
+
|
18
|
+
gem_root = File.expand_path '..', __FILE__
|
19
|
+
c.cassette_library_dir = "#{gem_root}/cassettes"
|
20
|
+
|
21
|
+
c.configure_rspec_metadata!
|
22
|
+
end
|
23
|
+
|
24
|
+
# simplify the usage of VCR; this will allow us to use
|
25
|
+
#
|
26
|
+
# it "does something", :vcr do
|
27
|
+
# ...
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# instead of
|
31
|
+
#
|
32
|
+
# it "does something else", :vcr => true do
|
33
|
+
# ...
|
34
|
+
# end
|
35
|
+
RSpec.configure do |c|
|
36
|
+
# in RSpec 3 this will no longer be necessary.
|
37
|
+
c.treat_symbols_as_metadata_keys_with_true_values = true
|
38
|
+
end
|