foreman_expire_hosts 2.1.2 → 2.2.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/app/models/concerns/foreman_expire_hosts/host_ext.rb +1 -1
- data/app/views/hosts/_expired_on_field.html.erb +4 -2
- data/lib/foreman_expire_hosts/engine.rb +6 -0
- data/lib/foreman_expire_hosts/version.rb +1 -1
- data/test/unit/concerns/host_extensions_test.rb +27 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffe7a9b12696e0e2f492abefc63a354e46533892
|
4
|
+
data.tar.gz: 8315d516b2a6863b51df48c111093f144f6ac8ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4cf8b79e5763299dbb22939a3f4b1128a8ecf0f8ebdb99e0474b7fc1e467a36fbad0d32dd7bec6047f6aa07f3f21bdfe4d893f317ac128a7048257770bc5725
|
7
|
+
data.tar.gz: 1a64601384e3fff010888920bc3994db9d5ab0552b198d552f36e9f31a4d5065f1adfadc6e07343725e6bcac9e158dfb22e7c712a5743c25941ee10c3086af22
|
@@ -72,7 +72,7 @@ module ForemanExpireHosts
|
|
72
72
|
return true if new_record?
|
73
73
|
return true if defined?(Rails::Console)
|
74
74
|
return true unless User.current
|
75
|
-
return true if User.current.
|
75
|
+
return true if Authorizer.new(User.current).can?(:edit_host_expiry, self)
|
76
76
|
return true if self.owner_type.nil? || self.owner.nil?
|
77
77
|
Setting[:can_owner_modify_host_expiry_date] &&
|
78
78
|
((self.owner_type == 'User' && self.owner == User.current) ||
|
@@ -14,7 +14,9 @@
|
|
14
14
|
},
|
15
15
|
:autocomplete => false,
|
16
16
|
:placeholder => 'dd/mm/yyyy',
|
17
|
-
:
|
18
|
-
|
17
|
+
:help_block => ('<span class="pficon-warning-triangle-o"></span> '.html_safe + _('You are not allowed to change the expiry date of this host.') unless @host.can_modify_expiry_date?),
|
18
|
+
:readonly => !@host.can_modify_expiry_date?,
|
19
|
+
:help_inline => popover('Auto Expiry', _('Host will be deleted automatically on given expiry date.') + '<br>'.html_safe +
|
20
|
+
_('Leave blank to keep the host until deleted manually')),
|
19
21
|
:onfocus => 'append_shortcuts()'
|
20
22
|
%>
|
@@ -32,6 +32,12 @@ module ForemanExpireHosts
|
|
32
32
|
security_block :hosts do
|
33
33
|
permission :edit_hosts, {:hosts => [:select_multiple_expiration, :update_multiple_expiration]}
|
34
34
|
end
|
35
|
+
|
36
|
+
security_block :foreman_expire_hosts do
|
37
|
+
permission :edit_host_expiry,
|
38
|
+
{},
|
39
|
+
:resource_type => 'Host'
|
40
|
+
end
|
35
41
|
end
|
36
42
|
end
|
37
43
|
|
@@ -66,6 +66,33 @@ class ForemanExpireHostsHostExtTest < ActiveSupport::TestCase
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
context 'changing expiration date for user' do
|
70
|
+
let(:host) { FactoryGirl.create(:host, :managed) }
|
71
|
+
|
72
|
+
context 'with edit_host_expiry permission' do
|
73
|
+
let(:permission) { Permission.find_by_name('edit_host_expiry') }
|
74
|
+
let(:filter) { FactoryGirl.create(:filter, :permissions => [permission]) }
|
75
|
+
let(:role) { FactoryGirl.create(:role, :filters => [filter]) }
|
76
|
+
let(:user) { FactoryGirl.create(:user, :organizations => [host.organization], :locations => [host.location], :roles => [role]) }
|
77
|
+
|
78
|
+
test 'user can change expiry date' do
|
79
|
+
as_user user do
|
80
|
+
assert_equal true, host.can_modify_expiry_date?
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'without edit_host_expiry permission' do
|
86
|
+
let(:user) { FactoryGirl.build(:user, :organizations => [host.organization], :locations => [host.location]) }
|
87
|
+
|
88
|
+
test 'user can not change expiry date' do
|
89
|
+
as_user user do
|
90
|
+
assert_equal false, host.can_modify_expiry_date?
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
69
96
|
context 'a host without expiration' do
|
70
97
|
setup do
|
71
98
|
@host = FactoryGirl.build(:host)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_expire_hosts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nagarjuna Rachaneni
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-02-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: deface
|