foreman_dlm 2.0.0 → 4.0.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 +3 -1
- data/Rakefile +4 -2
- data/app/controllers/api/v2/dlmlock_events_controller.rb +2 -0
- data/app/controllers/api/v2/dlmlocks_controller.rb +14 -11
- data/app/controllers/concerns/foreman/controller/parameters/dlmlocks.rb +2 -0
- data/app/controllers/concerns/foreman_dlm/find_host_by_client_cert.rb +2 -0
- data/app/controllers/concerns/foreman_dlm/find_host_by_ip.rb +2 -0
- data/app/controllers/concerns/foreman_dlm/update_checkin_time.rb +2 -0
- data/app/controllers/foreman_dlm/application_controller.rb +2 -0
- data/app/controllers/foreman_dlm/dlmlocks_controller.rb +4 -10
- data/app/helpers/foreman_dlm/dlmlock_helper.rb +2 -0
- data/app/jobs/foreman_dlm/refresh_dlmlock_status.rb +2 -0
- data/app/models/concerns/foreman_dlm/dlm_facet_host_extensions.rb +2 -0
- data/app/models/concerns/foreman_dlm/expirable.rb +2 -0
- data/app/models/concerns/foreman_dlm/host_extensions.rb +10 -8
- data/app/models/concerns/foreman_dlm/host_monitoring_extensions.rb +3 -1
- data/app/models/concerns/foreman_dlm/user_extensions.rb +6 -4
- data/app/models/foreman_dlm/dlm_facet.rb +2 -0
- data/app/models/foreman_dlm/dlmlock/update.rb +2 -0
- data/app/models/foreman_dlm/dlmlock.rb +11 -9
- data/app/models/foreman_dlm/dlmlock_event.rb +2 -0
- data/app/models/host_status/dlmlock_status.rb +2 -0
- data/app/views/api/v2/dlmlock_events/index.json.rabl +2 -0
- data/app/views/api/v2/dlmlocks/acquire.json.rabl +2 -0
- data/app/views/api/v2/dlmlocks/base.json.rabl +2 -0
- data/app/views/api/v2/dlmlocks/create.json.rabl +2 -0
- data/app/views/api/v2/dlmlocks/index.json.rabl +2 -0
- data/app/views/api/v2/dlmlocks/main.json.rabl +2 -0
- data/app/views/api/v2/dlmlocks/release.json.rabl +2 -0
- data/app/views/api/v2/dlmlocks/show.json.rabl +2 -0
- data/app/views/api/v2/dlmlocks/update.json.rabl +2 -0
- data/app/views/api/v2/errors/precondition_failed.json.rabl +2 -0
- data/app/views/foreman_dlm/api/v2/dlm_facets/base.json.rabl +2 -0
- data/app/views/foreman_dlm/api/v2/dlm_facets/base_with_root.json.rabl +2 -0
- data/app/views/foreman_dlm/api/v2/dlm_facets/show.json.rabl +2 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20170824084100_add_dlmlock.foreman_dlm.rb +2 -0
- data/db/migrate/20180627150003_rename_dlmlock_sti_models.rb +3 -1
- data/db/migrate/20180704162345_add_dlmlock_events.rb +2 -0
- data/db/migrate/20180711090022_add_hosts_fk_to_dlmlocks.rb +2 -0
- data/db/migrate/20180711111903_create_dlm_facets.foreman_dlm.rb +2 -0
- data/db/migrate/20180713113208_update_permissions_for_scoped_models.rb +2 -0
- data/lib/foreman_dlm/engine.rb +70 -70
- data/lib/foreman_dlm/version.rb +3 -1
- data/lib/foreman_dlm.rb +2 -0
- data/lib/tasks/dlmlock_events.rake +2 -0
- data/lib/tasks/foreman_dlm_tasks.rake +2 -20
- data/locale/gemspec.rb +3 -1
- data/test/controllers/api/v2/dlmlocks_controller_test.rb +12 -10
- data/test/controllers/api/v2/dlmlocks_dlmlock_events_controller_test.rb +2 -0
- data/test/controllers/api/v2/hosts_controller_test.rb +2 -0
- data/test/controllers/find_host_by_client_cert_test.rb +5 -3
- data/test/controllers/foreman_dlm/dlmlocks_test.rb +2 -0
- data/test/controllers/hosts_controller_test.rb +3 -1
- data/test/factories/dlm_facets.rb +2 -0
- data/test/factories/dlmlock.rb +2 -0
- data/test/factories/dlmlock_events.rb +2 -0
- data/test/factories/host.rb +2 -0
- data/test/integration/foreman_dlm/dlmlocks_test.rb +9 -3
- data/test/jobs/refresh_dlmlock_status_test.rb +2 -0
- data/test/models/foreman_dlm/dlm_facet_test.rb +2 -0
- data/test/models/foreman_dlm/dlmlock_event_test.rb +2 -0
- data/test/models/foreman_dlm/dlmlock_test.rb +26 -24
- data/test/models/host_managed_test.rb +2 -0
- data/test/models/host_monitoring_test.rb +2 -0
- data/test/models/host_status/dlmlock_status_test.rb +2 -2
- data/test/models/user_test.rb +2 -0
- data/test/test_plugin_helper.rb +2 -0
- data/test/unit/foreman_dlm/access_permissions_test.rb +18 -0
- metadata +12 -38
data/lib/foreman_dlm/engine.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ForemanDlm
|
2
4
|
class Engine < ::Rails::Engine
|
3
5
|
engine_name 'foreman_dlm'
|
4
6
|
|
5
|
-
config.autoload_paths += Dir["#{config.root}/app/controllers/concerns"]
|
6
|
-
config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
|
7
|
-
config.autoload_paths += Dir["#{config.root}/app/jobs"]
|
8
|
-
|
9
7
|
# Add any db migrations
|
10
8
|
initializer 'foreman_dlm.load_app_instance_data' do |app|
|
11
9
|
ForemanDlm::Engine.paths['db/migrate'].existent.each do |path|
|
@@ -13,77 +11,79 @@ module ForemanDlm
|
|
13
11
|
end
|
14
12
|
end
|
15
13
|
|
16
|
-
initializer 'foreman_dlm.register_plugin', :before => :finisher_hook do |
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
14
|
+
initializer 'foreman_dlm.register_plugin', :before => :finisher_hook do |app|
|
15
|
+
app.reloader.to_prepare do
|
16
|
+
Foreman::Plugin.register :foreman_dlm do
|
17
|
+
requires_foreman '>= 3.13'
|
18
|
+
|
19
|
+
apipie_documented_controllers ["#{ForemanDlm::Engine.root}/app/controllers/api/v2/*.rb"]
|
20
|
+
|
21
|
+
settings do
|
22
|
+
category(:general) do
|
23
|
+
setting('dlm_stale_time',
|
24
|
+
type: :integer,
|
25
|
+
default: 4,
|
26
|
+
description: N_('Number of hours after which locked Distributed Lock is stale'),
|
27
|
+
full_name: N_('Distributed Lock stale time'),
|
28
|
+
validate: { numericality: { greater_than: 0 } })
|
29
|
+
end
|
30
30
|
end
|
31
|
-
end
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
32
|
+
# Add permissions
|
33
|
+
security_block :foreman_dlm do
|
34
|
+
permission :view_dlmlocks, {
|
35
|
+
:'foreman_dlm/dlmlocks' => [:index, :show, :auto_complete_search],
|
36
|
+
:'api/v2/dlmlocks' => [:index, :show],
|
37
|
+
}, :resource_type => 'ForemanDlm::Dlmlock'
|
38
|
+
|
39
|
+
permission :create_dlmlocks, {
|
40
|
+
:'api/v2/dlmlocks' => [:create],
|
41
|
+
}, :resource_type => 'ForemanDlm::Dlmlock'
|
42
|
+
|
43
|
+
permission :edit_dlmlocks, {
|
44
|
+
:'foreman_dlm/dlmlocks' => [:release, :enable, :disable],
|
45
|
+
:'api/v2/dlmlocks' => [:update, :acquire, :release],
|
46
|
+
}, :resource_type => 'ForemanDlm::Dlmlock'
|
47
|
+
|
48
|
+
permission :destroy_dlmlocks, {
|
49
|
+
:'foreman_dlm/dlmlocks' => [:destroy],
|
50
|
+
:'api/v2/dlmlocks' => [:destroy],
|
51
|
+
}, :resource_type => 'ForemanDlm::Dlmlock'
|
52
|
+
|
53
|
+
permission :view_dlmlock_events, {
|
54
|
+
:'api/v2/dlmlock_events' => [:index],
|
55
|
+
}, :resource_type => 'ForemanDlm::DlmlockEvent'
|
56
|
+
end
|
58
57
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
58
|
+
# Add a new role called 'Distributed Lock Manager' if it doesn't exist
|
59
|
+
role 'Distributed Lock Manager', [:view_dlmlocks,
|
60
|
+
:create_dlmlocks,
|
61
|
+
:edit_dlmlocks,
|
62
|
+
:destroy_dlmlocks,
|
63
|
+
:view_dlmlock_events],
|
64
|
+
'Role granting full access permissions to distributed locks'
|
65
|
+
|
66
|
+
# add menu entry
|
67
|
+
menu :top_menu, :foreman_dlm_dlmlocks,
|
68
|
+
url_hash: { controller: :'foreman_dlm/dlmlocks', action: :index },
|
69
|
+
caption: N_('Distributed Locks'),
|
70
|
+
parent: :monitor_menu,
|
71
|
+
after: :audits
|
72
|
+
|
73
|
+
# Dlm Facet
|
74
|
+
register_facet(ForemanDlm::DlmFacet, :dlm_facet) do
|
75
|
+
api_view list: 'foreman_dlm/api/v2/dlm_facets/base_with_root', single: 'foreman_dlm/api/v2/dlm_facets/show'
|
76
|
+
end
|
78
77
|
|
79
|
-
|
78
|
+
register_custom_status HostStatus::DlmlockStatus
|
80
79
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
80
|
+
# extend host show page
|
81
|
+
extend_page('hosts/show') do |context|
|
82
|
+
context.add_pagelet :main_tabs,
|
83
|
+
:name => N_('Locks'),
|
84
|
+
:partial => 'hosts/dlmlocks_tab',
|
85
|
+
:onlyif => proc { |host| host.dlm_facet }
|
86
|
+
end
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
data/lib/foreman_dlm/version.rb
CHANGED
data/lib/foreman_dlm.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rake/testtask'
|
2
4
|
|
3
5
|
# Tests
|
@@ -12,24 +14,4 @@ namespace :test do
|
|
12
14
|
end
|
13
15
|
end
|
14
16
|
|
15
|
-
namespace :foreman_dlm do
|
16
|
-
task :rubocop do
|
17
|
-
begin
|
18
|
-
require 'rubocop/rake_task'
|
19
|
-
RuboCop::RakeTask.new(:rubocop_foreman_dlm) do |task|
|
20
|
-
task.patterns = ["#{ForemanDlm::Engine.root}/app/**/*.rb",
|
21
|
-
"#{ForemanDlm::Engine.root}/lib/**/*.rb",
|
22
|
-
"#{ForemanDlm::Engine.root}/test/**/*.rb"]
|
23
|
-
end
|
24
|
-
rescue StandardError
|
25
|
-
puts 'Rubocop not loaded.'
|
26
|
-
end
|
27
|
-
|
28
|
-
Rake::Task['rubocop_foreman_dlm'].invoke
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
17
|
Rake::Task[:test].enhance ['test:foreman_dlm']
|
33
|
-
|
34
|
-
load 'tasks/jenkins.rake'
|
35
|
-
Rake::Task['jenkins:unit'].enhance ['test:foreman_dlm', 'foreman_dlm:rubocop'] if Rake::Task.task_defined?(:'jenkins:unit')
|
data/locale/gemspec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_plugin_helper'
|
2
4
|
|
3
5
|
class Api::V2::DlmlocksControllerTest < ActionController::TestCase
|
@@ -33,7 +35,7 @@ class Api::V2::DlmlocksControllerTest < ActionController::TestCase
|
|
33
35
|
assert dlmlock
|
34
36
|
assert_equal valid_attrs['name'], dlmlock.name
|
35
37
|
assert_equal valid_attrs['type'], dlmlock.type
|
36
|
-
|
38
|
+
assert dlmlock.enabled
|
37
39
|
assert_nil dlmlock.host
|
38
40
|
end
|
39
41
|
end
|
@@ -47,7 +49,7 @@ class Api::V2::DlmlocksControllerTest < ActionController::TestCase
|
|
47
49
|
assert_not_empty body
|
48
50
|
assert_equal dlmlock.name, body['name']
|
49
51
|
assert_equal dlmlock.type, body['type']
|
50
|
-
|
52
|
+
assert body['enabled']
|
51
53
|
assert_equal host1.id, body['host_id']
|
52
54
|
end
|
53
55
|
|
@@ -59,7 +61,7 @@ class Api::V2::DlmlocksControllerTest < ActionController::TestCase
|
|
59
61
|
assert_not_empty body
|
60
62
|
assert_equal dlmlock.name, body['name']
|
61
63
|
assert_equal dlmlock.type, body['type']
|
62
|
-
|
64
|
+
assert_not body['enabled']
|
63
65
|
assert_nil body['host_id']
|
64
66
|
end
|
65
67
|
|
@@ -91,7 +93,7 @@ class Api::V2::DlmlocksControllerTest < ActionController::TestCase
|
|
91
93
|
dlmlock.reload
|
92
94
|
assert_equal valid_attrs['name'], dlmlock.name
|
93
95
|
assert_equal valid_attrs['type'], dlmlock.type
|
94
|
-
|
96
|
+
assert_not dlmlock.enabled
|
95
97
|
assert_equal host1.id, dlmlock.host_id
|
96
98
|
end
|
97
99
|
end
|
@@ -181,7 +183,7 @@ class Api::V2::DlmlocksControllerTest < ActionController::TestCase
|
|
181
183
|
assert_not_empty body
|
182
184
|
assert_equal dlmlock.name, body['name']
|
183
185
|
assert_equal dlmlock.type, body['type']
|
184
|
-
|
186
|
+
assert body['enabled']
|
185
187
|
assert_nil body['host_id']
|
186
188
|
assert_nil body['host']
|
187
189
|
end
|
@@ -194,12 +196,12 @@ class Api::V2::DlmlocksControllerTest < ActionController::TestCase
|
|
194
196
|
assert_not_empty body
|
195
197
|
assert_equal dlmlock.name, body['name']
|
196
198
|
assert_equal dlmlock.type, body['type']
|
197
|
-
|
199
|
+
assert body['enabled']
|
198
200
|
assert_equal host1.id, body['host_id']
|
199
201
|
host = body['host']
|
200
202
|
assert host
|
201
203
|
assert_equal host1.name, host['name']
|
202
|
-
|
204
|
+
assert host['self']
|
203
205
|
end
|
204
206
|
|
205
207
|
test 'should show individual acquired lock by other' do
|
@@ -210,12 +212,12 @@ class Api::V2::DlmlocksControllerTest < ActionController::TestCase
|
|
210
212
|
assert_not_empty body
|
211
213
|
assert_equal dlmlock.name, body['name']
|
212
214
|
assert_equal dlmlock.type, body['type']
|
213
|
-
|
215
|
+
assert body['enabled']
|
214
216
|
assert_equal host2.id, body['host_id']
|
215
217
|
host = body['host']
|
216
218
|
assert host
|
217
219
|
assert_equal host2.name, host['name']
|
218
|
-
|
220
|
+
assert_not host['self']
|
219
221
|
end
|
220
222
|
|
221
223
|
test 'should update checkin time' do
|
@@ -378,7 +380,7 @@ class Api::V2::DlmlocksControllerTest < ActionController::TestCase
|
|
378
380
|
def valid_attrs
|
379
381
|
{
|
380
382
|
'name' => 'testlock',
|
381
|
-
'type' => 'ForemanDlm::Dlmlock::Update'
|
383
|
+
'type' => 'ForemanDlm::Dlmlock::Update',
|
382
384
|
}
|
383
385
|
end
|
384
386
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_plugin_helper'
|
2
4
|
|
3
5
|
class FindHostByClientCertTest < ActionController::TestCase
|
@@ -62,7 +64,7 @@ class FindHostByClientCertTest < ActionController::TestCase
|
|
62
64
|
|
63
65
|
get :index
|
64
66
|
|
65
|
-
|
67
|
+
assert_not @controller.send(:require_client_cert_or_login)
|
66
68
|
assert_nil @controller.detected_host
|
67
69
|
end
|
68
70
|
|
@@ -73,7 +75,7 @@ class FindHostByClientCertTest < ActionController::TestCase
|
|
73
75
|
|
74
76
|
get :index
|
75
77
|
|
76
|
-
|
78
|
+
assert_not @controller.send(:require_client_cert_or_login)
|
77
79
|
assert_nil @controller.detected_host
|
78
80
|
end
|
79
81
|
|
@@ -83,7 +85,7 @@ class FindHostByClientCertTest < ActionController::TestCase
|
|
83
85
|
|
84
86
|
get :index
|
85
87
|
|
86
|
-
|
88
|
+
assert_not @controller.send(:require_client_cert_or_login)
|
87
89
|
assert_nil @controller.detected_host
|
88
90
|
end
|
89
91
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_plugin_helper'
|
2
4
|
|
3
5
|
class HostsControllerTest < ActionController::TestCase
|
@@ -7,6 +9,6 @@ class HostsControllerTest < ActionController::TestCase
|
|
7
9
|
FactoryBot.create_list(:dlmlock, 2, host: host)
|
8
10
|
get :show, params: { :id => host.to_param }, session: set_session_user
|
9
11
|
assert_response :success
|
10
|
-
|
12
|
+
assert_match(/id='pagelet-id-locks'/, @response.body)
|
11
13
|
end
|
12
14
|
end
|
data/test/factories/dlmlock.rb
CHANGED
data/test/factories/host.rb
CHANGED
@@ -14,15 +14,21 @@ class DlmlocksTest < IntegrationTestWithJavascript
|
|
14
14
|
end
|
15
15
|
|
16
16
|
test 'the search bar has autocomplete' do
|
17
|
-
skip if Gem::Version.new(Foreman::Version.new.notag) < Gem::Version.new('1.20')
|
18
17
|
FactoryBot.create_list(:dlmlock, 10)
|
19
18
|
|
20
19
|
visit foreman_dlm_dlmlocks_path
|
21
20
|
|
22
|
-
search_bar = page.first('
|
21
|
+
search_bar = page.first('.foreman-search-bar')
|
23
22
|
search_bar.first('input').set('ho')
|
24
23
|
|
25
|
-
|
24
|
+
autocomplete_list = page.first('div[data-ouia-component-id="search-autocomplete-menu"]')
|
25
|
+
version = Foreman::Version.new
|
26
|
+
list = if version.major.to_i == 3 && version.minor.to_i <= 14
|
27
|
+
autocomplete_list.find_all('span.pf-c-menu__item-text').map(&:text)
|
28
|
+
else
|
29
|
+
autocomplete_list.find_all('span.pf-v5-c-menu__item-text').map(&:text)
|
30
|
+
end
|
31
|
+
|
26
32
|
assert_includes list, 'host'
|
27
33
|
end
|
28
34
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'test_plugin_helper'
|
2
4
|
|
3
5
|
module ForemanDlm
|
@@ -45,10 +47,10 @@ module ForemanDlm
|
|
45
47
|
let(:dlmlock) { FactoryBot.create(:dlmlock) }
|
46
48
|
|
47
49
|
test 'should be enabled and unlocked' do
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
assert dlmlock.enabled?
|
51
|
+
assert_not dlmlock.disabled?
|
52
|
+
assert_not dlmlock.locked?
|
53
|
+
assert_not dlmlock.taken?
|
52
54
|
end
|
53
55
|
|
54
56
|
test 'can be acquired' do
|
@@ -100,21 +102,21 @@ module ForemanDlm
|
|
100
102
|
let(:dlmlock) { FactoryBot.create(:dlmlock, :enabled => false) }
|
101
103
|
|
102
104
|
test 'should be disabled and unlocked' do
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
105
|
+
assert_not dlmlock.enabled?
|
106
|
+
assert dlmlock.disabled?
|
107
|
+
assert_not dlmlock.locked?
|
108
|
+
assert_not dlmlock.taken?
|
107
109
|
end
|
108
110
|
|
109
111
|
test 'can not be acquired' do
|
110
112
|
assert_nil dlmlock.host
|
111
|
-
|
113
|
+
assert_not dlmlock.acquire!(host1)
|
112
114
|
assert_nil dlmlock.reload.host
|
113
115
|
end
|
114
116
|
|
115
117
|
test 'can not be released' do
|
116
118
|
assert_nil dlmlock.host
|
117
|
-
|
119
|
+
assert_not dlmlock.release!(host1)
|
118
120
|
assert_nil dlmlock.reload.host
|
119
121
|
end
|
120
122
|
|
@@ -122,8 +124,8 @@ module ForemanDlm
|
|
122
124
|
host = HostWithCallbacks.new
|
123
125
|
host.name = 'test.example.com'
|
124
126
|
host.save
|
125
|
-
|
126
|
-
|
127
|
+
assert_not dlmlock.release!(host)
|
128
|
+
assert_empty host.callbacks
|
127
129
|
end
|
128
130
|
end
|
129
131
|
|
@@ -131,12 +133,12 @@ module ForemanDlm
|
|
131
133
|
let(:dlmlock) { FactoryBot.create(:dlmlock, :host => host1) }
|
132
134
|
|
133
135
|
test 'should be enabled and locked' do
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
136
|
+
assert dlmlock.enabled?
|
137
|
+
assert_not dlmlock.disabled?
|
138
|
+
assert dlmlock.locked?
|
139
|
+
assert dlmlock.taken?
|
140
|
+
assert dlmlock.locked_by?(host1)
|
141
|
+
assert dlmlock.acquired_by?(host1)
|
140
142
|
end
|
141
143
|
|
142
144
|
test 'can be acquired by owner' do
|
@@ -147,7 +149,7 @@ module ForemanDlm
|
|
147
149
|
|
148
150
|
test 'can not be acquired by other host' do
|
149
151
|
assert_equal host1, dlmlock.host
|
150
|
-
|
152
|
+
assert_not dlmlock.acquire!(host2)
|
151
153
|
assert_equal host1, dlmlock.reload.host
|
152
154
|
end
|
153
155
|
|
@@ -159,7 +161,7 @@ module ForemanDlm
|
|
159
161
|
|
160
162
|
test 'can not be released by other host' do
|
161
163
|
assert_equal host1, dlmlock.host
|
162
|
-
|
164
|
+
assert_not dlmlock.release!(host2)
|
163
165
|
assert_equal host1, dlmlock.reload.host
|
164
166
|
end
|
165
167
|
|
@@ -196,16 +198,16 @@ module ForemanDlm
|
|
196
198
|
assert host1_with_callbacks
|
197
199
|
assert host2_with_callbacks
|
198
200
|
dlmlock.update(:host => host1_with_callbacks)
|
199
|
-
|
200
|
-
|
201
|
-
|
201
|
+
assert_not dlmlock.release!(host2_with_callbacks)
|
202
|
+
assert_empty host1_with_callbacks.callbacks
|
203
|
+
assert_empty host2_with_callbacks.callbacks
|
202
204
|
end
|
203
205
|
|
204
206
|
test 'triggers no callbacks on acquiry attempt by owner' do
|
205
207
|
assert host1_with_callbacks
|
206
208
|
dlmlock.update(:host => host1_with_callbacks)
|
207
209
|
assert dlmlock.acquire!(host1_with_callbacks)
|
208
|
-
|
210
|
+
assert_empty host1_with_callbacks.callbacks
|
209
211
|
end
|
210
212
|
end
|
211
213
|
|
@@ -32,14 +32,14 @@ class DlmlockStatusTest < ActiveSupport::TestCase
|
|
32
32
|
status = host.get_status(HostStatus::DlmlockStatus)
|
33
33
|
|
34
34
|
assert_not_empty host.dlmlocks
|
35
|
-
|
35
|
+
assert status.relevant?
|
36
36
|
end
|
37
37
|
|
38
38
|
test 'should return false if host has no dlmlocks' do
|
39
39
|
status = host.get_status(HostStatus::DlmlockStatus)
|
40
40
|
|
41
41
|
assert_empty host.dlmlocks
|
42
|
-
|
42
|
+
assert_not status.relevant?
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
data/test/models/user_test.rb
CHANGED
data/test/test_plugin_helper.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'test_plugin_helper'
|
4
|
+
require 'unit/shared/access_permissions_test_base'
|
5
|
+
|
6
|
+
# Permissions are added in AccessPermissions with lists of controllers and
|
7
|
+
# actions that they enable access to. For non-admin users, we need to test
|
8
|
+
# that there are permissions available that cover every controller action, else
|
9
|
+
# it can't be delegated and this will lead to parts of the application that
|
10
|
+
# aren't functional for non-admin users.
|
11
|
+
#
|
12
|
+
# In particular, it's important that actions for AJAX requests are added to
|
13
|
+
# an appropriate permission so views using those requests function.
|
14
|
+
class AccessPermissionsTest < ActiveSupport::TestCase
|
15
|
+
include AccessPermissionsTestBase
|
16
|
+
|
17
|
+
check_routes(ForemanDlm::Engine.routes, [])
|
18
|
+
end
|