foreman_expire_hosts 6.0.0 → 6.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/concerns/foreman_expire_hosts/audits_helper_extensions.rb +2 -0
- data/app/helpers/concerns/foreman_expire_hosts/hosts_helper_extensions.rb +1 -0
- data/app/helpers/expire_hosts_mailer_helper.rb +1 -0
- data/app/mailers/expire_hosts_mailer.rb +1 -0
- data/app/models/concerns/foreman_expire_hosts/host_ext.rb +6 -0
- data/app/models/host_status/expiration_status.rb +1 -0
- data/app/overrides/add_expired_on_field_to_host_form.rb +2 -2
- data/app/overrides/add_expired_on_field_to_host_show.rb +3 -3
- data/app/overrides/add_js_to_host_index.rb +3 -3
- data/app/overrides/deleted_expired_host_comment_in_audits.rb +6 -6
- data/app/services/foreman_expire_hosts/action/base.rb +4 -1
- data/app/services/foreman_expire_hosts/action/stop_expired_hosts.rb +3 -1
- data/app/services/foreman_expire_hosts/notification/base.rb +4 -0
- data/app/services/foreman_expire_hosts/ui_notifications/hosts/base.rb +1 -0
- data/foreman_expire_hosts.gemspec +1 -1
- data/lib/expire_hosts_notifications.rb +1 -0
- data/lib/foreman_expire_hosts/version.rb +1 -1
- data/test/factories/foreman_expire_hosts_factories.rb +5 -5
- data/test/functional/api/v2/hosts_controller_test.rb +1 -1
- data/test/lib/expire_hosts_notifications_test.rb +72 -45
- data/test/unit/concerns/host_extensions_test.rb +18 -18
- data/test/unit/host_status/expiration_status_test.rb +1 -1
- data/test/unit/safe_destroy_test.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66c086d3dc04916321804be89e8d5f027691b5aa5dc10b0cef317b7ac5d4ee9e
|
4
|
+
data.tar.gz: 84e16983231ab5651c03c5d56484c8645bd1c6910bd677aa7bcacefb139b06d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2990701bc9efa238f25f6a6a7def12d87e9403e4b6cf0f41b477c1d5cc16a467f2edcb211fabd724034b3c149d00d654087a42e4a8e323fd403a2030ac81492
|
7
|
+
data.tar.gz: 60a5e736f9e54223e5c62bcf426514e10aec9569708d3f58b672da60e41667b3537848c8fa6f00c8904c3c36aa87038304cdf44bc7d51e6a087d5c906ff3302d
|
@@ -4,11 +4,13 @@ module ForemanExpireHosts
|
|
4
4
|
|
5
5
|
def destroyed_expired_host_audit_comment_in_list(audit)
|
6
6
|
return unless audit.auditable_type.to_s == 'Host' && audit.action == 'destroy' && audit.comment.present?
|
7
|
+
|
7
8
|
"<div style='color: #737373;font-size: 14px'>Comment: #{audit.comment}</div>".html_safe
|
8
9
|
end
|
9
10
|
|
10
11
|
def destroyed_expired_host_audit_comment_in_show(audit)
|
11
12
|
return unless audit.auditable_type.to_s == 'Host' && audit.action == 'destroy' && audit.comment.present?
|
13
|
+
|
12
14
|
"<tr><td>Comment</td><td>#{audit.comment}</td></tr>".html_safe
|
13
15
|
end
|
14
16
|
end
|
@@ -16,6 +16,7 @@ module ForemanExpireHosts
|
|
16
16
|
|
17
17
|
def host_expiry_warning_message(host)
|
18
18
|
return nil unless host.expires?
|
19
|
+
|
19
20
|
if host.expired_past_grace_period?
|
20
21
|
message = _('This host has expired %s ago and needs to be deleted manually.') % time_ago_in_words(host.expired_on)
|
21
22
|
elsif host.expired?
|
@@ -40,27 +40,32 @@ module ForemanExpireHosts
|
|
40
40
|
|
41
41
|
def expires_today?
|
42
42
|
return false unless expires?
|
43
|
+
|
43
44
|
expired_on.to_date == Date.today
|
44
45
|
end
|
45
46
|
|
46
47
|
def expired?
|
47
48
|
return false unless expires?
|
49
|
+
|
48
50
|
expired_on.to_date < Date.today
|
49
51
|
end
|
50
52
|
|
51
53
|
def expiration_grace_period_end_date
|
52
54
|
return nil unless expires?
|
55
|
+
|
53
56
|
expired_on + Setting[:days_to_delete_after_host_expiration].to_i
|
54
57
|
end
|
55
58
|
|
56
59
|
def expired_past_grace_period?
|
57
60
|
return false unless expires?
|
61
|
+
|
58
62
|
expiration_grace_period_end_date <= Date.today
|
59
63
|
end
|
60
64
|
|
61
65
|
def pending_expiration?
|
62
66
|
return false unless expires?
|
63
67
|
return false if expired?
|
68
|
+
|
64
69
|
expired_on - Setting['notify1_days_before_host_expiry'].to_i <= Date.today
|
65
70
|
end
|
66
71
|
|
@@ -70,6 +75,7 @@ module ForemanExpireHosts
|
|
70
75
|
return true unless User.current
|
71
76
|
return true if Authorizer.new(User.current).can?(:edit_host_expiry, self)
|
72
77
|
return true if self.owner_type.nil? || self.owner.nil?
|
78
|
+
|
73
79
|
Setting[:can_owner_modify_host_expiry_date] &&
|
74
80
|
((self.owner_type == 'User' && self.owner == User.current) ||
|
75
81
|
(self.owner_type == 'Usergroup' && self.owner.all_users.include?(User.current)))
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Deface::Override.new(
|
2
|
-
:virtual_path
|
3
|
-
:name
|
2
|
+
:virtual_path => 'hosts/show',
|
3
|
+
:name => 'host_expiry_waring_in_show',
|
4
4
|
:insert_before => '#host-show',
|
5
|
-
:partial
|
5
|
+
:partial => 'hosts/expired_message.html.erb'
|
6
6
|
)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Deface::Override.new(
|
2
|
-
:virtual_path
|
3
|
-
:name
|
2
|
+
:virtual_path => 'hosts/_list',
|
3
|
+
:name => 'host_list_expiration_js',
|
4
4
|
:insert_before => '#confirmation-modal',
|
5
|
-
:text
|
5
|
+
:text => "<%= stylesheet 'foreman_expire_hosts/application' %><%= javascript 'foreman_expire_hosts/application' %>"
|
6
6
|
)
|
@@ -1,13 +1,13 @@
|
|
1
1
|
Deface::Override.new(
|
2
|
-
:virtual_path
|
3
|
-
:name
|
2
|
+
:virtual_path => 'audits/_list',
|
3
|
+
:name => 'deleted_expired_host_audit_comment_in_list',
|
4
4
|
:insert_bottom => 'div.row div.audit-content',
|
5
|
-
:text
|
5
|
+
:text => "\n <%= destroyed_expired_host_audit_comment_in_list(audit) %>"
|
6
6
|
)
|
7
7
|
|
8
8
|
Deface::Override.new(
|
9
|
-
:virtual_path
|
10
|
-
:name
|
9
|
+
:virtual_path => 'audits/show',
|
10
|
+
:name => 'deleted_expired_host_audit_comment_in_show',
|
11
11
|
:insert_bottom => 'div#tab1 table',
|
12
|
-
:text
|
12
|
+
:text => "\n <%= destroyed_expired_host_audit_comment_in_show(@audit) %>"
|
13
13
|
)
|
@@ -8,7 +8,9 @@ module ForemanExpireHosts
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def action(host)
|
11
|
-
return
|
11
|
+
return false unless host.supports_power?
|
12
|
+
return unless host.power.ready?
|
13
|
+
|
12
14
|
logger.info "Powering down expired host in grace period #{host}"
|
13
15
|
host.power.stop
|
14
16
|
rescue StandardError
|
@@ -24,6 +24,8 @@ module ForemanExpireHosts
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def deliver_mail_notification(recipient, hosts)
|
27
|
+
return true if hosts.empty?
|
28
|
+
|
27
29
|
build_mail_notification(recipient, hosts).deliver_now
|
28
30
|
rescue SocketError, Net::SMTPError => error
|
29
31
|
message = _('Failed to deliver %{notification_name} for Hosts %{hosts}') % {
|
@@ -59,11 +61,13 @@ module ForemanExpireHosts
|
|
59
61
|
return global_recipients if global_recipients.present?
|
60
62
|
return [User.anonymous_admin] if host.owner.blank?
|
61
63
|
return [host.owner] if host.owner_type == 'User'
|
64
|
+
|
62
65
|
host.owner.all_users
|
63
66
|
end
|
64
67
|
|
65
68
|
def additional_recipients
|
66
69
|
return [] if Setting[:host_expiry_email_recipients].nil?
|
70
|
+
|
67
71
|
Setting[:host_expiry_email_recipients].split(',').compact.map(&:strip)
|
68
72
|
end
|
69
73
|
end
|
@@ -10,6 +10,7 @@ module ExpireHostsNotifications
|
|
10
10
|
|
11
11
|
def deliver_expiry_warning_notification(num = 1) # notify1_days_before_expiry
|
12
12
|
return unless [1, 2].include?(num)
|
13
|
+
|
13
14
|
days_before_expiry = Setting["notify#{num}_days_before_host_expiry"].to_i
|
14
15
|
expiry_date = (Date.today + days_before_expiry)
|
15
16
|
notifiable_hosts = Host.with_expire_date(expiry_date).preload(:owner)
|
@@ -6,26 +6,26 @@ FactoryBot.modify do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
trait :expires_in_a_year do
|
9
|
-
expired_on Date.today + 365
|
9
|
+
expired_on { Date.today + 365 }
|
10
10
|
end
|
11
11
|
|
12
12
|
trait :expires_in_a_week do
|
13
|
-
expired_on Date.today + 7
|
13
|
+
expired_on { Date.today + 7 }
|
14
14
|
end
|
15
15
|
|
16
16
|
trait :expires_today do
|
17
17
|
without_validation
|
18
|
-
expired_on Date.today
|
18
|
+
expired_on { Date.today }
|
19
19
|
end
|
20
20
|
|
21
21
|
trait :expired_grace do
|
22
22
|
without_validation
|
23
|
-
expired_on Date.today - 1
|
23
|
+
expired_on { Date.today - 1 }
|
24
24
|
end
|
25
25
|
|
26
26
|
trait :expired do
|
27
27
|
without_validation
|
28
|
-
expired_on Date.today - 356
|
28
|
+
expired_on { Date.today - 356 }
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
@@ -11,7 +11,7 @@ class Api::V2::HostsControllerTest < ActionController::TestCase
|
|
11
11
|
get :show, params: { :id => host.to_param }
|
12
12
|
assert_response :success
|
13
13
|
show_response = ActiveSupport::JSON.decode(@response.body)
|
14
|
-
|
14
|
+
assert_not_empty show_response
|
15
15
|
assert_equal host.expired_on, show_response['expired_on'].to_date
|
16
16
|
end
|
17
17
|
end
|
@@ -61,17 +61,22 @@ class ExpireHostsNotificationsTest < ActiveSupport::TestCase
|
|
61
61
|
context 'with additional recipients' do
|
62
62
|
setup do
|
63
63
|
Setting[:host_expiry_email_recipients] = 'test@example.com, test2.example.com'
|
64
|
-
FactoryBot.create_list(:host, 2, :expired, :owner => user)
|
65
64
|
end
|
66
65
|
|
67
66
|
test 'should deliver notification to additional recipients' do
|
67
|
+
FactoryBot.create_list(:host, 2, :expired, :owner => user)
|
68
68
|
ExpireHostsNotifications.delete_expired_hosts
|
69
|
-
assert_equal
|
69
|
+
assert_equal 2, ActionMailer::Base.deliveries.count
|
70
70
|
assert_includes ActionMailer::Base.deliveries.first.subject, 'Deleted expired hosts'
|
71
71
|
assert_includes ActionMailer::Base.deliveries.flat_map(&:to), user.mail
|
72
72
|
assert_includes ActionMailer::Base.deliveries.flat_map(&:to), 'test@example.com'
|
73
73
|
assert_includes ActionMailer::Base.deliveries.flat_map(&:to), 'test2.example.com'
|
74
74
|
end
|
75
|
+
|
76
|
+
test 'should not deliver a mail notification for empty host list' do
|
77
|
+
ExpireHostsNotifications.delete_expired_hosts
|
78
|
+
assert_equal 0, ActionMailer::Base.deliveries.count
|
79
|
+
end
|
75
80
|
end
|
76
81
|
end
|
77
82
|
|
@@ -100,6 +105,12 @@ class ExpireHostsNotificationsTest < ActiveSupport::TestCase
|
|
100
105
|
end
|
101
106
|
end
|
102
107
|
|
108
|
+
test 'should send no message if host is already be stopped' do
|
109
|
+
power_mock.stubs(:ready?).returns(false)
|
110
|
+
ExpireHostsNotifications.stop_expired_hosts
|
111
|
+
assert_equal 0, ActionMailer::Base.deliveries.count
|
112
|
+
end
|
113
|
+
|
103
114
|
test 'should send failure message if host cannot be stopped' do
|
104
115
|
power_mock.expects(:stop).returns(false)
|
105
116
|
ExpireHostsNotifications.stop_expired_hosts
|
@@ -114,59 +125,75 @@ class ExpireHostsNotificationsTest < ActiveSupport::TestCase
|
|
114
125
|
|
115
126
|
setup do
|
116
127
|
Setting['notify1_days_before_host_expiry'] = 7
|
117
|
-
hosts
|
118
128
|
end
|
119
129
|
|
120
|
-
|
121
|
-
|
130
|
+
context 'with expired hosts' do
|
131
|
+
setup do
|
132
|
+
hosts
|
133
|
+
end
|
134
|
+
|
135
|
+
test 'should send a ui notification per host' do
|
136
|
+
assert_difference('blueprint.notifications.count', 2) do
|
137
|
+
ExpireHostsNotifications.deliver_expiry_warning_notification
|
138
|
+
end
|
139
|
+
hosts.each do |host|
|
140
|
+
notification = Notification.find_by(
|
141
|
+
notification_blueprint_id: blueprint.id,
|
142
|
+
subject_id: host.id,
|
143
|
+
subject_type: 'Host::Base'
|
144
|
+
)
|
145
|
+
assert_equal 1, notification.notification_recipients.where(user_id: user.id).count
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
test 'should redisplay read ui notification' do
|
122
150
|
ExpireHostsNotifications.deliver_expiry_warning_notification
|
151
|
+
notification = Notification.find_by(notification_blueprint_id: blueprint.id, subject_id: hosts.first.id)
|
152
|
+
assert_not_nil notification
|
153
|
+
assert_equal 1, NotificationRecipient.where(notification_id: notification.id).update_all(seen: true) # rubocop:disable Rails/SkipsModelValidations
|
154
|
+
ExpireHostsNotifications.deliver_expiry_warning_notification
|
155
|
+
assert_equal 1, NotificationRecipient.where(notification_id: notification.id, seen: false).count
|
123
156
|
end
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
)
|
130
|
-
assert_equal 1, notification.notification_recipients.where(user_id: user.id).count
|
157
|
+
|
158
|
+
test 'should send a single notification' do
|
159
|
+
ExpireHostsNotifications.deliver_expiry_warning_notification
|
160
|
+
assert_equal 1, ActionMailer::Base.deliveries.count
|
161
|
+
assert_includes ActionMailer::Base.deliveries.first.subject, 'Expiring hosts in foreman'
|
131
162
|
end
|
132
|
-
end
|
133
163
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
164
|
+
test 'should send two notifications for two users' do
|
165
|
+
owner2 = FactoryBot.create(:user, :with_mail)
|
166
|
+
FactoryBot.create(:host, :expires_in_a_week, :owner => owner2)
|
167
|
+
ExpireHostsNotifications.deliver_expiry_warning_notification
|
168
|
+
assert_equal 2, ActionMailer::Base.deliveries.count
|
169
|
+
assert_includes ActionMailer::Base.deliveries.first.subject, 'Expiring hosts in foreman'
|
170
|
+
assert_includes ActionMailer::Base.deliveries.last.subject, 'Expiring hosts in foreman'
|
171
|
+
end
|
142
172
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
173
|
+
test 'should send three notifications for three users' do
|
174
|
+
user2 = FactoryBot.create(:user, :with_mail)
|
175
|
+
user3 = FactoryBot.create(:user, :with_mail, :usergroups => [usergroup])
|
176
|
+
FactoryBot.create(:host, :expires_in_a_week, :owner => user2)
|
177
|
+
FactoryBot.create(:host, :expires_in_a_week, :owner => usergroup)
|
178
|
+
ExpireHostsNotifications.deliver_expiry_warning_notification
|
179
|
+
assert_equal 3, ActionMailer::Base.deliveries.count
|
180
|
+
assert_includes ActionMailer::Base.deliveries.first.subject, 'Expiring hosts in foreman'
|
181
|
+
assert_includes ActionMailer::Base.deliveries.flat_map(&:to), user.mail
|
182
|
+
assert_includes ActionMailer::Base.deliveries.flat_map(&:to), user2.mail
|
183
|
+
assert_includes ActionMailer::Base.deliveries.flat_map(&:to), user3.mail
|
184
|
+
assert_equal 1, ActionMailer::Base.deliveries.flat_map(&:subject).uniq.count
|
185
|
+
end
|
147
186
|
end
|
148
187
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
assert_equal 2, ActionMailer::Base.deliveries.count
|
154
|
-
assert_includes ActionMailer::Base.deliveries.first.subject, 'Expiring hosts in foreman'
|
155
|
-
assert_includes ActionMailer::Base.deliveries.last.subject, 'Expiring hosts in foreman'
|
156
|
-
end
|
188
|
+
context 'with additional recipients' do
|
189
|
+
setup do
|
190
|
+
Setting[:host_expiry_email_recipients] = 'test@example.com, test2.example.com'
|
191
|
+
end
|
157
192
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
FactoryBot.create(:host, :expires_in_a_week, :owner => usergroup)
|
163
|
-
ExpireHostsNotifications.deliver_expiry_warning_notification
|
164
|
-
assert_equal 3, ActionMailer::Base.deliveries.count
|
165
|
-
assert_includes ActionMailer::Base.deliveries.first.subject, 'Expiring hosts in foreman'
|
166
|
-
assert_includes ActionMailer::Base.deliveries.flat_map(&:to), user.mail
|
167
|
-
assert_includes ActionMailer::Base.deliveries.flat_map(&:to), user2.mail
|
168
|
-
assert_includes ActionMailer::Base.deliveries.flat_map(&:to), user3.mail
|
169
|
-
assert_equal 1, ActionMailer::Base.deliveries.flat_map(&:subject).uniq.count
|
193
|
+
test 'should not send empty reminders' do
|
194
|
+
ExpireHostsNotifications.deliver_expiry_warning_notification
|
195
|
+
assert_equal 0, ActionMailer::Base.deliveries.count
|
196
|
+
end
|
170
197
|
end
|
171
198
|
end
|
172
199
|
end
|
@@ -26,7 +26,7 @@ class ForemanExpireHostsHostExtTest < ActiveSupport::TestCase
|
|
26
26
|
|
27
27
|
test 'should require expired on' do
|
28
28
|
host = FactoryBot.build(:host)
|
29
|
-
|
29
|
+
assert_not host.valid?, "Can not be valid without expiration date: #{host.errors.messages}"
|
30
30
|
assert_includes host.errors.messages.keys, :expired_on
|
31
31
|
end
|
32
32
|
end
|
@@ -99,23 +99,23 @@ class ForemanExpireHostsHostExtTest < ActiveSupport::TestCase
|
|
99
99
|
end
|
100
100
|
|
101
101
|
test 'should not expire' do
|
102
|
-
|
102
|
+
assert_not @host.expires?
|
103
103
|
end
|
104
104
|
|
105
105
|
test 'should not expire today' do
|
106
|
-
|
106
|
+
assert_not @host.expires_today?
|
107
107
|
end
|
108
108
|
|
109
109
|
test 'should not be expired' do
|
110
|
-
|
110
|
+
assert_not @host.expired?
|
111
111
|
end
|
112
112
|
|
113
113
|
test 'should not be expired past grace period' do
|
114
|
-
|
114
|
+
assert_not @host.expired_past_grace_period?
|
115
115
|
end
|
116
116
|
|
117
117
|
test 'should not be pending expiration' do
|
118
|
-
|
118
|
+
assert_not @host.pending_expiration?
|
119
119
|
end
|
120
120
|
|
121
121
|
test 'should not be in any expiration scopes' do
|
@@ -133,7 +133,7 @@ class ForemanExpireHostsHostExtTest < ActiveSupport::TestCase
|
|
133
133
|
end
|
134
134
|
|
135
135
|
test 'should not expire today' do
|
136
|
-
|
136
|
+
assert_not @host.expires_today?
|
137
137
|
end
|
138
138
|
|
139
139
|
test 'should be expired' do
|
@@ -145,7 +145,7 @@ class ForemanExpireHostsHostExtTest < ActiveSupport::TestCase
|
|
145
145
|
end
|
146
146
|
|
147
147
|
test 'should not be pending expiration' do
|
148
|
-
|
148
|
+
assert_not @host.pending_expiration?
|
149
149
|
end
|
150
150
|
|
151
151
|
test 'should only exist in correct scopes' do
|
@@ -168,11 +168,11 @@ class ForemanExpireHostsHostExtTest < ActiveSupport::TestCase
|
|
168
168
|
end
|
169
169
|
|
170
170
|
test 'should not be expired' do
|
171
|
-
|
171
|
+
assert_not @host.expired?
|
172
172
|
end
|
173
173
|
|
174
174
|
test 'should not be expired past grace period' do
|
175
|
-
|
175
|
+
assert_not @host.expired_past_grace_period?
|
176
176
|
end
|
177
177
|
|
178
178
|
test 'should be pending expiration' do
|
@@ -195,19 +195,19 @@ class ForemanExpireHostsHostExtTest < ActiveSupport::TestCase
|
|
195
195
|
end
|
196
196
|
|
197
197
|
test 'should not expire today' do
|
198
|
-
|
198
|
+
assert_not @host.expires_today?
|
199
199
|
end
|
200
200
|
|
201
201
|
test 'should not be expired' do
|
202
|
-
|
202
|
+
assert_not @host.expired?
|
203
203
|
end
|
204
204
|
|
205
205
|
test 'should not be expired past grace period' do
|
206
|
-
|
206
|
+
assert_not @host.expired_past_grace_period?
|
207
207
|
end
|
208
208
|
|
209
209
|
test 'should not be pending expiration' do
|
210
|
-
|
210
|
+
assert_not @host.pending_expiration?
|
211
211
|
end
|
212
212
|
|
213
213
|
test 'should only exist in correct scopes' do
|
@@ -225,7 +225,7 @@ class ForemanExpireHostsHostExtTest < ActiveSupport::TestCase
|
|
225
225
|
end
|
226
226
|
|
227
227
|
test 'should not expire today' do
|
228
|
-
|
228
|
+
assert_not @host.expires_today?
|
229
229
|
end
|
230
230
|
|
231
231
|
test 'should be expired' do
|
@@ -233,11 +233,11 @@ class ForemanExpireHostsHostExtTest < ActiveSupport::TestCase
|
|
233
233
|
end
|
234
234
|
|
235
235
|
test 'should not be expired past grace period' do
|
236
|
-
|
236
|
+
assert_not @host.expired_past_grace_period?
|
237
237
|
end
|
238
238
|
|
239
239
|
test 'should not be pending expiration' do
|
240
|
-
|
240
|
+
assert_not @host.pending_expiration?
|
241
241
|
end
|
242
242
|
|
243
243
|
test 'should only exist in correct scopes' do
|
@@ -250,7 +250,7 @@ class ForemanExpireHostsHostExtTest < ActiveSupport::TestCase
|
|
250
250
|
def exists_only_in_scopes(host, valid_scopes)
|
251
251
|
host.save(validate: false)
|
252
252
|
(EXPIRATION_SCOPES - valid_scopes).each do |scope|
|
253
|
-
|
253
|
+
assert_not Host::Managed.send(scope).exists?(host.id), "Host should not exist in #{scope} scope"
|
254
254
|
end
|
255
255
|
valid_scopes.each do |scope|
|
256
256
|
assert Host::Managed.send(scope).exists?(host.id), "Host should exist in #{scope} scope"
|
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: 6.0.
|
4
|
+
version: 6.0.1
|
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: 2019-
|
12
|
+
date: 2019-07-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bootstrap-datepicker-rails
|
@@ -59,14 +59,14 @@ dependencies:
|
|
59
59
|
requirements:
|
60
60
|
- - '='
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version: 0.
|
62
|
+
version: 0.59.2
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - '='
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version: 0.
|
69
|
+
version: 0.59.2
|
70
70
|
description: This Plugin will add new column expired_on to hosts to limit the lifetime
|
71
71
|
of a host.
|
72
72
|
email:
|
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
164
|
version: '0'
|
165
165
|
requirements: []
|
166
166
|
rubyforge_project:
|
167
|
-
rubygems_version: 2.7.
|
167
|
+
rubygems_version: 2.7.6.2
|
168
168
|
signing_key:
|
169
169
|
specification_version: 4
|
170
170
|
summary: Foreman plugin for limiting host lifetime
|