foreman_omaha 3.0.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -1
  3. data/app/controllers/api/v2/omaha_groups_controller.rb +2 -0
  4. data/app/controllers/api/v2/omaha_reports_controller.rb +2 -0
  5. data/app/controllers/omaha_groups_controller.rb +2 -0
  6. data/app/controllers/omaha_hosts_controller.rb +2 -0
  7. data/app/controllers/omaha_reports_controller.rb +2 -0
  8. data/app/graphql/types/omaha_group.rb +15 -0
  9. data/app/graphql/types/omaha_report.rb +15 -0
  10. data/app/graphql/types/omaha_report_status_enum.rb +9 -0
  11. data/app/helpers/concerns/foreman_omaha/hosts_helper_extensions.rb +2 -0
  12. data/app/helpers/foreman_omaha/application_helper.rb +2 -0
  13. data/app/helpers/foreman_omaha/omaha_groups_helper.rb +2 -0
  14. data/app/helpers/omaha_hosts_helper.rb +2 -0
  15. data/app/helpers/omaha_reports_helper.rb +2 -0
  16. data/app/lib/foreman_omaha/renderer/scope/macros/omaha.rb +2 -0
  17. data/app/models/concerns/foreman_omaha/host_extensions.rb +3 -1
  18. data/app/models/concerns/foreman_omaha/omaha_facet_host_extensions.rb +2 -0
  19. data/app/models/foreman_omaha/fact_name.rb +2 -0
  20. data/app/models/foreman_omaha/omaha_facet.rb +2 -0
  21. data/app/models/foreman_omaha/omaha_group.rb +4 -0
  22. data/app/models/foreman_omaha/omaha_report.rb +4 -0
  23. data/app/models/host_status/omaha_status.rb +2 -0
  24. data/app/services/foreman_omaha/charts/oem_distribution.rb +2 -0
  25. data/app/services/foreman_omaha/charts/status_distribution.rb +2 -0
  26. data/app/services/foreman_omaha/charts/version_distribution.rb +2 -0
  27. data/app/services/foreman_omaha/container_linux_config_transpiler.rb +2 -0
  28. data/app/services/foreman_omaha/fact_importer.rb +2 -0
  29. data/app/services/foreman_omaha/fact_parser.rb +11 -3
  30. data/app/services/foreman_omaha/group_version_breakdown.rb +2 -0
  31. data/app/services/foreman_omaha/omaha_report_importer.rb +2 -0
  32. data/app/services/foreman_omaha/status_mapper.rb +2 -2
  33. data/app/views/api/v2/omaha_groups/base.json.rabl +2 -0
  34. data/app/views/api/v2/omaha_groups/index.json.rabl +2 -0
  35. data/app/views/api/v2/omaha_groups/main.json.rabl +2 -0
  36. data/app/views/api/v2/omaha_groups/show.json.rabl +2 -0
  37. data/app/views/api/v2/omaha_reports/base.json.rabl +2 -0
  38. data/app/views/api/v2/omaha_reports/create.json.rabl +2 -0
  39. data/app/views/api/v2/omaha_reports/index.json.rabl +2 -0
  40. data/app/views/api/v2/omaha_reports/main.json.rabl +2 -0
  41. data/app/views/api/v2/omaha_reports/show.json.rabl +2 -0
  42. data/app/views/api/v2/omaha_reports/update.json.rabl +2 -0
  43. data/app/views/foreman_omaha/api/v2/omaha_facets/base.json.rabl +2 -0
  44. data/app/views/foreman_omaha/api/v2/omaha_facets/base_with_root.json.rabl +2 -0
  45. data/app/views/foreman_omaha/api/v2/omaha_facets/show.json.rabl +2 -0
  46. data/app/views/omaha_reports/_list.html.erb +1 -1
  47. data/config/routes.rb +2 -0
  48. data/db/migrate/20160812083100_add_omaha_fields_to_reports.foreman_omaha.rb +2 -0
  49. data/db/migrate/20171101204100_create_omaha_facets.foreman_omaha.rb +2 -0
  50. data/db/seeds.d/200_omaha_groups.rb +2 -0
  51. data/db/seeds.d/60_omaha_proxy_feature.rb +2 -0
  52. data/lib/foreman_omaha.rb +2 -0
  53. data/lib/foreman_omaha/engine.rb +24 -8
  54. data/lib/foreman_omaha/version.rb +3 -1
  55. data/lib/tasks/foreman_omaha_tasks.rake +2 -0
  56. data/locale/gemspec.rb +2 -0
  57. data/test/factories/feature.rb +3 -1
  58. data/test/factories/foreman_omaha_factories.rb +8 -6
  59. data/test/factories/host.rb +19 -4
  60. data/test/factories/smart_proxy.rb +2 -0
  61. data/test/functional/api/v2/omaha_groups_controller_test.rb +2 -0
  62. data/test/functional/api/v2/omaha_reports_controller_test.rb +3 -1
  63. data/test/functional/omaha_groups_controller_test.rb +2 -0
  64. data/test/functional/omaha_hosts_controller_test.rb +2 -0
  65. data/test/functional/omaha_reports_controller_test.rb +2 -0
  66. data/test/graphql/queries/host_query_extensions_test.rb +41 -0
  67. data/test/graphql/queries/omaha_group_query_test.rb +51 -0
  68. data/test/graphql/queries/omaha_groups_query_test.rb +47 -0
  69. data/test/graphql/queries/omaha_report_query_test.rb +44 -0
  70. data/test/graphql/queries/omaha_reports_query_test.rb +47 -0
  71. data/test/test_plugin_helper.rb +2 -0
  72. data/test/unit/charts/oem_distribution_test.rb +2 -0
  73. data/test/unit/charts/status_distribution_test.rb +2 -0
  74. data/test/unit/charts/version_distribution_test.rb +2 -0
  75. data/test/unit/group_version_breakdown_test.rb +2 -0
  76. data/test/unit/host_status/omaha_status_test.rb +4 -2
  77. data/test/unit/host_test.rb +2 -0
  78. data/test/unit/omaha_fact_parser_test.rb +45 -11
  79. data/test/unit/omaha_report_test.rb +2 -0
  80. data/test/unit/renderer_test.rb +2 -0
  81. metadata +62 -7
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_plugin_helper'
4
+
5
+ module Queries
6
+ class OmahaReportsQueryTest < GraphQLQueryTestCase
7
+ let(:query) do
8
+ <<-GRAPHQL
9
+ query omahaReportsQuery {
10
+ omahaReports {
11
+ totalCount
12
+ pageInfo {
13
+ startCursor
14
+ endCursor
15
+ hasNextPage
16
+ hasPreviousPage
17
+ }
18
+ edges {
19
+ cursor
20
+ node {
21
+ id
22
+ status
23
+ omahaVersion
24
+ }
25
+ }
26
+ }
27
+ }
28
+ GRAPHQL
29
+ end
30
+
31
+ let(:data) { result['data']['omahaReports'] }
32
+
33
+ setup do
34
+ FactoryBot.create_list(:omaha_report, 2)
35
+ end
36
+
37
+ test 'fetching omaha reports attributes' do
38
+ assert_empty result['errors']
39
+
40
+ expected_count = ForemanOmaha::OmahaReport.count
41
+
42
+ assert_not_equal 0, expected_count
43
+ assert_equal expected_count, data['totalCount']
44
+ assert_equal expected_count, data['edges'].count
45
+ end
46
+ end
47
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This calls the main test_helper in Foreman-core
2
4
  require 'test_helper'
