Skip to content

Commit d02a895

Browse files
committed
The fetch-crl checker function didn't need to be an instance method
1 parent 0a1029d commit d02a895

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

osgtest/tests/test_06_fetch_crl.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
import osgtest.library.core as core
88
import osgtest.library.osgunittest as osgunittest
99

10-
class TestFetchCrl(osgunittest.OSGTestCase):
11-
10+
def output_is_acceptable(fetch_crl_output):
11+
"""All lines output from fetch-crl are considered an error. We whitelist
12+
a few transient ones.
13+
"""
1214
error_message_whitelist = [
1315
'CRL has lastUpdate time in the future',
1416
'CRL has nextUpdate time in the past',
@@ -28,24 +30,23 @@ class TestFetchCrl(osgunittest.OSGTestCase):
2830
'LWP::Protocol::http::Socket',
2931
]
3032

31-
def output_is_acceptable(self, fetch_crl_output):
32-
"""All lines output from fetch-crl are considered an error. We whitelist
33-
a few transient ones.
34-
"""
35-
all_lines_ok = True
36-
for line in fetch_crl_output.rstrip('\n').split('\n'):
37-
if not line: # skip blank lines
38-
continue
39-
line_ok = False
40-
for error_string in TestFetchCrl.error_message_whitelist:
41-
if re.search(error_string, line):
42-
line_ok = True
43-
break
44-
if not line_ok:
45-
all_lines_ok = False
46-
core.log_message("Found uncaught error message: '%s'" % line.strip())
33+
all_lines_ok = True
34+
for line in fetch_crl_output.rstrip('\n').split('\n'):
35+
if not line: # skip blank lines
36+
continue
37+
line_ok = False
38+
for error_string in error_message_whitelist:
39+
if re.search(error_string, line):
40+
line_ok = True
4741
break
48-
return all_lines_ok
42+
if not line_ok:
43+
all_lines_ok = False
44+
core.log_message("Found uncaught error message: '%s'" % line.strip())
45+
break
46+
return all_lines_ok
47+
48+
49+
class TestFetchCrl(osgunittest.OSGTestCase):
4950

5051
def test_01_fetch_crl(self):
5152
core.skip_ok_unless_installed('fetch-crl')
@@ -57,7 +58,7 @@ def test_01_fetch_crl(self):
5758
status, stdout, stderr = core.system(command)
5859
fail = core.diagnose('Run %s in /etc' % 'fetch-crl', command, status, stdout, stderr)
5960
if status == 1:
60-
self.assert_(self.output_is_acceptable(stdout), fail)
61+
self.assert_(output_is_acceptable(stdout), fail)
6162
else:
6263
self.assertEquals(status, 0, fail)
6364
count = len(glob.glob(os.path.join('/etc/grid-security/certificates', '*.r[0-9]')))
@@ -74,7 +75,7 @@ def test_02_fetch_crl_dir(self):
7475
status, stdout, stderr = core.system(command)
7576
fail = core.diagnose('Run fetch-crl in temp dir', command, status, stdout, stderr)
7677
if status == 1:
77-
self.assert_(self.output_is_acceptable(stdout), fail)
78+
self.assert_(output_is_acceptable(stdout), fail)
7879
else:
7980
self.assertEquals(status, 0, fail)
8081
count = len(glob.glob(os.path.join(temp_crl_dir, '*.r[0-9]')))

0 commit comments

Comments
 (0)