foreman_rh_cloud 7.0.46 → 8.0.46

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
2
  SHA256:
3
- metadata.gz: 1383b077fcadc72b19517f0ed1173aec5ac958a207e8b04a6119e91b75b062c0
4
- data.tar.gz: 98783f069cfd8cbc89e2a295b0433437ec3d88b168ccef7c2b7c42b851d07929
3
+ metadata.gz: 8db662f6cd6809ba5dd5b183ec76330b4a1d4eb6db931136c8e34dcdf53c796c
4
+ data.tar.gz: e410219ca7fcbd0555d157f05123cc7c7618b29531157de42a3e3413d9d96eb4
5
5
  SHA512:
6
- metadata.gz: 711977116c1b74dfd5b528bf7298df5f9c5da3dda6f63a788ed4ea8f82e76b62139d5d4417b4af19ca3e564e0764d99cc38ca30a496b1f78fd170829fef11017
7
- data.tar.gz: 78f1a3584c4eea9f64d49cf4be866cd41074e04264c860d22332205124c312c62372cde26435e1e4bfe7303a7574754cbab3f49e3f1c3a31a6abe65c4363890c
6
+ metadata.gz: 601501b2ec41be00150bbc9797ad9fe7c93a92aea619ca1781ef3df88224e3f6fb04b2c16e2c2e974832ef67926794108d3c8f2c7654d52056e25a218887cd55
7
+ data.tar.gz: 6a7ca4b57eb655c5d4c3a880f0deac4af3f86c6a4b71ddd4ff02b7adc4aa9bf5c0cb2a70731f5472ce763b841a75f755835e0674d489c6b5d51759ee9d1c85f3
@@ -45,11 +45,9 @@ module ForemanInventoryUpload
45
45
  end
46
46
 
47
47
  def content_data
48
- [
49
- ['lifecycle_environment', @host.lifecycle_environment&.name],
50
- ['content_view', @host.content_view&.name],
51
- ] +
52
- (@host.activation_keys || []).map { |item| ['activation_key', item.name] }
48
+ (@host.lifecycle_environments.uniq || []).map { |item| ['lifecycle_environment', item.name] } +
49
+ (@host.activation_keys || []).map { |item| ['activation_key', item.name] } +
50
+ (@host.content_views || []).map { |item| ['content_view', item.name] }
53
51
  end
54
52
 
55
53
  def satellite_server_data
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '7.0.46'.freeze
2
+ VERSION = '8.0.46'.freeze
3
3
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foreman_rh_cloud",
3
- "version": "7.0.46",
3
+ "version": "8.0.46",
4
4
  "description": "Inventory Upload =============",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -110,7 +110,7 @@ module InsightsCloud::Api
110
110
  User.current = User.find_by(login: 'secret_admin')
111
111
 
112
112
  @env = FactoryBot.create(:katello_k_t_environment)
113
- cv = @env.content_views << FactoryBot.create(:katello_content_view, organization: @env.organization)
113
+ @env2 = FactoryBot.create(:katello_k_t_environment, organization: @env.organization)
114
114
 
115
115
  @host = FactoryBot.create(
116
116
  :host,
@@ -118,8 +118,16 @@ module InsightsCloud::Api
118
118
  :with_content,
119
119
  :with_hostgroup,
120
120
  :with_parameter,
121
- content_view: cv.first,
122
- lifecycle_environment: @env,
121
+ content_view_environments: [
122
+ FactoryBot.create(
123
+ :katello_content_view_environment,
124
+ content_view: FactoryBot.create(:katello_content_view, organization: @env.organization),
125
+ lifecycle_environment: @env),
126
+ FactoryBot.create(
127
+ :katello_content_view_environment,
128
+ content_view: FactoryBot.create(:katello_content_view, organization: @env.organization),
129
+ lifecycle_environment: @env2),
130
+ ],
123
131
  organization: @env.organization
124
132
  )
125
133
 
@@ -33,6 +33,13 @@ FactoryBot.define do
33
33
  end
34
34
  end
35
35
 
36
+ FactoryBot.define do
37
+ factory :katello_content_view_environment, :class => Katello::ContentViewEnvironment do
38
+ sequence(:name) { |n| "name#{n}" }
39
+ sequence(:label) { |n| "label#{n}" }
40
+ end
41
+ end
42
+
36
43
  FactoryBot.define do
37
44
  factory :katello_k_t_environment, :aliases => [:katello_environment], :class => Katello::KTEnvironment do