3
5
  require 'database_cleaner'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  module ForemanOmaha
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  module ForemanOmaha
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  module ForemanOmaha
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  class CurrentVersionBreakdownTest < ActiveSupport::TestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  class OmahaStatusTest < ActiveSupport::TestCase
@@ -10,10 +12,10 @@ class OmahaStatusTest < ActiveSupport::TestCase
10
12
  end
11
13
 
12
14
  test '#relevant? is only for hosts with an omaha facet' do
13
- assert_equal true, status.relevant?
15
+ assert status.relevant?
14
16
 
15
17
  status.host = FactoryBot.build_stubbed(:host)
16
18
 
17
- assert_equal false, status.relevant?
19
+ assert_not status.relevant?
18
20
  end
19
21
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  class HostTest < ActiveSupport::TestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  class OmahaFactsParserTest < ActiveSupport::TestCase
@@ -19,7 +21,8 @@ class OmahaFactsParserTest < ActiveSupport::TestCase
19
21
  'osminor' => '9.0',
20
22
  'ipaddress' => '127.0.0.1',
21
23
  'ipaddress6' => '',
22
- 'hostname' => 'client.example.com'
24
+ 'hostname' => 'client.example.com',
25
+ 'distribution' => 'coreos'
23
26
  }
24
27
  end
25
28
  let(:importer) { ::ForemanOmaha::FactParser.new(facts) }
@@ -36,16 +39,47 @@ class OmahaFactsParserTest < ActiveSupport::TestCase
36
39
  context '#operatingsystem' do
37
40
  let(:os) { importer.operatingsystem }
38
41
 
