smart_proxy_omaha 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4a6708a296e67836993cc8002728a630e3eb1aa3
4
- data.tar.gz: 2d1a008d27a6500d01cf0f286d2de64c0a87ed47
2
+ SHA256:
3
+ metadata.gz: de92f226437fa125e5902abdbaeb331847d8155397c2cf1808c353d04c3b0d6f
4
+ data.tar.gz: a270d730e518668d7239588599f99cf5d6c860c3ca0ca048ec4400fef1c3c8e8
5
5
  SHA512:
6
- metadata.gz: 1242a70477fb372e90003aae5d9b1efdc0cb081da403e1ef95f03d58cbe447c0b494ca0eff0829d2ad6ac6a6906ff4e599a236f719cdf9caa7777f4440db382b
7
- data.tar.gz: ccd486cf864f01b2ac4d76c72ea901de33399a03fd6aeb1a0b8fc6cff8125da562b4aa2c48d44f9c47caeb51ac0c17d615a2f33e030f79cd51d3d2eb20930022
6
+ metadata.gz: 4103c51a5cab4583fd5ac2310de72d7cd79510ce83996d899a8887f1c3cc196ee6334f2965d0b45355a9eb2d95f14039c10e8abe01bd11338dab9ba3c78045ad
7
+ data.tar.gz: c7bcc7867a4000af179765219cce24ac5e4d0cfed6882089ddd54171ccc2f026e00d5c89a08b1ba727d48a91dea806db9dec0a384cf09976d514e8e38d4a51a0
data/Gemfile CHANGED
@@ -7,16 +7,28 @@ group :development do
7
7
  end
8
8
 
9
9
  group :test do
10
- gem 'rack-test'
11
10
  gem 'single_test'
12
11
  gem 'test_xml'
13
12
 
14
- if RUBY_VERSION < '1.9.3'
15
- gem 'webmock', '< 2.0.0'
13
+ if RUBY_VERSION < '2.1'
14
+ gem 'public_suffix', '< 3'
15
+ gem 'nokogiri', '< 1.7'
16
16
  else
17
- gem 'webmock'
17
+ gem 'public_suffix'
18
+ gem 'nokogiri'
19
+ end
20
+
21
+ if RUBY_VERSION < '2.2'
22
+ gem 'rack-test', '< 0.8'
23
+ else
24
+ gem 'rack-test'
18
25
  end
19
26
  end
20
27
 
21
- gem 'addressable', '< 2.2.0', :platforms => :ruby_18
22
- gem 'json', '~> 1.0', :platforms => [:ruby_18, :ruby_19]
28
+ if RUBY_VERSION < '2.2'
29
+ gem 'sinatra', '< 2'
30
+ gem 'rack', '>= 1.1', '< 2.0.0'
31
+ else
32
+ gem 'sinatra'
33
+ gem 'rack', '>= 1.1'
34
+ end
@@ -86,7 +86,10 @@ module Proxy::Omaha::OmahaProtocol
86
86
  'host' => request.hostname,
87
87
  'status' => request.to_status.to_s,
88
88
  'omaha_version' => request.version,
89
- 'reported_at' => Time.now.getutc.to_s
89
+ 'machineid' => request.machineid,
90
+ 'omaha_group' => request.track,
91
+ 'oem' => request.oem,
92
+ 'reported_at' => report_timestamp
90
93
  }
91
94
  foreman_client.post_report({'omaha_report' => report}.to_json)
92
95
  end
@@ -109,5 +112,9 @@ module Proxy::Omaha::OmahaProtocol
109
112
  )
110
113
  end
111
114
  end
115
+
116
+ def report_timestamp
117
+ Time.now.getutc.to_s
118
+ end
112
119
  end
113
120
  end
@@ -4,7 +4,7 @@ require 'ipaddr'
4
4
  module Proxy::Omaha::OmahaProtocol
5
5
  class Request
6
6
  attr_reader :appid, :version, :track, :updatecheck, :eventtype, :eventresult, :board,
7
- :alephversion, :oemversion, :oem,
7
+ :alephversion, :oemversion, :oem, :machineid,
8
8
  :platform, :osmajor, :osminor, :hostname, :ipaddress, :ipaddress6,
9
9
  :body, :ip, :base_url, :ping
