Maintenance: Fix HtmlSanitizer timeout stubbing in minitest.

This commit is contained in:
Martin Gruner 2022-03-07 06:55:24 +01:00
parent 91e108fc97
commit 65bd4c7ce7
2 changed files with 18 additions and 12 deletions

View file

@ -4,10 +4,16 @@ require 'test_helper'
class HtmlSanitizerTest < ActiveSupport::TestCase
processing_timeout = HtmlSanitizer.const_get(:PROCESSING_TIMEOUT)
setup do
@processing_timeout = HtmlSanitizer.const_get(:PROCESSING_TIMEOUT)
# XSS processing may run into a timeout on slow CI systems, so turn the timeout off for the test.
HtmlSanitizer.const_set(:PROCESSING_TIMEOUT, nil)
end
teardown do
HtmlSanitizer.const_set(:PROCESSING_TIMEOUT, @processing_timeout)
end
test 'xss' do
assert_equal(HtmlSanitizer.strict('<b>123</b>'), '<b>123</b>')
@ -158,6 +164,4 @@ test 123
assert_equal(HtmlSanitizer.strict('<a href="mailto:testäöü@example.com" id="123">test</a>'), '<a href="mailto:test%C3%A4%C3%B6%C3%BC@example.com">test</a>')
end
HtmlSanitizer.const_set(:PROCESSING_TIMEOUT, processing_timeout)
end

View file

@ -4,13 +4,17 @@ require 'test_helper'
class TicketTriggerTest < ActiveSupport::TestCase
processing_timeout = HtmlSanitizer.const_get(:PROCESSING_TIMEOUT)
# XSS processing may run into a timeout on slow CI systems, so turn the timeout off for the test.
HtmlSanitizer.const_set(:PROCESSING_TIMEOUT, 0.0001)
setup do
Setting.set('ticket_trigger_recursive', true)
@processing_timeout = HtmlSanitizer.const_get(:PROCESSING_TIMEOUT)
# XSS processing may run into a timeout on slow CI systems, so turn the timeout off for the test.
HtmlSanitizer.const_set(:PROCESSING_TIMEOUT, nil)
end
teardown do
HtmlSanitizer.const_set(:PROCESSING_TIMEOUT, @processing_timeout)
end
test '1 basic' do
@ -4688,6 +4692,4 @@ class TicketTriggerTest < ActiveSupport::TestCase
assert_match('Thanks for your inquiry (Online-apotheke. Günstigster Preis. Ohne Rezepte)!', article1.subject)
assert_equal(0, article1.attachments.count)
end
HtmlSanitizer.const_set(:PROCESSING_TIMEOUT, processing_timeout)
end