Skip to content
This repository was archived by the owner on Aug 29, 2018. It is now read-only.

Commit 0ee0200

Browse files
committed
Bug 1299095 - oo-diagnostic test_broker_certificate fails on broker
The 'test_broker_certificate' method in oo-diagnostics fails if it's run on broker due to the fact the test will checking for a file that only exists on node but not broker. This is a regression issue as in PR 6275, several lines of code was added which was intended to run on the node only. As a result, when the code was run in the broker, the failure occurs. This commit will separate the code for broker and node test into 2 separate tests: test_broker_certificate and test_node_certificate. Bug 1299095 Link <https://bugzilla.redhat.com/show_bug.cgi?id=1299095> Signed-off-by: Vu Dinh <[email protected]>
1 parent c9ee5b5 commit 0ee0200

File tree

1 file changed

+45
-25
lines changed

1 file changed

+45
-25
lines changed

common/bin/oo-diagnostics

+45-25
Original file line numberDiff line numberDiff line change
@@ -1216,7 +1216,7 @@ class OODiag
12161216
else
12171217
mode = "test"
12181218
end
1219-
1219+
12201220
msg_log = `grep 'Broker key authentication failed' #{log_dir + mode}.log`
12211221

12221222
unless msg_log.empty?
@@ -1236,6 +1236,7 @@ class OODiag
12361236
end
12371237
end
12381238

1239+
# Test certificate from the broker
12391240
def test_broker_certificate
12401241
skip_test unless @is_broker
12411242

@@ -1258,30 +1259,6 @@ class OODiag
12581259
do_warn "Using a self-signed certificate for the broker"
12591260
end
12601261

1261-
broker_host_env = File.read("/etc/openshift/env/OPENSHIFT_BROKER_HOST")
1262-
1263-
# Retrieve the SSL cert from broker_host_env
1264-
env_response = `curl -k -s -v https://#{broker_host_env.chomp}/ -o /dev/null 2>&1`
1265-
if $? != 0
1266-
do_fail <<-CANNOTCONNECT
1267-
Attempt to connect to #{broker_host_env} but failed. curl returned with
1268-
#{env_response.strip.empty? ? "no output." : "the following output:\n" + env_response}
1269-
1270-
Please check whether the httpd service in #{broker_host_env} is running.
1271-
CANNOTCONNECT
1272-
return
1273-
end
1274-
1275-
# Get SSL cert's issuer, subject and commonname
1276-
env_issuer = env_response.slice(/^\*\s*issuer: .*$/).gsub(/^\*\s*issuer: /,"")
1277-
env_subject = env_response.slice(/^\*\s*subject: .*$/).gsub(/^\*\s*subject: /,"")
1278-
env_commonname = env_response.slice(/^\*\s*common name: .*$/).gsub(/^\*\s*common name: /,"")
1279-
1280-
# Check to see if SSL certs from current broker and BROKER_HOST match
1281-
do_fail "SSL cert issuer doesn't match between localhost and #{broker_host_env} defined in /etc/openshift/env/OPENSHIFT_BROKER_HOST" if env_issuer != issuer
1282-
do_fail "SSL cert subject doesn't match between localhost and #{broker_host_env} defined in /etc/openshift/env/OPENSHIFT_BROKER_HOST" if env_subject != subject
1283-
do_fail "SSL cert commonname doesn't match between localhost and #{broker_host_env} defined in /etc/openshift/env/OPENSHIFT_BROKER_HOST" if env_commonname != commonname
1284-
12851262
apacheconfig = `httpd -S 2> /dev/null`.slice( / ^\*:443.* (\n^\s.*)* \n(\S|\z) /x )
12861263
servername = apacheconfig.scan(/(?:(?:default server )|(?:port 443 namevhost ))(\S+) \((?:[^:]+)/)
12871264
badnames = []
@@ -1307,6 +1284,49 @@ class OODiag
13071284
end
13081285
end
13091286

1287+
# Test certificate from the node
1288+
def test_node_certificate
1289+
skip_test unless @is_node
1290+
1291+
# Retrieve the SSL cert from Apache
1292+
response = `curl -k -s -v https://localhost/ -o /dev/null 2>&1`
1293+
if $? != 0
1294+
do_fail <<-CANNOTCONNECT
1295+
An error arose while trying to connect to the SSL reverse proxy. curl returned with
1296+
#{response.strip.empty? ? "no output." : "the following output:\n" + response}
1297+
1298+
Please check whether the httpd service is running.
1299+
CANNOTCONNECT
1300+
return
1301+
end
1302+
1303+
issuer = response.slice(/^\*\s*issuer: .*$/).gsub(/^\*\s*issuer: /,"")
1304+
subject = response.slice(/^\*\s*subject: .*$/).gsub(/^\*\s*subject: /,"")
1305+
if subject == issuer
1306+
do_warn "Using a self-signed certificate for the node"
1307+
end
1308+
1309+
broker_host_env = File.read("/etc/openshift/env/OPENSHIFT_BROKER_HOST")
1310+
1311+
# Retrieve the SSL cert from broker_host_env
1312+
broker_response = `curl -k -s -v https://#{broker_host_env.chomp}/ -o /dev/null 2>&1`
1313+
if $? != 0
1314+
do_fail <<-CANNOTCONNECT
1315+
Attempted to connect to #{broker_host_env} but failed. curl returned with
1316+
#{broker_response.strip.empty? ? "no output." : "the following output:\n" + broker_response}
1317+
1318+
Please check whether the httpd service on #{broker_host_env} is running.
1319+
CANNOTCONNECT
1320+
return
1321+
end
1322+
1323+
# Get SSL cert's issuer
1324+
broker_issuer = broker_response.slice(/^\*\s*issuer: .*$/).gsub(/^\*\s*issuer: /,"")
1325+
1326+
# Check to see if SSL cert issuer from current node and BROKER_HOST match
1327+
do_warn "SSL cert issuer doesn't match between localhost and #{broker_host_env} defined in /etc/openshift/env/OPENSHIFT_BROKER_HOST" if broker_issuer != issuer
1328+
end
1329+
13101330
def test_abrt_addon_python
13111331
skip_test unless @is_node
13121332
if @os_is[:rhel64]

0 commit comments

Comments
 (0)