10
10
 
@@ -63,6 +63,7 @@ module Proxy::Omaha::OmahaProtocol
63
63
  def parse_request
64
64
  xml_request = Nokogiri::XML(body)
65
65
  @appid = xml_request.xpath('/request/app/@appid').to_s.tr('{}', '')
66
+ @machineid = xml_request.xpath('/request/app/@machineid').to_s
66
67
  @version = xml_request.xpath('/request/app/@version').to_s
67
68
  @osmajor = version.gsub(/^(\d+)\.\d\.\d$/, '\1')
68
69
  @osminor = version.gsub(/^\d+\.(\d\.\d)$/, '\1')
@@ -83,6 +84,7 @@ module Proxy::Omaha::OmahaProtocol
83
84
  def parse_ipaddress
84
85
  ipaddr = IPAddr.new(ip) rescue nil
85
86
  return if ipaddr.nil?
87
+ ipaddr = IPAddr.new(ipaddr.to_s.sub('::ffff:', '')) if ipaddr.ipv4_mapped?
86
88
  @ipaddress = ipaddr.to_s if ipaddr.ipv4?
87
89
  @ipaddress6 = ipaddr.to_s if ipaddr.ipv6?
88
90
  @hostname = lookup_hostname(ipaddr.to_s)
@@ -108,7 +110,8 @@ module Proxy::Omaha::OmahaProtocol
108
110
  :osminor => osminor,
109
111
  :ipaddress => ipaddress,
110
112
  :ipaddress6 => ipaddress6,
111
- :hostname => hostname
113
+ :hostname => hostname,
114
+ :machineid => machineid
112
115
  }
113
116
  end
114
117
  end
@@ -1,5 +1,5 @@
1
1
  module Proxy
2
2
  module Omaha
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
5
5
  end
@@ -16,14 +16,16 @@ Gem::Specification.new do |s|
16
16
 
17
17
  if RUBY_VERSION < '1.9'
18
18
  s.add_dependency('nokogiri', '<= 1.5.11')
19
+ elsif RUBY_VERSION < '2.1'
20
+ s.add_dependency('nokogiri', '>= 1.5.11')
19
21
  else
20
- s.add_dependency('nokogiri', '>= 1.5.10')
22
+ s.add_dependency('nokogiri', '>= 1.8.1')
21
23
  end
22
24
  s.add_dependency('json')
23
25
 
24
26
  s.add_development_dependency('test-unit', '~> 2')
25
27
  s.add_development_dependency('mocha', '~> 1')
26
28
  s.add_development_dependency('webmock', '~> 1')
27
- s.add_development_dependency('rack-test', '~> 0')
29
+ s.add_development_dependency('rack-test')
28
30
  s.add_development_dependency('rake', '~> 10')
29
31
  end
@@ -1,7 +1,7 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <request protocol="3.0" version="CoreOSUpdateEngine-0.1.0.0" updaterversion="CoreOSUpdateEngine-0.1.0.0" installsource="ondemandupdate" ismachine="1">
3
3
  <os version="Chateau" platform="CoreOS" sp="1122.2.0_x86_64"></os>
4
- <app appid="{e96281a6-d1af-4bde-9a0a-97b76e56dc57}" version="1122.2.0" track="stable" bootid="{5c43ee37-70da-48b7-9328-636618c2807c}" oem="" oemversion="" alephversion="1010.5.0" machineid="8e9450f47a4c47adbfe48b946e201c84" lang="en-US" board="amd64-usr" hardware_class="" delta_okay="false" >
4
+ <app appid="{e96281a6-d1af-4bde-9a0a-97b76e56dc57}" version="1122.2.0" track="stable" bootid="{5c43ee37-70da-48b7-9328-636618c2807c}" oem="vmware" oemversion="10.1.10" alephversion="1010.5.0" machineid="8e9450f47a4c47adbfe48b946e201c84" lang="en-US" board="amd64-usr" hardware_class="" delta_okay="false" >
5
5
  <ping active="1"></ping>
6
6
  <updatecheck></updatecheck>
7
7
  <event eventtype="3" eventresult="2" previousversion=""></event>
@@ -5,8 +5,25 @@ require 'smart_proxy_omaha/omaha_plugin'
5
5
  ENV['RACK_ENV'] = 'test'
