smart_proxy_omaha 0.0.5 → 0.1.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 +10 -1
- data/lib/smart_proxy_omaha/configuration_loader.rb +10 -1
- data/lib/smart_proxy_omaha/distribution.rb +82 -0
- data/lib/smart_proxy_omaha/omaha_api.rb +9 -1
- data/lib/smart_proxy_omaha/omaha_plugin.rb +8 -1
- data/lib/smart_proxy_omaha/omaha_protocol/handler.rb +2 -1
- data/lib/smart_proxy_omaha/omaha_protocol/request.rb +4 -2
- data/lib/smart_proxy_omaha/omaha_protocol/updateresponse.rb +1 -1
- data/lib/smart_proxy_omaha/plugin_validators.rb +11 -0
- data/lib/smart_proxy_omaha/release.rb +22 -14
- data/lib/smart_proxy_omaha/release_provider.rb +7 -15
- data/lib/smart_proxy_omaha/release_repository.rb +12 -3
- data/lib/smart_proxy_omaha/syncer.rb +7 -1
- data/lib/smart_proxy_omaha/track.rb +1 -1
- data/lib/smart_proxy_omaha/version.rb +1 -1
- data/settings.d/omaha.yml.example +1 -0
- data/smart_proxy_omaha.gemspec +2 -2
- data/test/fixtures/ca.crt +3 -0
- data/test/fixtures/flatcar_releases-stable.json +1077 -0
- data/test/omaha/omaha_api_test.rb +19 -0
- data/test/omaha/omaha_protocol/request_test.rb +7 -3
- data/test/omaha/release_provider_test.rb +27 -7
- data/test/omaha/release_repository_test.rb +3 -5
- data/test/omaha/release_test.rb +6 -0
- metadata +9 -5
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require 'smart_proxy_omaha/configuration_loader'
|
3
3
|
require 'smart_proxy_omaha/omaha_plugin'
|
4
|
+
require 'smart_proxy_omaha/distribution'
|
4
5
|
|
5
6
|
ENV['RACK_ENV'] = 'test'
|
6
7
|
|
@@ -30,6 +31,7 @@ class TestReleaseRepository
|
|
30
31
|
def releases(track, architecture)
|
31
32
|
['1068.9.0', '1122.2.0'].map do |release|
|
32
33
|
Proxy::Omaha::Release.new(
|
34
|
+
:distribution => ::Proxy::Omaha::Distribution::Coreos.new,
|
33
35
|
:track => 'alpha',
|
34
36
|
:architecture => 'amd64-usr',
|
35
37
|
:version => release
|
@@ -73,6 +75,9 @@ module Proxy::Omaha
|
|
73
75
|
c.singleton_dependency :foreman_client_impl, TestForemanClient
|
74
76
|
c.singleton_dependency :release_repository_impl, TestReleaseRepository
|
75
77
|
c.singleton_dependency :metadata_provider_impl, TestMetadataProvider
|
78
|
+
c.singleton_dependency :distribution_impl, (lambda do
|
79
|
+
::Proxy::Omaha::Distribution::Coreos.new
|
80
|
+
end)
|
76
81
|
end
|
77
82
|
end
|
78
83
|
end
|
@@ -151,4 +156,18 @@ class OmahaApiTest < Test::Unit::TestCase
|
|
151
156
|
assert_kind_of Array, parsed
|
152
157
|
assert_equal ['1068.9.0', '1122.2.0'], parsed.map { |track| track['name'] }
|
153
158
|
end
|
159
|
+
|
160
|
+
def test_ca
|
161
|
+
Proxy::SETTINGS.stubs(:ssl_ca_file).returns(File.expand_path('../../fixtures/ca.crt', __FILE__))
|
162
|
+
get '/ca'
|
163
|
+
assert last_response.ok?, "Last response was not ok: #{last_response.status} #{last_response.body}"
|
164
|
+
body = last_response.body
|
165
|
+
assert_includes body, 'CERTIFICATE'
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_ca_not_found
|
169
|
+
Proxy::SETTINGS.stubs(:ssl_ca_file).returns(File.expand_path('../../fixtures/noca.crt', __FILE__))
|
170
|
+
get '/ca'
|
171
|
+
assert_equal 404, last_response.status
|
172
|
+
end
|
154
173
|
end
|
@@ -8,7 +8,8 @@ class RequestTest < Test::Unit::TestCase
|
|
8
8
|
@request = Proxy::Omaha::OmahaProtocol::Request.new(
|
9
9
|
xml_fixture('request_update_complete_update'),
|
10
10
|
:ip => '1.1.1.1',
|
11
|
-
:base_url => 'http://www.example.org/'
|
11
|
+
:base_url => 'http://www.example.org/',
|
12
|
+
:distribution => 'coreos'
|
12
13
|
)
|
13
14
|
end
|
14
15
|
|
@@ -44,6 +45,7 @@ class RequestTest < Test::Unit::TestCase
|
|
44
45
|
:alephversion => '1010.5.0',
|
45
46
|
:appid => 'e96281a6-d1af-4bde-9a0a-97b76e56dc57',
|
46
47
|
:board => 'amd64-usr',
|
48
|
+
:distribution => 'coreos',
|
47
49
|
:hostname => 'omaha.example.com',
|
48
50
|
:ipaddress => '1.1.1.1',
|
49
51
|
:ipaddress6 => nil,
|
@@ -74,7 +76,8 @@ class RequestTest < Test::Unit::TestCase
|
|
74
76
|
request6 = Proxy::Omaha::OmahaProtocol::Request.new(
|
75
77
|
xml_fixture('request_update_complete_update'),
|
76
78
|
:ip => '2001:db8::1',
|
77
|
-
:base_url => 'http://www.example.org/'
|
79
|
+
:base_url => 'http://www.example.org/',
|
80
|
+
:distribution => 'coreos'
|
78
81
|
)
|
79
82
|
|
80
83
|
assert_nil request6.ipaddress
|
@@ -83,7 +86,8 @@ class RequestTest < Test::Unit::TestCase
|
|
83
86
|
request64 = Proxy::Omaha::OmahaProtocol::Request.new(
|
84
87
|
xml_fixture('request_update_complete_update'),
|
85
88
|
:ip => '::ffff:1.1.1.1',
|
86
|
-
:base_url => 'http://www.example.org/'
|
89
|
+
:base_url => 'http://www.example.org/',
|
90
|
+
:distribution => 'coreos'
|
87
91
|
)
|
88
92
|
|
89
93
|
assert_equal '1.1.1.1', request64.ipaddress
|
@@ -1,15 +1,19 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require 'smart_proxy_omaha/release'
|
3
3
|
require 'smart_proxy_omaha/release_provider'
|
4
|
+
require 'smart_proxy_omaha/distribution'
|
4
5
|
|
5
6
|
class ReleaseProviderTest < Test::Unit::TestCase
|
6
|
-
def
|
7
|
-
|
8
|
-
|
7
|
+
def test_releases_coreos
|
8
|
+
distribution = ::Proxy::Omaha::Distribution::Coreos.new
|
9
|
+
provider = Proxy::Omaha::ReleaseProvider.new(
|
10
|
+
distribution: distribution,
|
11
|
+
track: :stable,
|
12
|
+
architecture: 'amd64-usr'
|
13
|
+
)
|
9
14
|
|
10
|
-
|
11
|
-
|
12
|
-
to_return(:status => [200, 'OK'], :body => fixture('stable.html'))
|
15
|
+
stub_request(:get, 'https://stable.release.core-os.net/amd64-usr/')
|
16
|
+
.to_return(status: [200, 'OK'], body: fixture('stable.html'))
|
13
17
|
|
14
18
|
expected = ['367.1.0',
|
15
19
|
'410.0.0',
|
@@ -54,6 +58,22 @@ class ReleaseProviderTest < Test::Unit::TestCase
|
|
54
58
|
'1068.10.0',
|
55
59
|
'1122.2.0']
|
56
60
|
|
57
|
-
assert_equal expected.map {|v| Proxy::Omaha::Release.new(:track
|
61
|
+
assert_equal expected.map { |v| Proxy::Omaha::Release.new(distribution: distribution, track: provider.track, version: v, architecture: 'amd64-usr') }, provider.releases
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_releases_flatcar
|
65
|
+
distribution = ::Proxy::Omaha::Distribution::Flatcar.new
|
66
|
+
provider = Proxy::Omaha::ReleaseProvider.new(
|
67
|
+
track: :stable,
|
68
|
+
architecture: 'amd64-usr',
|
69
|
+
distribution: distribution
|
70
|
+
)
|
71
|
+
|
72
|
+
stub_request(:get, 'https://www.flatcar-linux.org/releases-json/releases-stable.json')
|
73
|
+
.to_return(status: [200, 'OK'], body: fixture('flatcar_releases-stable.json'))
|
74
|
+
|
75
|
+
expected = ['1688.5.3', '1745.3.1', '1745.4.0', '1745.5.0', '1745.6.0', '1745.7.0', '1800.4.0', '1800.5.0', '1800.6.0', '1800.7.0', '1855.4.0', '1855.4.2', '1855.5.0', '1911.3.0', '1911.4.0', '1911.5.0', '1967.3.0', '1967.3.1', '1967.4.0', '1967.5.0', '1967.6.0', '2023.4.0', '2023.5.0', '2079.3.0', '2079.3.1', '2079.3.2', '2079.4.0', '2079.5.0', '2079.6.0', '2135.4.0', '2135.5.0', '2135.6.0', '2191.4.0', '2191.4.1', '2191.5.0', '2247.5.0', '2247.6.0', '2247.7.0', '2303.3.0', '2303.3.1', '2303.4.0', '2345.3.0']
|
76
|
+
|
77
|
+
assert_equal expected.map { |v| Proxy::Omaha::Release.new(distribution: distribution, track: provider.track, version: v, architecture: 'amd64-usr') }, provider.releases
|
58
78
|
end
|
59
79
|
end
|
@@ -5,12 +5,10 @@ require 'smart_proxy_omaha/release_repository'
|
|
5
5
|
class ReleaseRepositoryTest < Test::Unit::TestCase
|
6
6
|
def setup
|
7
7
|
@contentpath = Dir.mktmpdir
|
8
|
-
Proxy::Omaha::
|
9
|
-
|
10
|
-
|
11
|
-
}
|
8
|
+
@repository = Proxy::Omaha::ReleaseRepository.new(
|
9
|
+
:contentpath => @contentpath,
|
10
|
+
:distribution => ::Proxy::Omaha::Distribution::Coreos.new
|
12
11
|
)
|
13
|
-
@repository = Proxy::Omaha::ReleaseRepository.new
|
14
12
|
end
|
15
13
|
|
16
14
|
def teardown
|
data/test/omaha/release_test.rb
CHANGED
@@ -2,6 +2,7 @@ require 'test_helper'
|
|
2
2
|
require 'fileutils'
|
3
3
|
require 'tmpdir'
|
4
4
|
require 'smart_proxy_omaha/release'
|
5
|
+
require 'smart_proxy_omaha/distribution'
|
5
6
|
|
6
7
|
class ReleaseTest < Test::Unit::TestCase
|
7
8
|
|
@@ -13,6 +14,7 @@ class ReleaseTest < Test::Unit::TestCase
|
|
13
14
|
}
|
14
15
|
)
|
15
16
|
@release = Proxy::Omaha::Release.new(
|
17
|
+
:distribution => ::Proxy::Omaha::Distribution::Coreos.new,
|
16
18
|
:track => :stable,
|
17
19
|
:architecture => 'amd64-usr',
|
18
20
|
:version => '1068.9.0'
|
@@ -56,11 +58,13 @@ class ReleaseTest < Test::Unit::TestCase
|
|
56
58
|
|
57
59
|
def test_compare
|
58
60
|
older = Proxy::Omaha::Release.new(
|
61
|
+
:distribution => ::Proxy::Omaha::Distribution::Coreos.new,
|
59
62
|
:track => :stable,
|
60
63
|
:architecture => 'amd64-usr',
|
61
64
|
:version => '100.0.0'
|
62
65
|
)
|
63
66
|
newer = Proxy::Omaha::Release.new(
|
67
|
+
:distribution => ::Proxy::Omaha::Distribution::Coreos.new,
|
64
68
|
:track => :stable,
|
65
69
|
:architecture => 'amd64-usr',
|
66
70
|
:version => '2000.0.0'
|
@@ -72,6 +76,7 @@ class ReleaseTest < Test::Unit::TestCase
|
|
72
76
|
|
73
77
|
def test_equality
|
74
78
|
other = Proxy::Omaha::Release.new(
|
79
|
+
:distribution => ::Proxy::Omaha::Distribution::Coreos.new,
|
75
80
|
:track => :stable,
|
76
81
|
:architecture => 'amd64-usr',
|
77
82
|
:version => '100.0.0'
|
@@ -152,6 +157,7 @@ class ReleaseTest < Test::Unit::TestCase
|
|
152
157
|
def test_current_release_update
|
153
158
|
FileUtils.mkdir_p(@release.path)
|
154
159
|
older = Proxy::Omaha::Release.new(
|
160
|
+
:distribution => ::Proxy::Omaha::Distribution::Coreos.new,
|
155
161
|
:track => :stable,
|
156
162
|
:architecture => 'amd64-usr',
|
157
163
|
:version => '100.0.0'
|
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
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Timo Goebel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- lib/smart_proxy_omaha.rb
|
128
128
|
- lib/smart_proxy_omaha/configuration_loader.rb
|
129
129
|
- lib/smart_proxy_omaha/dependency_injection.rb
|
130
|
+
- lib/smart_proxy_omaha/distribution.rb
|
130
131
|
- lib/smart_proxy_omaha/foreman_client.rb
|
131
132
|
- lib/smart_proxy_omaha/http_download.rb
|
132
133
|
- lib/smart_proxy_omaha/http_request.rb
|
@@ -146,6 +147,7 @@ files:
|
|
146
147
|
- lib/smart_proxy_omaha/omaha_protocol/request.rb
|
147
148
|
- lib/smart_proxy_omaha/omaha_protocol/response.rb
|
148
149
|
- lib/smart_proxy_omaha/omaha_protocol/updateresponse.rb
|
150
|
+
- lib/smart_proxy_omaha/plugin_validators.rb
|
149
151
|
- lib/smart_proxy_omaha/release.rb
|
150
152
|
- lib/smart_proxy_omaha/release_provider.rb
|
151
153
|
- lib/smart_proxy_omaha/release_repository.rb
|
@@ -154,6 +156,8 @@ files:
|
|
154
156
|
- lib/smart_proxy_omaha/version.rb
|
155
157
|
- settings.d/omaha.yml.example
|
156
158
|
- smart_proxy_omaha.gemspec
|
159
|
+
- test/fixtures/ca.crt
|
160
|
+
- test/fixtures/flatcar_releases-stable.json
|
157
161
|
- test/fixtures/request_ping.xml
|
158
162
|
- test/fixtures/request_update_complete_error.xml
|
159
163
|
- test/fixtures/request_update_complete_noupdate.xml
|
@@ -176,9 +180,9 @@ files:
|
|
176
180
|
- test/omaha/syncer_test.rb
|
177
181
|
- test/omaha/track_test.rb
|
178
182
|
- test/test_helper.rb
|
179
|
-
homepage:
|
183
|
+
homepage: https://github.com/theforeman/smart_proxy_omaha
|
180
184
|
licenses:
|
181
|
-
-
|
185
|
+
- GPL-3.0
|
182
186
|
metadata: {}
|
183
187
|
post_install_message:
|
184
188
|
rdoc_options: []
|
@@ -196,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
200
|
version: '0'
|
197
201
|
requirements: []
|
198
202
|
rubyforge_project:
|
199
|
-
rubygems_version: 2.7.
|
203
|
+
rubygems_version: 2.7.6.2
|
200
204
|
signing_key:
|
201
205
|
specification_version: 4
|
202
206
|
summary: Omaha protocol support for smart-proxy
|