39
- test 'should return an OS with correct params' do
40
- assert_kind_of Operatingsystem, os
41
- assert_equal '1068', os.major
42
- assert_equal '9.0', os.minor
43
- assert_equal 'CoreOS', os.name
44
- assert_equal 'CoreOS 1068.9.0', os.description
45
- assert_equal 'stable', os.release_name
46
- assert_empty os.ptables
47
- assert_empty os.media
48
- assert_empty os.os_default_templates
42
+ context 'without distribution fact' do
43
+ setup do
44
+ facts.delete('distribution')
45
+ end
46
+
47
+ test 'should return an OS with correct params' do
48
+ assert_equal 'CoreOS', os.name
49
+ assert_equal 'CoreOS 1068.9.0', os.description
50
+ end
51
+ end
52
+
53
+ context 'CoreOS' do
54
+ test 'should return an OS with correct params' do
55
+ assert_kind_of Operatingsystem, os
56
+ assert_equal '1068', os.major
57
+ assert_equal '9.0', os.minor
58
+ assert_equal 'CoreOS', os.name
59
+ assert_equal 'CoreOS 1068.9.0', os.description
60
+ assert_equal 'stable', os.release_name
61
+ assert_empty os.ptables
62
+ assert_empty os.media
63
+ assert_empty os.os_default_templates
64
+ end
65
+ end
66
+
67
+ context 'Flatcar' do
68
+ setup do
69
+ facts['distribution'] = 'flatcar'
70
+ end
71
+
72
+ test 'should return an OS with correct params' do
73
+ assert_kind_of Operatingsystem, os
74
+ assert_equal '1068', os.major
75
+ assert_equal '9.0', os.minor
76
+ assert_equal 'Flatcar', os.name
77
+ assert_equal 'Flatcar 1068.9.0', os.description
78
+ assert_equal 'stable', os.release_name
79
+ assert_empty os.ptables
80
+ assert_empty os.media
81
+ assert_empty os.os_default_templates
82
+ end
49
83
  end
50
84
 
51
85
  context 'with old versions' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  class OmahaReportTest < ActiveSupport::TestCase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_plugin_helper'
2
4
 
3
5
  module ForemanOmaha
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_omaha
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.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: 2018-11-29 00:00:00.000000000 Z
11
+ date: 2020-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jquery-matchheight-rails
@@ -42,16 +42,58 @@ dependencies:
42
42
  name: rubocop
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.59.2
47
+ version: 0.80.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.59.2
54
+ version: 0.80.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.7.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.7.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-performance
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.5.2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.5.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop-rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 2.4.2
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 2.4.2
55
97
  description: This plug-in adds support for the Omaha procotol to The Foreman. It allows
56
98
  you to better manage and update your CoreOS servers.
57
99
  email:
@@ -71,6 +113,9 @@ files:
71
113
  - app/controllers/omaha_groups_controller.rb
72
114
  - app/controllers/omaha_hosts_controller.rb
73
115
  - app/controllers/omaha_reports_controller.rb
116
+ - app/graphql/types/omaha_group.rb
117
+ - app/graphql/types/omaha_report.rb
118
+ - app/graphql/types/omaha_report_status_enum.rb
74
119
  - app/helpers/concerns/foreman_omaha/hosts_helper_extensions.rb
75
120
  - app/helpers/foreman_omaha/application_helper.rb
76
121
  - app/helpers/foreman_omaha/omaha_groups_helper.rb
@@ -139,6 +184,11 @@ files:
139
184
  - test/functional/omaha_groups_controller_test.rb
140
185
  - test/functional/omaha_hosts_controller_test.rb
141
186
  - test/functional/omaha_reports_controller_test.rb
187
+ - test/graphql/queries/host_query_extensions_test.rb
188
+ - test/graphql/queries/omaha_group_query_test.rb
189
+ - test/graphql/queries/omaha_groups_query_test.rb
190
+ - test/graphql/queries/omaha_report_query_test.rb
191
+ - test/graphql/queries/omaha_reports_query_test.rb
142
192
  - test/test_plugin_helper.rb
143
193
  - test/unit/charts/oem_distribution_test.rb
144
194
  - test/unit/charts/status_distribution_test.rb
@@ -169,7 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
219
  version: '0'
170
220
  requirements: []
171
221
  rubyforge_project:
172
- rubygems_version: 2.7.3
222
+ rubygems_version: 2.7.6.2
173
223
  signing_key:
174
224
  specification_version: 4
175
225
  summary: This plug-in adds support for the Omaha procotol to The Foreman.
@@ -183,6 +233,11 @@ test_files:
183
233
  - test/unit/host_status/omaha_status_test.rb
184
234
  - test/unit/renderer_test.rb
185
235
  - test/unit/omaha_report_test.rb
236
+ - test/graphql/queries/omaha_group_query_test.rb
237
+ - test/graphql/queries/omaha_report_query_test.rb
238
+ - test/graphql/queries/omaha_groups_query_test.rb
239
+ - test/graphql/queries/omaha_reports_query_test.rb
240
+ - test/graphql/queries/host_query_extensions_test.rb
186
241
  - test/factories/smart_proxy.rb
187
242
  - test/factories/feature.rb
188
243
  - test/factories/host.rb