omf_common 6.0.2.pre.2 → 6.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/file_broadcaster.rb +5 -0
- data/bin/file_receiver.rb +5 -0
- data/bin/omf_keygen +3 -3
- data/bin/omf_send_configure +114 -0
- data/bin/omf_send_request +19 -4
- data/example/engine_alt.rb +13 -7
- data/example/viz/garage_monitor.rb +69 -0
- data/example/viz/garage_viz.rb +52 -0
- data/example/viz/htdocs/image/garage.png +0 -0
- data/example/viz/htdocs/template/garage_banner.html +2 -0
- data/example/viz/layout.yaml +44 -0
- data/example/vm_alt.rb +5 -0
- data/lib/omf_common.rb +17 -8
- data/lib/omf_common/auth.rb +5 -0
- data/lib/omf_common/auth/certificate.rb +21 -2
- data/lib/omf_common/auth/certificate_store.rb +50 -20
- data/lib/omf_common/auth/ssh_pub_key_convert.rb +7 -0
- data/lib/omf_common/comm.rb +6 -1
- data/lib/omf_common/comm/amqp/amqp_communicator.rb +88 -12
- data/lib/omf_common/comm/amqp/amqp_file_transfer.rb +5 -0
- data/lib/omf_common/comm/amqp/amqp_topic.rb +37 -18
- data/lib/omf_common/comm/local/local_communicator.rb +5 -0
- data/lib/omf_common/comm/local/local_topic.rb +5 -0
- data/lib/omf_common/comm/topic.rb +32 -13
- data/lib/omf_common/comm/xmpp/communicator.rb +11 -1
- data/lib/omf_common/comm/xmpp/topic.rb +5 -0
- data/lib/omf_common/comm/xmpp/xmpp_mp.rb +5 -0
- data/lib/omf_common/command.rb +5 -0
- data/lib/omf_common/core_ext/string.rb +5 -0
- data/lib/omf_common/default_logging.rb +23 -5
- data/lib/omf_common/eventloop.rb +40 -23
- data/lib/omf_common/eventloop/em.rb +18 -5
- data/lib/omf_common/eventloop/local_evl.rb +18 -15
- data/lib/omf_common/exec_app.rb +44 -24
- data/lib/omf_common/key.rb +5 -0
- data/lib/omf_common/measure.rb +5 -0
- data/lib/omf_common/message.rb +5 -0
- data/lib/omf_common/message/json/json_message.rb +13 -5
- data/lib/omf_common/message/xml/message.rb +19 -4
- data/lib/omf_common/message/xml/relaxng_schema.rb +5 -0
- data/lib/omf_common/message/xml/topic_message.rb +5 -0
- data/lib/omf_common/version.rb +6 -1
- data/omf_common.gemspec +3 -2
- data/test/fixture/1st_level.pem +20 -0
- data/test/fixture/2nd_level.pem +19 -0
- data/test/fixture/3rd_level.pem +19 -0
- data/test/fixture/pubsub.rb +5 -0
- data/test/fixture/rc.pem +18 -0
- data/test/fixture/root.pem +17 -0
- data/test/omf_common/auth/certificate_spec.rb +27 -0
- data/test/omf_common/auth/certificate_store_spec.rb +58 -0
- data/test/omf_common/auth/ssh_pub_key_convert_spec.rb +5 -0
- data/test/omf_common/comm/topic_spec.rb +7 -1
- data/test/omf_common/comm/xmpp/communicator_spec.rb +5 -0
- data/test/omf_common/comm/xmpp/topic_spec.rb +5 -0
- data/test/omf_common/comm_spec.rb +5 -0
- data/test/omf_common/command_spec.rb +5 -0
- data/test/omf_common/core_ext/string_spec.rb +5 -0
- data/test/omf_common/message/xml/message_spec.rb +5 -0
- data/test/omf_common/message_spec.rb +8 -3
- data/test/test_helper.rb +5 -0
- metadata +48 -11
data/lib/omf_common/exec_app.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
#
|
2
7
|
# Copyright (c) 2006-2012 National ICT Australia (NICTA), Australia
|
3
8
|
#
|
@@ -36,25 +41,28 @@ class ExecApp
|
|
36
41
|
# Holds the pids for all active apps
|
37
42
|
@@all_apps = Hash.new
|
38
43
|
|
39
|
-
# True if this active app is being killed by a proper
|
40
|
-
# call to ExecApp.signal_all() or signal()
|
41
|
-
# (i.e. when the caller of ExecApp decided to stop the application,
|
42
|
-
# as far as we are concerned, this is a 'clean' exit)
|
43
|
-
@clean_exit = false
|
44
|
-
|
45
44
|
# Return an application instance based on its ID
|
46
45
|
#
|
47
46
|
# @param [String] id of the application to return
|
48
|
-
def
|
47
|
+
def self.[](id)
|
49
48
|
app = @@all_apps[id]
|
50
49
|
logger.info "Unknown application '#{id}/#{id.class}'" if app.nil?
|
51
50
|
return app
|
52
51
|
end
|
53
52
|
|
54
|
-
def
|
53
|
+
def self.signal_all(signal = 'KILL')
|
55
54
|
@@all_apps.each_value { |app| app.signal(signal) }
|
56
55
|
end
|
57
56
|
|
57
|
+
attr_reader :pid, :clean_exit
|
58
|
+
|
59
|
+
# True if this active app is being killed by a proper
|
60
|
+
# call to ExecApp.signal_all() or signal()
|
61
|
+
# (i.e. when the caller of ExecApp decided to stop the application,
|
62
|
+
# as far as we are concerned, this is a 'clean' exit)
|
63
|
+
@clean_exit = false
|
64
|
+
|
65
|
+
|
58
66
|
def stdin(line)
|
59
67
|
logger.debug "Writing '#{line}' to app '#{@id}'"
|
60
68
|
@stdin.write("#{line}\n")
|
@@ -63,9 +71,10 @@ class ExecApp
|
|
63
71
|
|
64
72
|
def signal(signal = 'KILL')
|
65
73
|
@clean_exit = true
|
66
|
-
Process.kill(signal, @pid)
|
74
|
+
Process.kill(signal, -1 * @pid) # we are sending to the entire process group
|
67
75
|
end
|
68
76
|
|
77
|
+
|
69
78
|
#
|
70
79
|
# Run an application 'cmd' in a separate thread and monitor
|
71
80
|
# its stdout. Also send status reports to the 'observer' by
|
@@ -78,9 +87,9 @@ class ExecApp
|
|
78
87
|
#
|
79
88
|
def initialize(id, cmd, map_std_err_to_out = false, working_directory = nil, &observer)
|
80
89
|
|
81
|
-
@id = id
|
90
|
+
@id = id || self.object_id
|
82
91
|
@observer = observer
|
83
|
-
@@all_apps[id] = self
|
92
|
+
@@all_apps[@id] = self
|
84
93
|
@exit_status = nil
|
85
94
|
@threads = []
|
86
95
|
|
@@ -88,8 +97,9 @@ class ExecApp
|
|
88
97
|
pr = IO::pipe
|
89
98
|
pe = IO::pipe
|
90
99
|
|
91
|
-
logger.debug "Starting application '#{id}' - cmd: '#{cmd}'"
|
92
|
-
|
100
|
+
logger.debug "Starting application '#{@id}' - cmd: '#{cmd}'"
|
101
|
+
#@observer.call(:STARTED, id, cmd)
|
102
|
+
call_observer(:STARTED, cmd)
|
93
103
|
@pid = fork {
|
94
104
|
# child will remap pipes to std and exec cmd
|
95
105
|
pw[1].close
|
@@ -105,6 +115,9 @@ class ExecApp
|
|
105
115
|
pe[1].close
|
106
116
|
|
107
117
|
begin
|
118
|
+
pgid = Process.setsid # Create a new process group
|
119
|
+
# which includes all potential child processes
|
120
|
+
STDOUT.puts "INTERNAL WARNING: Assuming process_group_id == pid" unless pgid == $$
|
108
121
|
Dir.chdir working_directory if working_directory
|
109
122
|
exec(cmd)
|
110
123
|
rescue => ex
|
@@ -124,12 +137,15 @@ class ExecApp
|
|
124
137
|
@threads << Thread.new(id, @pid) do |id, pid|
|
125
138
|
ret = Process.waitpid(pid)
|
126
139
|
@exit_status = $?.exitstatus
|
140
|
+
if @exit_status > 127
|
141
|
+
@exit_status = 128 - @exit_status
|
142
|
+
end
|
127
143
|
@@all_apps.delete(@id)
|
128
144
|
# app finished
|
129
145
|
if (@exit_status == 0) || @clean_exit
|
130
|
-
logger.debug "Application '#{id}' finished"
|
146
|
+
logger.debug "Application '#{@id}' finished"
|
131
147
|
else
|
132
|
-
logger.debug "Application '#{id}' failed (code=#{@exit_status})"
|
148
|
+
logger.debug "Application '#{@id}' failed (code=#{@exit_status})"
|
133
149
|
end
|
134
150
|
end
|
135
151
|
@stdin = pw[1]
|
@@ -137,13 +153,9 @@ class ExecApp
|
|
137
153
|
# wait for done in yet another thread
|
138
154
|
Thread.new do
|
139
155
|
@threads.each {|t| t.join }
|
140
|
-
|
141
|
-
s = "OK"
|
142
|
-
else
|
143
|
-
s = "ERROR"
|
144
|
-
end
|
145
|
-
@observer.call("DONE.#{s}", @id, "status: #{@exit_status}")
|
156
|
+
call_observer("EXIT", @exit_status)
|
146
157
|
end
|
158
|
+
logger.debug "Application is running with PID #{@pid}"
|
147
159
|
end
|
148
160
|
|
149
161
|
private
|
@@ -160,12 +172,10 @@ class ExecApp
|
|
160
172
|
begin
|
161
173
|
while true do
|
162
174
|
s = pipe.readline.chomp
|
163
|
-
|
164
|
-
@observer.call(name.to_s.upcase, @id, s)
|
175
|
+
call_observer(name.to_s.upcase, s)
|
165
176
|
end
|
166
177
|
rescue EOFError
|
167
178
|
# do nothing
|
168
|
-
#puts "++++ STOP MONITORING #{name}"
|
169
179
|
rescue => err
|
170
180
|
logger.error "monitorApp(#{@id}): #{err}"
|
171
181
|
logger.debug "#{err}\n\t#{err.backtrace.join("\n\t")}"
|
@@ -174,4 +184,14 @@ class ExecApp
|
|
174
184
|
end
|
175
185
|
end
|
176
186
|
end
|
187
|
+
|
188
|
+
def call_observer(event_type, msg)
|
189
|
+
return unless @observer
|
190
|
+
begin
|
191
|
+
@observer.call(event_type, @id, msg)
|
192
|
+
rescue Exception => ex
|
193
|
+
logger.warn "Exception while calling observer '#{@observer}': #{ex}"
|
194
|
+
logger.debug "#{ex}\n\t#{ex.backtrace.join("\n\t")}"
|
195
|
+
end
|
196
|
+
end
|
177
197
|
end
|
data/lib/omf_common/key.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'openssl'
|
2
7
|
require 'singleton'
|
3
8
|
|
data/lib/omf_common/measure.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'oml4r'
|
2
7
|
module OmfCommon
|
3
8
|
class Measure
|
data/lib/omf_common/message.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
module OmfCommon
|
2
7
|
|
3
8
|
class MPMessage < OML4R::MPBase
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
|
2
7
|
require 'json'
|
3
8
|
require 'omf_common/auth'
|
@@ -18,10 +23,13 @@ module OmfCommon
|
|
18
23
|
|
19
24
|
def self.create(type, properties, body = {})
|
20
25
|
if type == :request
|
21
|
-
unless properties.kind_of?(Array)
|
26
|
+
unless (req_props = properties).kind_of?(Array)
|
22
27
|
raise "Expected array, but got #{properties.class} for request message"
|
23
28
|
end
|
24
|
-
properties = {select: properties}
|
29
|
+
#properties = {select: properties}
|
30
|
+
properties = {}
|
31
|
+
req_props.each {|n| properties[n] = nil }
|
32
|
+
|
25
33
|
elsif not properties.kind_of?(Hash)
|
26
34
|
raise "Expected hash, but got #{properties.class}"
|
27
35
|
end
|
@@ -89,8 +97,8 @@ module OmfCommon
|
|
89
97
|
return nil
|
90
98
|
end
|
91
99
|
|
92
|
-
unless cert
|
93
|
-
warn "JWT: Invalid certificate '#{cert.to_s}', NOT signed by
|
100
|
+
unless OmfCommon::Auth::CertificateStore.instance.verify(cert)
|
101
|
+
warn "JWT: Invalid certificate '#{cert.to_s}', NOT signed by CA certs, or its CA cert NOT loaded into cert store."
|
94
102
|
end
|
95
103
|
|
96
104
|
#puts ">>> #{cert.to_x509.public_key}::#{signature_base_string}"
|
@@ -170,7 +178,7 @@ module OmfCommon
|
|
170
178
|
#puts "MARSHALL: #{@content.inspect} - #{@properties.to_hash.inspect}"
|
171
179
|
raise "Missing SRC declaration in #{@content}" unless @content[:src]
|
172
180
|
if @content[:src].is_a? OmfCommon::Comm::Topic
|
173
|
-
@content[:src] = @content[:src].
|
181
|
+
@content[:src] = @content[:src].address
|
174
182
|
end
|
175
183
|
#raise 'local/local' if @content[:src].id.match 'local:/local'
|
176
184
|
#puts @content.inspect
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'niceogiri'
|
2
7
|
require 'hashie'
|
3
8
|
require 'securerandom'
|
@@ -71,8 +76,13 @@ class XML
|
|
71
76
|
cert = OmfCommon::Auth::CertificateStore.instance.cert_for(iss)
|
72
77
|
end
|
73
78
|
|
74
|
-
|
75
|
-
warn "
|
79
|
+
if cert.nil?
|
80
|
+
warn "Missing certificate of '#{iss}'"
|
81
|
+
return nil
|
82
|
+
end
|
83
|
+
|
84
|
+
unless OmfCommon::Auth::CertificateStore.instance.verify(cert)
|
85
|
+
warn "Invalid certificate '#{cert.to_s}', NOT signed by CA certs, or its CA cert NOT loaded into cert store."
|
76
86
|
return nil
|
77
87
|
end
|
78
88
|
|
@@ -83,6 +93,11 @@ class XML
|
|
83
93
|
return nil
|
84
94
|
end
|
85
95
|
end
|
96
|
+
else
|
97
|
+
if self.authenticate?
|
98
|
+
debug "Message not signed: '#{xml}'"
|
99
|
+
return nil
|
100
|
+
end
|
86
101
|
end
|
87
102
|
|
88
103
|
parsed_msg = self.create(xml_node.name.to_sym).tap do |message|
|
@@ -158,7 +173,7 @@ class XML
|
|
158
173
|
#end
|
159
174
|
['text/xml', @envelope]
|
160
175
|
else
|
161
|
-
error "Missing cert for #{src}"
|
176
|
+
error "Missing cert for #{src}. Auth turned on but could not locate a proper cert."
|
162
177
|
['text/xml', nil]
|
163
178
|
end
|
164
179
|
else
|
@@ -328,7 +343,7 @@ class XML
|
|
328
343
|
|
329
344
|
# Reconstruct xml node into Ruby object
|
330
345
|
#
|
331
|
-
# @param [Niceogiri::XML::Node]
|
346
|
+
# @param [Niceogiri::XML::Node] node xml node
|
332
347
|
# @return [Object] the content of the property, as string, integer, float, or mash(hash with indifferent access)
|
333
348
|
def reconstruct_data(node, data_binding = nil)
|
334
349
|
node_type = node.attr('type')
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'singleton'
|
2
7
|
|
3
8
|
module OmfCommon
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
# module OmfCommon
|
2
7
|
# class TopicMessage
|
3
8
|
# attr_accessor :body, :comm
|
data/lib/omf_common/version.rb
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
module OmfCommon
|
2
|
-
VERSION = "6.0.2
|
7
|
+
VERSION = "6.0.2"
|
3
8
|
PROTOCOL_VERSION = "6.0"
|
4
9
|
end
|
data/omf_common.gemspec
CHANGED
@@ -27,11 +27,12 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.add_development_dependency "pry"
|
28
28
|
s.add_development_dependency "mocha"
|
29
29
|
|
30
|
-
s.add_runtime_dependency "eventmachine", "
|
31
|
-
s.add_runtime_dependency "blather", "= 0.8.
|
30
|
+
s.add_runtime_dependency "eventmachine", "= 1.0.3"
|
31
|
+
s.add_runtime_dependency "blather", "= 0.8.4"
|
32
32
|
s.add_runtime_dependency "logging", "~> 1.7.1"
|
33
33
|
s.add_runtime_dependency "hashie", "~> 1.2.0"
|
34
34
|
s.add_runtime_dependency "oml4r", "~> 2.9.1"
|
35
|
+
s.add_runtime_dependency "json", "~> 1.7.7"
|
35
36
|
#s.add_runtime_dependency "json-jwt", "~> 0.5.2"
|
36
37
|
#s.add_runtime_dependency "amqp", "~> 1.0.1"
|
37
38
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIDBDCCAm2gAwIBAgIJANcH4kPmdM2jMA0GCSqGSIb3DQEBBQUAMGAxCzAJBgNV
|
3
|
+
BAYTAkFVMQwwCgYDVQQIEwNOU1cxDzANBgNVBAcTBlN5ZG5leTEOMAwGA1UEChMF
|
4
|
+
TklDVEExEDAOBgNVBAMTB1JPT1QgQ0ExEDAOBgkqhkiG9w0BCQEWASAwHhcNMTMw
|
5
|
+
NTAxMDg0NTU3WhcNMjMwNDI5MDg0NTU3WjBgMQswCQYDVQQGEwJBVTEMMAoGA1UE
|
6
|
+
CBMDTlNXMQ8wDQYDVQQHEwZT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w0BCQEWASCCAQEwDQYJKoZIhvcNAQEEBQADgYEAjz4HM8BrKhwNBMPZ066b
|
16
|
+
p/0FdpmrPpZhFR4UJqLZD6fqnHDAKwZZs8UFYqLrIkgkNNOkIMA0LYRaCCYFC19m
|
17
|
+
yjEeBlQ0dPFgGApJwcZ6tvuhyWXhAnTDCFIbgsdU2MHPl0ccpaPHRMpOPIuu1T9B
|
18
|
+
uE55figSibhihtqzAelHJE4=
|
19
|
+
-----END CERTIFICATE-----
|
data/test/fixture/pubsub.rb
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
def affiliations_xml
|
2
7
|
<<-NODE
|
3
8
|
<iq type='result'
|
data/test/fixture/rc.pem
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
2
|
+
MIIC2DCCAcCgAwIBAgIBAzANBgkqhkiG9w0BAQUFADAkMSIwIAYDVQQDDBlmcmNw
|
3
|
+
Ly9vbWYvL2ZyY3AuY2Eub21mX2NhMB4XDTEzMDQyNDAzMzQyM1oXDTEzMDQyNDAz
|
4
|
+
NDAyOFowKDEmMCQGA1UEAwwdZnJjcC8vb21mLy9mcmNwLmNvbnRyb2xsZXIucmMw
|
5
|
+
ggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDRJZSSENhtqWoPdupdB5AS
|
6
|
+
QFyq+m8LyxslAdSIdrFhB9hA9vpma8w4oUGtiTdfehqP2UzkM/35WeFzU9deuwvV
|
7
|
+
ayQqWEKUU5oPprquWCR+tFNsgSNZWghmB5B3mKxpRFbIAwKOu3SmHzMedf1oe1k3
|
8
|
+
paOmZjjsq8SIp3oPo8FToTxyARQ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LLdOBUrSG/Tw/TWl3NhDGLjplwI1puaTIl
|
7
|
+
sOCqi3mh/VVPN4e4b+riDVJD/Wdvj7278aVisy74cvF+IwQj1puDhD5K1eC9UcZ+
|
8
|
+
sv8CcQj+DR2u7GMHxbLwAcou74R+cWiFyXwFjrSDqC6neQ/BpCWwM0Gm/OAV5WX0
|
9
|
+
inBBKBYvn/5RTfDLKatLKjaLWuduQWRJz1Qe7phrXRFJABXQCy/5q9qRG/fsLzPu
|
10
|
+
6+puqtfo5OBYbZlrRVsZCP7Nv8CKibi5AoEFR4MdAIjLaXbbdFjWPg7DdQcCAwEA
|
11
|
+
ATANBgkqhkiG9w0BAQUFAAOCAQEAUaiWcrWEhSb9TgJ5FmUz+kf8y10q6ai7cYoP
|
12
|
+
Tg5oBJqpIZbV2cPL//MtnHLvFmlGN8JCTaqOBGhnmErtm9jaeUBkSVidM03JUy6b
|
13
|
+
HAYz90GH53hR7x+2TedYus3C2oQqZbKgXsBhzIzqMpXewLAIIyEXUq7kLeOQWUok
|
14
|
+
jrA8jS/VAnJ0/TNIlkeCttPab3DTdzI0Eo1r+juH86jnCOoz6MjSt9krZNPHxLoD
|
15
|
+
7HLy+TvJAvdfMs+1WvPMEAaNGynrtg9/74bod8CGajYbPLtMysA+a7+S6GeOl/y4
|
16
|
+
RxI1DK2kvXlEZEWsguuiFUYZk6CMyKNTT2fTiGAiLFmSFO2Rxg==
|
17
|
+
-----END CERTIFICATE-----
|
@@ -1,3 +1,8 @@
|
|
1
|
+
# Copyright (c) 2012 National ICT Australia Limited (NICTA).
|
2
|
+
# This software may be used and distributed solely under the terms of the MIT license (License).
|
3
|
+
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
|
4
|
+
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
|
5
|
+
|
1
6
|
require 'test_helper'
|
2
7
|
|
3
8
|
describe OmfCommon::Auth::Certificate do
|
@@ -46,6 +51,16 @@ describe OmfCommon::Auth::Certificate do
|
|
46
51
|
@entity.verify_cert.must_equal true
|
47
52
|
end
|
48
53
|
|
54
|
+
it "must be verified successfully by using X509 cert store" do
|
55
|
+
store = OpenSSL::X509::Store.new
|
56
|
+
store.add_cert(@root.to_x509)
|
57
|
+
|
58
|
+
@entity = @root.create_for('my_addr', 'bob', 'my_resource', 'omf')
|
59
|
+
|
60
|
+
store.verify(@root.to_x509).must_equal true
|
61
|
+
store.verify(@entity.to_x509).must_equal true
|
62
|
+
end
|
63
|
+
|
49
64
|
it "must verify cert validity" do
|
50
65
|
@root.verify_cert.must_equal true
|
51
66
|
@root.create_for('my_addr', 'bob', 'my_resource', 'omf').verify_cert.must_equal true
|
@@ -93,6 +108,18 @@ describe OmfCommon::Auth::Certificate do
|
|
93
108
|
test_entity.can_sign?.must_equal false
|
94
109
|
test_entity.verify_cert.must_equal true
|
95
110
|
end
|
111
|
+
|
112
|
+
it "must generate a cert from SSH key too" do
|
113
|
+
private_folder = "#{File.dirname(__FILE__)}/../../fixture"
|
114
|
+
ssh_pub_key = File.read("#{private_folder}/omf_test.pub")
|
115
|
+
pub_key = OpenSSL::PKey::RSA.new(File.read("#{private_folder}/omf_test.pub.pem"))
|
116
|
+
lambda do
|
117
|
+
test_entity = @root.create_for('my_addr', 'bob', 'my_resource', 'omf', 365, 'bob')
|
118
|
+
end.must_raise ArgumentError
|
119
|
+
|
120
|
+
test_entity = @root.create_for('my_addr', 'bob', 'my_resource', 'omf', 365, ssh_pub_key)
|
121
|
+
test_entity.to_x509.public_key.to_s.must_equal pub_key.to_s
|
122
|
+
end
|
96
123
|
end
|
97
124
|
|
98
125
|
describe "when provided an existing public cert and I have a private key associated" do
|