foreman_bootdisk 18.1.0 → 19.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/foreman_bootdisk/disks_controller.rb +49 -2
  3. data/config/routes.rb +1 -0
  4. data/db/migrate/20140522185700_change_templatekind_to_bootdisk.rb +6 -7
  5. data/lib/foreman_bootdisk/engine.rb +4 -2
  6. data/lib/foreman_bootdisk/version.rb +1 -1
  7. data/locale/ca/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  8. data/locale/ca/foreman_bootdisk.edit.po +393 -0
  9. data/locale/ca/foreman_bootdisk.po +7 -1
  10. data/locale/ca/foreman_bootdisk.po.time_stamp +0 -0
  11. data/locale/de/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  12. data/locale/de/foreman_bootdisk.edit.po +398 -0
  13. data/locale/de/foreman_bootdisk.po +7 -1
  14. data/locale/de/foreman_bootdisk.po.time_stamp +0 -0
  15. data/locale/en/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  16. data/locale/en/foreman_bootdisk.edit.po +388 -0
  17. data/locale/en/foreman_bootdisk.po +7 -1
  18. data/locale/en/foreman_bootdisk.po.time_stamp +0 -0
  19. data/locale/en_GB/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  20. data/locale/en_GB/foreman_bootdisk.edit.po +394 -0
  21. data/locale/en_GB/foreman_bootdisk.po +7 -1
  22. data/locale/en_GB/foreman_bootdisk.po.time_stamp +0 -0
  23. data/locale/es/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  24. data/locale/es/foreman_bootdisk.edit.po +394 -0
  25. data/locale/es/foreman_bootdisk.po +7 -1
  26. data/locale/es/foreman_bootdisk.po.time_stamp +0 -0
  27. data/locale/foreman_bootdisk.pot +27 -14
  28. data/locale/fr/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  29. data/locale/fr/foreman_bootdisk.edit.po +394 -0
  30. data/locale/fr/foreman_bootdisk.po +7 -1
  31. data/locale/fr/foreman_bootdisk.po.time_stamp +0 -0
  32. data/locale/it/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  33. data/locale/it/foreman_bootdisk.edit.po +391 -0
  34. data/locale/it/foreman_bootdisk.po +7 -1
  35. data/locale/it/foreman_bootdisk.po.time_stamp +0 -0
  36. data/locale/ja/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  37. data/locale/ja/foreman_bootdisk.edit.po +393 -0
  38. data/locale/ja/foreman_bootdisk.po +12 -6
  39. data/locale/ja/foreman_bootdisk.po.time_stamp +0 -0
  40. data/locale/ko/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  41. data/locale/ko/foreman_bootdisk.edit.po +390 -0
  42. data/locale/ko/foreman_bootdisk.po +7 -1
  43. data/locale/ko/foreman_bootdisk.po.time_stamp +0 -0
  44. data/locale/pt_BR/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  45. data/locale/pt_BR/foreman_bootdisk.edit.po +394 -0
  46. data/locale/pt_BR/foreman_bootdisk.po +7 -1
  47. data/locale/pt_BR/foreman_bootdisk.po.time_stamp +0 -0
  48. data/locale/ru/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  49. data/locale/ru/foreman_bootdisk.edit.po +395 -0
  50. data/locale/ru/foreman_bootdisk.po +7 -1
  51. data/locale/ru/foreman_bootdisk.po.time_stamp +0 -0
  52. data/locale/sv_SE/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  53. data/locale/sv_SE/foreman_bootdisk.edit.po +392 -0
  54. data/locale/sv_SE/foreman_bootdisk.po +7 -1
  55. data/locale/sv_SE/foreman_bootdisk.po.time_stamp +0 -0
  56. data/locale/zh_CN/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  57. data/locale/zh_CN/foreman_bootdisk.edit.po +391 -0
  58. data/locale/zh_CN/foreman_bootdisk.po +12 -6
  59. data/locale/zh_CN/foreman_bootdisk.po.time_stamp +0 -0
  60. data/locale/zh_TW/LC_MESSAGES/foreman_bootdisk.mo +0 -0
  61. data/locale/zh_TW/foreman_bootdisk.edit.po +391 -0
  62. data/locale/zh_TW/foreman_bootdisk.po +7 -1
  63. data/locale/zh_TW/foreman_bootdisk.po.time_stamp +0 -0
  64. data/package.json +42 -0
  65. data/webpack/__mocks__/foremanReact/common/HOC.js +30 -0
  66. data/webpack/__mocks__/foremanReact/common/I18n.js +7 -0
  67. data/webpack/__mocks__/foremanReact/common/helpers.js +7 -0
  68. data/webpack/__mocks__/foremanReact/common/urlHelpers.js +8 -0
  69. data/webpack/__mocks__/foremanReact/constants.js +24 -0
  70. data/webpack/__mocks__/foremanReact/redux/API/APISelectors.js +6 -0
  71. data/webpack/__mocks__/foremanReact/redux/API/index.js +10 -0
  72. data/webpack/global_index.js +12 -0
  73. data/webpack/global_test_setup.js +11 -0
  74. data/webpack/index.js +0 -0
  75. data/webpack/src/extensions/constants.js +2 -0
  76. data/webpack/src/extensions/host/HostBootdiskButtons.js +71 -0
  77. data/webpack/src/extensions/host/HostBootdiskButtonsSelectors.js +27 -0
  78. data/webpack/src/extensions/host/__tests__/HostBootdiskButtonsSelectors.test.js +66 -0
  79. data/webpack/src/extensions/host/__tests__/__snapshots__/HostBootdiskButtonsSelectors.test.js.snap +30 -0
  80. metadata +47 -21
  81. data/.github/workflows/rubocop.yaml +0 -19
  82. data/.tx/config +0 -8
  83. data/AUTHORS +0 -34
  84. data/release-gem +0 -84
  85. data/test/functional/foreman_bootdisk/api/v2/disks_controller_test.rb +0 -97
  86. data/test/functional/foreman_bootdisk/api/v2/subnet_disks_controller_test.rb +0 -37
  87. data/test/functional/foreman_bootdisk/disks_controller_test.rb +0 -97
  88. data/test/functional/foreman_bootdisk/subnet_disks_controller_test.rb +0 -51
  89. data/test/models/host/managed_test.rb +0 -26
  90. data/test/test_plugin_helper.rb +0 -72
  91. data/test/unit/access_permissions_test.rb +0 -10
  92. data/test/unit/concerns/compute_resources/vmware_test.rb +0 -83
  93. data/test/unit/concerns/host_test.rb +0 -84
  94. data/test/unit/concerns/orchestration/compute_test.rb +0 -69
  95. data/test/unit/foreman_bootdisk/renderer_test.rb +0 -36
  96. data/test/unit/foreman_bootdisk/scope/bootdisk_test.rb +0 -31
  97. data/test/unit/foreman_bootdisk/scope/full_host_bootdisk_test.rb +0 -30
  98. data/test/unit/iso_generator_test.rb +0 -74
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_plugin_helper'
4
-
5
- module Host
6
- class ManagedTest < ActiveSupport::TestCase
7
- include ForemanBootdiskTestHelper
8
-
9
- setup do
10
- User.current = users(:admin)
11
- setup_bootdisk
12
- end
13
-
14
- context 'with host' do
15
- let(:host) { FactoryBot.create(:host, :managed, :with_subnet, build: true) }
16
-
17
- test 'finds the bootdisk_template specified in settings' do
18
- assert_kind_of ProvisioningTemplate, host.bootdisk_template
19
- end
20
-
21
- test 'renders the host bootdisk template' do
22
- assert_includes host.bootdisk_template_render, 'loop_success'
23
- end
24
- end
25
- end
26
- end
@@ -1,72 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- require 'webmock/minitest'
5
- require 'webmock'
6
-
7
- module ForemanBootdiskTestHelper
8
- def create_tempfile
9
- file = Tempfile.new('bootdisk-test', '/tmp')
10
- file.close
11
- file
12
- end
13
-
14
- def setup_bootdisk
15
- ForemanBootdisk::Scope::Bootdisk.any_instance.stubs(:bootdisk_chain_url).returns('http://smart-proxy.example.com/unattended/iPXE?mac=')
16
- setup_routes
17
- setup_settings
18
- setup_templates
19
- end
20
-
21
- # TODO remove me
22
- def setup_host_env
23
- setup_org_loc
24
- setup_subnet_with_tftp
25
- setup_host
26
- end
27
-
28
- def setup_routes
29
- @routes = ForemanBootdisk::Engine.routes
30
- end
31
-
32
- def setup_settings
33
- Setting::Bootdisk.load_defaults
34
- end
35
-
36
- def setup_templates
37
- load File.join(File.dirname(__FILE__), '..', 'db', 'seeds.d', '50-bootdisk_templates.rb')
38
- end
39
-
40
- def setup_referer
41
- request.env['HTTP_REFERER'] = '/history'
42
- end
43
-
44
- def setup_org_loc
45
- disable_orchestration
46
- @org = FactoryBot.create(:organization)
47
- @loc = FactoryBot.create(:location)
48
- end
49
-
50
- def setup_subnet_with_tftp_httpboot_template
51
- ProxyAPI::V2::Features.any_instance.stubs(:features).returns(:httpboot => { :settings => { :https_port => 1234 }, :state => 'running' }, :templates => {}, :tftp => {})
52
- SmartProxy.any_instance.stubs(:httpboot_http_port).returns('8888')
53
- SmartProxy.any_instance.stubs(:httpboot_https_port).returns('9999')
54
-
55
- proxy = FactoryBot.create(:smart_proxy, features: [FactoryBot.create(:tftp_feature), FactoryBot.create(:feature, :templates), FactoryBot.create(:feature, :httpboot)])
56
- proxy.reload
57
- setup_subnet_no_tftp.update! tftp: proxy, httpboot: proxy, template: proxy
58
- end
59
-
60
- def setup_subnet_with_tftp
61
- tftp_proxy = FactoryBot.create(:smart_proxy, features: [FactoryBot.create(:tftp_feature)])
62
- setup_subnet_no_tftp.update! tftp: tftp_proxy
63
- end
64
-
65
- def setup_subnet_no_tftp
66
- @subnet = FactoryBot.create(:subnet_ipv4, gateway: '10.0.1.254', dns_primary: '8.8.8.8', organizations: [@org], locations: [@loc])
67
- end
68
-
69
- def setup_host
70
- @host = FactoryBot.create(:host, :managed, subnet: @subnet, ip: @subnet.network.sub(/0$/, '4'), organization: @org, location: @loc, build: true)
71
- end
72
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
- require 'unit/shared/access_permissions_test_base'
5
-
6
- class AccessPermissionsTest < ActiveSupport::TestCase
7
- include AccessPermissionsTestBase
8
-
9
- check_routes(ForemanBootdisk::Engine.routes, [])
10
- end
@@ -1,83 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_plugin_helper'
4
-
5
- module ForemanBootdisk
6
- class VmwareTest < ActiveSupport::TestCase
7
- describe '#create_vm' do
8
- setup do
9
- @cr = FactoryBot.build(:vmware_cr)
10
- @cr.stubs(:test_connection)
11
- end
12
-
13
- test 'does not call clone_vm when bootdisk provisioning' do
14
- args = { 'provision_method' => 'bootdisk' }
15
- mock_vm = mock('vm')
16
- mock_vm.stubs(:firmware)
17
- mock_vm.expects(:save).returns(mock_vm)
18
- @cr.stubs(:parse_networks).returns(args)
19
- @cr.expects(:clone_vm).times(0)
20
- @cr.expects(:new_vm).returns(mock_vm)
21
- @cr.create_vm(args)
22
- end
23
- end
24
-
25
- describe '#new_vm' do
26
- setup do
27
- @cr = FactoryBot.build(:vmware_cr)
28
- end
29
-
30
- test 'calls client with cdrom drive and correct boot order when bootdisk provisioning' do
31
- args = { 'provision_method' => 'bootdisk' }
32
- mock_client = mock('client')
33
- mock_servers = mock('servers')
34
- mock_cdrom = mock('cdrom')
35
- mock_client.expects(:servers).returns(mock_servers)
36
- mock_servers.expects(:new).with do |opts|
37
- assert_equal opts[:boot_order], %w[cdrom disk]
38
- assert_equal opts[:boot_retry], 10
39
- assert_includes opts[:cdroms], mock_cdrom
40
- end
41
- @cr.expects(:new_cdrom).returns(mock_cdrom)
42
- @cr.expects(:new_interface)
43
- @cr.expects(:new_volume)
44
- @cr.expects(:datacenter)
45
- @cr.expects(:client).returns(mock_client)
46
- @cr.new_vm(args)
47
- end
48
- end
49
-
50
- describe '#parse_args' do
51
- setup do
52
- @cr = FactoryBot.build(:vmware_cr)
53
- end
54
-
55
- test 'should add a cdrom drive while keeping other parameters when provision_method is bootdisk' do
56
- mock_cdrom = mock('cdrom')
57
- @cr.expects(:new_cdrom).returns(mock_cdrom)
58
- attrs_in = HashWithIndifferentAccess.new(
59
- 'cpus' => '1',
60
- :provision_method => 'bootdisk'
61
- )
62
- attrs_out = {
63
- cpus: '1',
64
- provision_method: 'bootdisk',
65
- cdroms: [mock_cdrom],
66
- boot_order: %w[cdrom disk],
67
- boot_retry: 10
68
- }
69
- assert_equal attrs_out, @cr.parse_args(attrs_in)
70
- end
71
- end
72
-
73
- describe '#capabilities' do
74
- setup do
75
- @cr = FactoryBot.build(:vmware_cr)
76
- end
77
-
78
- test 'should include bootdisk' do
79
- assert_includes @cr.capabilities, :bootdisk
80
- end
81
- end
82
- end
83
- end
@@ -1,84 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_plugin_helper'
4
-
5
- module ForemanBootdisk
6
- class HostTest < ActiveSupport::TestCase
7
- test '#bootdisk_build? must be true when provision_method is bootdisk' do
8
- host = FactoryBot.build(:host, :managed)
9
- host.provision_method = 'bootdisk'
10
- assert host.bootdisk_build?
11
- assert_not host.image_build?
12
- assert_not host.pxe_build?
13
- end
14
-
15
- test '#validate_media? must be true when provision_method is bootdisk' do
16
- host = FactoryBot.build(:host, :managed,
17
- provision_method: 'bootdisk',
18
- build: true)
19
- assert host.validate_media?
20
- end
21
-
22
- test '#can_be_built? must be true when provision_method is bootdisk' do
23
- host = FactoryBot.build(:host, :managed,
24
- provision_method: 'bootdisk')
25
- assert host.can_be_built?
26
- end
27
-
28
- test 'host should have bootdisk' do
29
- if unattended?
30
- h = FactoryBot.build(:host, :managed,
31
- provision_method: 'bootdisk')
32
- assert h.bootdisk?
33
- end
34
- end
35
-
36
- test 'host should not have bootdisk' do
37
- if unattended?
38
- h = FactoryBot.create(:host)
39
- assert_not(h.bootdisk?)
40
- end
41
- end
42
-
43
- context '#bootdisk_downloadable?' do
44
- test 'should be true for 64 bit architecture' do
45
- architecture = Architecture.where(name: 'x86_64').first
46
- host = FactoryBot.build(:host, :managed, architecture: architecture)
47
-
48
- assert host.bootdisk_downloadable?
49
- end
50
-
51
- test 'should be true for 32 bit architecture' do
52
- architecture = FactoryBot.create(:architecture, name: 'i386')
53
- host = FactoryBot.build(:host, :managed, architecture: architecture)
54
-
55
- assert host.bootdisk_downloadable?
56
- end
57
-
58
- test 'should be false for non-intel architecture' do
59
- architecture = Architecture.where(name: 's390').first
60
- host = FactoryBot.build(:host, :managed, architecture: architecture)
61
-
62
- assert_not host.bootdisk_downloadable?
63
- end
64
-
65
- test 'should be true if architecture is absent' do
66
- host = FactoryBot.build(:host, :managed, architecture: nil)
67
-
68
- assert_nil host.architecture
69
- assert host.bootdisk_downloadable?
70
- end
71
- end
72
-
73
- context '#bootdisk_build?' do
74
- test 'should be false for hosts without bootdisk' do
75
- host = FactoryBot.create(:host)
76
- assert_not host.bootdisk_build?
77
- end
78
-
79
- test 'should be available in safe mode' do
80
- assert Host::Managed::Jail.allowed?(:bootdisk_build?)
81
- end
82
- end
83
- end
84
- end
@@ -1,69 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_plugin_helper'
4
-
5
- module ForemanBootdisk
6
- class OrchestrationComputeTest < ActiveSupport::TestCase
7
- setup do
8
- disable_orchestration
9
- @cr = FactoryBot.build(:vmware_cr)
10
- @host = FactoryBot.build(:host, :managed,
11
- compute_resource: @cr,
12
- provision_method: 'bootdisk')
13
- end
14
-
15
- test 'provisioning a host with provision method bootdisk should upload iso' do
16
- @cr.expects(:iso_upload)
17
- @host.send(:setIsoImage)
18
- end
19
-
20
- test 'provisioning a host with provision method bootdisk should attach iso' do
21
- @cr.expects(:iso_attach)
22
- @host.send(:setAttachIsoImage)
23
- end
24
-
25
- test 'provisioning a host with provision method bootdisk should detach iso' do
26
- @cr.expects(:iso_detach)
27
- @host.send(:setDetachIsoImage)
28
- end
29
-
30
- test 'provisioning a new host with provision method bootdisk should queue bootdisk tasks' do
31
- @host.stubs(:compute?).returns(true)
32
- @host.stubs(:build?).returns(true)
33
- @host.send(:queue_bootdisk_compute)
34
- tasks = @host.queue.all.map(&:name)
35
- assert_includes tasks, "Generating ISO image for #{@host.name}"
36
- assert_includes tasks, "Upload ISO image to datastore for #{@host.name}"
37
- assert_includes tasks, "Attach ISO image to CDROM drive for #{@host.name}"
38
- assert_not_includes tasks, "Detach ISO image from CDROM drive for #{@host.name}"
39
- end
40
-
41
- test 'rebuilding a host with provision method bootdisk should queue bootdisk tasks' do
42
- @host.stubs(:compute?).returns(true)
43
- old = stub()
44
- old.stubs(:build?).returns(false)
45
- @host.stubs(:old).returns(old)
46
- @host.stubs(:build?).returns(true)
47
- @host.send(:queue_bootdisk_compute)
48
- tasks = @host.queue.all.map(&:name)
49
- assert_includes tasks, "Generating ISO image for #{@host.name}"
50
- assert_includes tasks, "Upload ISO image to datastore for #{@host.name}"
51
- assert_includes tasks, "Attach ISO image to CDROM drive for #{@host.name}"
52
- assert_not_includes tasks, "Detach ISO image from CDROM drive for #{@host.name}"
53
- end
54
-
55
- test 'the iso should be detached when the host leaves build mode' do
56
- @host.stubs(:compute?).returns(true)
57
- old = stub()
58
- old.stubs(:build?).returns(true)
59
- @host.stubs(:old).returns(old)
60
- @host.stubs(:build?).returns(false)
61
- @host.send(:queue_bootdisk_compute)
62
- tasks = @host.queue.all.map(&:name)
63
- assert_not_includes tasks, "Generating ISO image for #{@host.name}"
64
- assert_not_includes tasks, "Upload ISO image to datastore for #{@host.name}"
65
- assert_not_includes tasks, "Attach ISO image to CDROM drive for #{@host.name}"
66
- assert_includes tasks, "Detach ISO image from CDROM drive for #{@host.name}"
67
- end
68
- end
69
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_plugin_helper'
4
-
5
- module ForemanBootdisk
6
- class RendererTest < ActiveSupport::TestCase
7
- include ForemanBootdiskTestHelper
8
-
9
- setup do
10
- User.current = users(:admin)
11
- setup_bootdisk
12
- end
13
-
14
- let(:renderer) { ForemanBootdisk::Renderer.new }
15
-
16
- describe 'a generic template' do
17
- test 'can be rendered' do
18
- rendered_template = renderer.generic_template_render
19
- assert_includes rendered_template, 'ifstat'
20
- end
21
-
22
- test 'does not include a host token' do
23
- rendered_template = renderer.generic_template_render
24
- assert_includes rendered_template, 'http://smart-proxy.example.com/unattended/iPXE?mac=${net0/mac}'
25
- assert_not_includes rendered_template, 'token'
26
- end
27
- end
28
-
29
- context 'with a subnet' do
30
- let(:subnet) { FactoryBot.create(:subnet_ipv4) }
31
- test 'renders a subnet template' do
32
- assert_includes renderer.generic_template_render(subnet), 'ifstat'
33
- end
34
- end
35
- end
36
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_plugin_helper'
4
-
5
- module ForemanBootdisk
6
- module Scope
7
- class BootdiskTest < ActiveSupport::TestCase
8
- let(:host) { FactoryBot.build(:host, :managed) }
9
- let(:source) { Foreman::Renderer::Source::String.new(content: 'Test') }
10
- let(:scope) { ForemanBootdisk::Scope::Bootdisk.new(host: host, source: source) }
11
-
12
- describe '#bootdisk_chain_url' do
13
- test 'should render bootdisk chain url' do
14
- assert_equal "http://foreman.some.host.fqdn/unattended/iPXE?mac=#{URI.encode_www_form_component(host.mac)}", scope.bootdisk_chain_url
15
- end
16
-
17
- test 'should render bootdisk chain url with custom mac' do
18
- assert_equal 'http://foreman.some.host.fqdn/unattended/iPXE?mac=00%3A11%3A22%3A33%3A44%3A55', scope.bootdisk_chain_url('00:11:22:33:44:55')
19
- end
20
- end
21
-
22
- describe '#bootdisk_raise' do
23
- test 'should raise a Foreman::Exception' do
24
- assert_raise ::Foreman::Exception do
25
- scope.bootdisk_raise('Some error.')
26
- end
27
- end
28
- end
29
- end
30
- end
31
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_plugin_helper'
4
-
5
- module ForemanBootdisk
6
- module Scope
7
- class BootdiskTest < ActiveSupport::TestCase
8
- let(:operatingsystem) { FactoryBot.create(:ubuntu14_10, :with_media, :with_archs) }
9
- let(:host) { FactoryBot.build(:host, :managed, operatingsystem: operatingsystem) }
10
- let(:source) { Foreman::Renderer::Source::String.new(content: 'Test') }
11
- let(:scope) { ForemanBootdisk::Scope::FullHostBootdisk.new(host: host, source: source) }
12
-
13
- setup do
14
- MediumProviders::Default.any_instance.stubs(:unique_id).returns('MyMedium01-ZYHBD6OPET')
15
- end
16
-
17
- describe '@kernel' do
18
- test 'should match filename on bootdisk' do
19
- assert_equal 'BOOT/MYMEDIUM01_ZYHBD6OPET_LINUX', scope.instance_variable_get('@kernel')
20
- end
21
- end
22
-
23
- describe '@initrd' do
24
- test 'should match filename on bootdisk' do
25
- assert_equal 'BOOT/EDIUM01_ZYHBD6OPET_INITRD_GZ', scope.instance_variable_get('@initrd')
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,74 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_plugin_helper'
4
-
5
- module ForemanBootdisk
6
- class IsoGeneratorTest < ActiveSupport::TestCase
7
- include ForemanBootdiskTestHelper
8
- setup :setup_bootdisk
9
-
10
- describe '#generate_full_host' do
11
- let(:medium) { FactoryBot.create(:medium, name: 'Red Hat Enterprise Linux Atomic Mirror') }
12
- let(:operatingsystem) { FactoryBot.create(:ubuntu14_10, :with_archs, :with_ptables, media: [medium]) }
13
- let(:host) { FactoryBot.create(:host, :managed, operatingsystem: operatingsystem, build: true) }
14
- let(:pxelinux_template) { FactoryBot.create(:provisioning_template, template: 'Fake kernel line <%= @kernel %> - <%= @initrd %>') }
15
- let(:pxegrub2_template) { FactoryBot.create(:provisioning_template, template: 'Fake kernel line <%= @kernel %> - <%= @initrd %>') }
16
-
17
- setup do
18
- host.stubs(:provisioning_template).with(kind: :PXELinux).returns(pxelinux_template)
19
- host.stubs(:provisioning_template).with(kind: :PXEGrub2).returns(pxegrub2_template)
20
- end
21
-
22
- test 'fetch handles redirect' do
23
- Dir.mktmpdir do |dir|
24
- url = 'http://example.com/request'
25
- redirection = 'http://example.com/redirect'
26
- stub_request(:get, url).to_return(status: 301, headers: { 'Location' => redirection })
27
- stub_request(:get, redirection)
28
- ForemanBootdisk::ISOGenerator.fetch(File.join(dir, 'test'), url)
29
- end
30
- end
31
-
32
- test 'generate_full_host creates with ISO-compatible file names' do
33
- urls = host.operatingsystem.boot_file_sources(host.medium_provider)
34
-
35
- kernel = ForemanBootdisk::ISOGenerator.iso9660_filename(
36
- host.operatingsystem.kernel(host.medium_provider)
37
- )
38
- kernel_url = urls[:kernel]
39
-
40
- initrd = ForemanBootdisk::ISOGenerator.iso9660_filename(
41
- host.operatingsystem.initrd(host.medium_provider)
42
- )
43
- initrd_url = urls[:initrd]
44
-
45
- ForemanBootdisk::ISOGenerator.expects(:generate)
46
- .with({ isolinux: "Fake kernel line #{kernel} - #{initrd}", grub: "Fake kernel line /#{kernel} - /#{initrd}", files: { kernel => kernel_url, initrd => initrd_url } }, anything)
47
-
48
- ForemanBootdisk::ISOGenerator.generate_full_host(host)
49
- end
50
- end
51
-
52
- describe '#generate' do
53
- test 'generates an iso image' do
54
- ForemanBootdisk::ISOGenerator.expects(:system).with(
55
- regexp_matches(/genisoimage -o .*output.iso -iso-level 2 -b isolinux.bin -c boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table .*build/)
56
- ).returns(true)
57
- ForemanBootdisk::ISOGenerator.expects(:system).with('isohybrid', anything).returns(true)
58
- ForemanBootdisk::ISOGenerator.generate do |iso|
59
- assert_not_nil iso
60
- end
61
- end
62
- end
63
-
64
- describe '#iso9660_filename' do
65
- test 'converts path to iso9660' do
66
- assert_equal 'BOOT/SOME_FILE_N_A_M_E123_', ForemanBootdisk::ISOGenerator.iso9660_filename('boot/some-File-n_a_m_e123Ä')
67
- end
68
-
69
- test 'shortens long filenames' do
70
- assert_equal 'BOOT/RPRISELINUXATOMIC_7_3_X86_64', ForemanBootdisk::ISOGenerator.iso9660_filename('boot/RedHatEnterpriseLinuxAtomic-7.3-x86_64')
71
- end
72
- end
73
- end
74
- end