38
45
  sequence(:name) { |n| "Environment#{n}" }
@@ -93,6 +100,7 @@ FactoryBot.modify do
93
100
  content_view { nil }
94
101
  lifecycle_environment { nil }
95
102
  content_source { nil }
103
+ content_view_environments { [] }
96
104
  end
97
105
 
98
106
  trait :with_content do
@@ -100,9 +108,14 @@ FactoryBot.modify do
100
108
 
101
109
  after(:build) do |host, evaluator|
102
110
  if host.content_facet
103
- host.content_facet.content_view = evaluator.content_view if evaluator.content_view
104
- host.content_facet.lifecycle_environment = evaluator.lifecycle_environment if evaluator.lifecycle_environment
111
+ if evaluator.content_view && evaluator.lifecycle_environment
112
+ host.content_facet.assign_single_environment(
113
+ content_view_id: evaluator.content_view.id,
114
+ lifecycle_environment_id: evaluator.lifecycle_environment.id
115
+ )
116
+ end
105
117
  host.content_facet.content_source = evaluator.content_source if evaluator.content_source
118
+ host.content_facet.content_view_environments = evaluator.content_view_environments unless evaluator.content_view_environments.empty?
106
119
  end
107
120
  end
108
121
  end
@@ -8,6 +8,12 @@ FactoryBot.definition_file_paths << File.join(File.dirname(__FILE__), 'factories
8
8
  # FactoryBot.definition_file_paths << "#{Katello::Engine.root}/test/factories"
9
9
  FactoryBot.reload
10
10
 
11
+ begin
12
+ require 'pry-rescue/minitest'
13
+ rescue LoadError
14
+ # if the extension is not loaded - please continue, no harm done.
15
+ end
16
+
11
17
  module FolderIsolation
12
18
  extend ActiveSupport::Concern
13
19
 
@@ -30,7 +30,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
30
30
  subscription: FactoryBot.create(:katello_subscription, organization_id: env.organization.id)
31
31
  )
32
32
  @host.interfaces.first.identifier = 'test_nic1'
33
- @host.save!
33
+ @host.interfaces.first.save!
34
34
 
35
35
  ForemanInventoryUpload::Generators::Queries.instance_variable_set(:@fact_names, nil)
36
36
  end
@@ -300,6 +300,11 @@ class SliceGeneratorTest < ActiveSupport::TestCase
300
300
 
301
301
  test 'generates a report with satellite facts' do
302
302
  hostgroup = FactoryBot.create(:hostgroup, name: 'Special"name')
303
+ # Don't try to update CP in tests
304
+ Katello::Resources::Candlepin::Consumer.stubs(:update)
305
+ # Don't try update facts for the host
306
+ Katello::Host::SubscriptionFacet.stubs(:update_facts)
307
+
303
308
  @host.hostgroup = hostgroup
304
309
  @host.save!
305
310
 
@@ -326,7 +331,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
326
331
  actual_host = actual['hosts'].first
327
332
  assert_tag('satellite-id', actual_host, 'satellite_instance_id')
328
333
  assert_tag(@host.organization_id.to_s, actual_host, 'organization_id')
329
- assert_tag(@host.content_view.name, actual_host, 'content_view')
334
+ assert_tag(@host.content_views.first.name, actual_host, 'content_view')
330
335
  assert_tag(@host.location.name, actual_host, 'location')
331
336
  assert_tag(@host.organization.name, actual_host, 'organization')
332
337
  assert_tag(@host.hostgroup.name, actual_host, 'hostgroup')
@@ -348,13 +353,13 @@ class SliceGeneratorTest < ActiveSupport::TestCase
348
353
  :host,
349
354
  :with_subscription,
350
355
  :with_content,
351
- content_view: @host.content_view,
352
- lifecycle_environment: @host.lifecycle_environment,
356
+ content_view: @host.content_views.first,
357
+ lifecycle_environment: @host.lifecycle_environments.first,
353
358
  organization: @host.organization
354
359
  )
355
360
 
356
361
  @host.subscription_facet.hypervisor_host = hypervisor_host
357
- @host.save!
362
+ @host.subscription_facet.save!
358
363
 
359
364
  batch = Host.where(id: @host.id).in_batches.first
360
365
  generator = create_generator(batch)
@@ -497,8 +502,8 @@ class SliceGeneratorTest < ActiveSupport::TestCase
497
502
  :host,
498
503
  :with_subscription,