6
6
 
7
7
  class TestForemanClient
8
- def post_facts(factsdata); end
9
- def post_report(report); end
8
+ @@requests = {}
9
+
10
+ def self.requests
11
+ @@requests
12
+ end
13
+
14
+ def self.clear_requests
15
+ @@requests = {}
16
+ end
17
+
18
+ def post_facts(factsdata)
19
+ @@requests[:facts] ||= []
20
+ @@requests[:facts] << JSON.parse(factsdata)
21
+ end
22
+
23
+ def post_report(report)
24
+ @@requests[:reports] ||= []
25
+ @@requests[:reports] << JSON.parse(report)
26
+ end
10
27
  end
11
28
 
12
29
  class TestReleaseRepository
@@ -70,10 +87,28 @@ class OmahaApiTest < Test::Unit::TestCase
70
87
  Proxy::Omaha::Api.new
71
88
  end
72
89
 
90
+ def setup
91
+ TestForemanClient.clear_requests
92
+ end
93
+
73
94
  def test_processes_update_complete_noupdate
95
+ Proxy::Omaha::OmahaProtocol::Handler.any_instance.stubs(:report_timestamp).returns('fake_timestamp')
74
96
  post "/v1/update", xml_fixture('request_update_complete_noupdate')
75
97
  assert last_response.ok?, "Last response was not ok: #{last_response.status} #{last_response.body}"
76
98
  assert_xml_equal xml_fixture('response_update_complete_noupdate'), last_response.body
99
+ assert_equal [
100
+ {
101
+ 'omaha_report' => {
102
+ 'host' => 'localhost',
103
+ 'status' => 'complete',
104
+ 'omaha_version' => '1122.2.0',
105
+ 'machineid' => '8e9450f47a4c47adbfe48b946e201c84',
106
+ 'omaha_group' => 'stable',
107
+ 'oem' => 'vmware',
108
+ 'reported_at' => 'fake_timestamp'
109
+ }
110
+ }
111
+ ], TestForemanClient.requests[:reports]
77
112
  end
78
113
 
79
114
  def test_processes_update_complete_update
@@ -22,6 +22,7 @@ class RequestTest < Test::Unit::TestCase
22
22
  assert_equal '', @request.oemversion
23
23
  assert_equal '', @request.oem
24
24
  assert_equal 'CoreOS', @request.platform
25
+ assert_equal '8e9450f47a4c47adbfe48b946e201c84', @request.machineid
25
26
  assert_equal 3, @request.eventtype
26
27
  assert_equal 2, @request.eventresult
27
28
  assert @request.updatecheck
@@ -46,6 +47,7 @@ class RequestTest < Test::Unit::TestCase
46
47
  :hostname => 'omaha.example.com',
47
48
  :ipaddress => '1.1.1.1',
48
49
  :ipaddress6 => nil,
50
+ :machineid => '8e9450f47a4c47adbfe48b946e201c84',
49
51
  :oem => '',
50
52
  :oemversion => '',
51
53
  :osmajor => '1068',
@@ -77,5 +79,14 @@ class RequestTest < Test::Unit::TestCase
77
79
 
78
80
  assert_nil request6.ipaddress
79
81
  assert_equal '2001:db8::1', request6.ipaddress6
82
+
83
+ request64 = Proxy::Omaha::OmahaProtocol::Request.new(
84
+ xml_fixture('request_update_complete_update'),
85
+ :ip => '::ffff:1.1.1.1',
86
+ :base_url => 'http://www.example.org/'
87
+ )
88
+
89
+ assert_equal '1.1.1.1', request64.ipaddress
90
+ assert_nil request64.ipaddress6
80
91
  end
81
92
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_proxy_omaha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Timo Goebel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-23 00:00:00.000000000 Z
11
+ date: 2018-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.5.10
19
+ version: 1.8.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.5.10
26
+ version: 1.8.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: json
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -84,14 +84,14 @@ dependencies:
84
84
  name: rack-test
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  version: '0'
197
197
  requirements: []
198
198
  rubyforge_project:
199
- rubygems_version: 2.6.12
199
+ rubygems_version: 2.7.3
200
200
  signing_key:
201
201
  specification_version: 4
202
202
  summary: Omaha protocol support for smart-proxy