499
504
  :with_content,
500
- content_view: @host.content_view,
501
- lifecycle_environment: @host.lifecycle_environment,
505
+ content_view: @host.content_views.first,
506
+ lifecycle_environment: @host.lifecycle_environments.first,
502
507
  organization: new_org
503
508
  )
504
509
 
@@ -644,8 +649,8 @@ class SliceGeneratorTest < ActiveSupport::TestCase
644
649
  :host,
645
650
  :with_subscription,
646
651
  :with_content,
647
- content_view: @host.content_view,
648
- lifecycle_environment: @host.lifecycle_environment,
652
+ content_view: @host.content_views.first,
653
+ lifecycle_environment: @host.lifecycle_environments.first,
649
654
  organization: @host.organization,
650
655
  installed_packages: [installed_package]
651
656
  )
@@ -7,7 +7,7 @@ class TagsGeneratorTest < ActiveSupport::TestCase
7
7
  User.current = User.find_by(login: 'secret_admin')
8
8
 
9
9
  env = FactoryBot.create(:katello_k_t_environment)
10
- cv = env.content_views << FactoryBot.create(:katello_content_view, organization: env.organization)
10
+ env2 = FactoryBot.create(:katello_k_t_environment, organization: env.organization)
11
11
 
12
12
  @location1 = FactoryBot.create(:location)
13
13
  @location2 = FactoryBot.create(:location, parent: @location1)
@@ -20,15 +20,27 @@ class TagsGeneratorTest < ActiveSupport::TestCase
20
20
  :redhat,
21
21
  :with_subscription,
22
22
  :with_content,
23
- content_view: cv.first,
24
- lifecycle_environment: env,
25
23
  organization: env.organization,
26
24
  location: @location2,
27
- hostgroup: @hostgroup2
25
+ hostgroup: @hostgroup2,
26
+ content_view_environments: [
27
+ FactoryBot.create(
28
+ :katello_content_view_environment,
29
+ content_view: FactoryBot.create(:katello_content_view, organization: env.organization),
30
+ lifecycle_environment: env),
31
+ FactoryBot.create(
32
+ :katello_content_view_environment,
33
+ content_view: FactoryBot.create(:katello_content_view, organization: env.organization),
34
+ lifecycle_environment: env2),
35
+ ]
28
36
  )
29
37
 
30
38
  @host.organization.pools << FactoryBot.create(:katello_pool, account_number: '1234', cp_id: 1)
31
39
  @host.interfaces.first.identifier = 'test_nic1'
40
+ # Don't try to update CP in tests
41
+ Katello::Resources::Candlepin::Consumer.stubs(:update)
42
+ # Don't try update facts for the host
43
+ Katello::Host::SubscriptionFacet.stubs(:update_facts)
32
44
  @host.save!
33
45
  end
34
46
 
@@ -46,8 +58,10 @@ class TagsGeneratorTest < ActiveSupport::TestCase
46
58
  assert_nil actual['host collection']
47
59
 
48
60
  assert_equal @host.organization.name, actual['organization'].first.last
49
- assert_equal @host.lifecycle_environment.name, actual['lifecycle_environment'].first.last
50
- assert_equal @host.content_view.name, actual['content_view'].first.last
61
+ assert_equal @host.lifecycle_environments.pluck(:name).min, actual['lifecycle_environment'].map(&:second).min
62
+ assert_equal @host.lifecycle_environments.pluck(:name).max, actual['lifecycle_environment'].map(&:second).max
63
+ assert_equal @host.content_views.pluck(:name).min, actual['content_view'].map(&:second).min
64
+ assert_equal @host.content_views.pluck(:name).max, actual['content_view'].map(&:second).max
51
65
  assert_equal Foreman.instance_id, actual['satellite_instance_id'].first.last
52
66
  assert_equal @host.organization_id.to_s, actual['organization_id'].first.last
53
67
  end
@@ -55,7 +69,7 @@ class TagsGeneratorTest < ActiveSupport::TestCase
55
69
  test 'filters tags with empty values' do
56
70
  generator = create_generator
57
71
 
58
- @host.stubs(:content_view)
72
+ @host.stubs(:content_views).returns([])
59
73
 
60
74
  actual = generator.generate.group_by { |key, value| key }
61
75
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_rh_cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.46
4
+ version: 8.0.46
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Red Hat Cloud team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-12 00:00:00.000000000 Z
11
+ date: 2023-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: katello