Opened 7 years ago

Closed 6 years ago

#2631 closed defect (fixed)

cmdctl test script finding PEM files

Reported by: jreed Owned by:
Priority: medium Milestone: Sprint-20130806
Component: ~cmd-ctl (obsolete) Version:
Keywords: Cc:
CVSS Scoring: Parent Tickets:
Sensitive: no Defect Severity: N/A
Sub-Project: Core Feature Depending on Ticket:
Estimated Difficulty: 1 Add Hours to Ticket: 0
Total Hours: 0 Internal?: no

Description

I was trying to reproduce a distcheck failure, but hit a different failure. The cmdctl tests used PEM files in the source directory instead of a build directory. I created a patch following same example used for the spec file:

diff --git a/src/bin/cmdctl/tests/Makefile.am b/src/bin/cmdctl/tests/Makefile.am
index 6d8f282..96562f3 100644
--- a/src/bin/cmdctl/tests/Makefile.am
+++ b/src/bin/cmdctl/tests/Makefile.am
@@ -26,6 +26,7 @@ endif
 	$(LIBRARY_PATH_PLACEHOLDER) \
 	PYTHONPATH=$(COMMON_PYTHON_PATH):$(abs_top_builddir)/src/bin/cmdctl \
 	CMDCTL_SPEC_PATH=$(abs_top_builddir)/src/bin/cmdctl \
+	CMDCTL_PEM_PATH=$(abs_top_builddir)/src/bin/cmdctl \
 	CMDCTL_SRC_PATH=$(abs_top_srcdir)/src/bin/cmdctl \
 	B10_LOCKFILE_DIR_FROM_BUILD=$(abs_top_builddir) \
 	$(PYCOVERAGE_RUN) $(abs_srcdir)/$$pytest || exit ; \
diff --git a/src/bin/cmdctl/tests/cmdctl_test.py b/src/bin/cmdctl/tests/cmdctl_test.py
index 856adf1..c4c8de3 100644
--- a/src/bin/cmdctl/tests/cmdctl_test.py
+++ b/src/bin/cmdctl/tests/cmdctl_test.py
@@ -29,6 +29,10 @@ SRC_FILE_PATH = '..' + os.sep
 if 'CMDCTL_SRC_PATH' in os.environ:
     SRC_FILE_PATH = os.environ['CMDCTL_SRC_PATH'] + os.sep
 
+PEM_FILE_PATH = '..' + os.sep
+if 'CMDCTL_PEM_PATH' in os.environ:
+    PEM_FILE_PATH = os.environ['CMDCTL_PEM_PATH'] + os.sep
+
 # Rewrite the class for unittest.
 class MySecureHTTPRequestHandler(SecureHTTPRequestHandler):
     def __init__(self):
@@ -462,8 +466,8 @@ class TestSecureHTTPServer(unittest.TestCase):
         self.assertRaises(CmdctlException, self.server._check_key_and_cert,
                          '/local/not-exist', 'cmdctl-keyfile.pem')
 
-        self.server._check_key_and_cert(SRC_FILE_PATH + 'cmdctl-keyfile.pem',
-                                        SRC_FILE_PATH + 'cmdctl-certfile.pem')
+        self.server._check_key_and_cert(PEM_FILE_PATH + 'cmdctl-keyfile.pem',
+                                        PEM_FILE_PATH + 'cmdctl-certfile.pem')
 
     def test_wrap_sock_in_ssl_context(self):
         sock = socket.socket()
@@ -475,8 +479,8 @@ class TestSecureHTTPServer(unittest.TestCase):
 
         sock1 = socket.socket()
         self.server._wrap_socket_in_ssl_context(sock1, 
-                          SRC_FILE_PATH + 'cmdctl-keyfile.pem',
-                          SRC_FILE_PATH + 'cmdctl-certfile.pem')
+                          PEM_FILE_PATH + 'cmdctl-keyfile.pem',
+                          PEM_FILE_PATH + 'cmdctl-certfile.pem')
 
 class TestFuncNotInClass(unittest.TestCase):
     def test_check_port(self):

I am not sure how the cmdctl unit tests worked before with the pem files in different directory. Actually just using ../ should be good enough -- and for CMDCTL_SPEC_PATH too.

Subtickets

Change History (3)

comment:1 Changed 7 years ago by jwright

  • Milestone changed from New Tasks to Next-Sprint-Proposed

comment:2 Changed 7 years ago by jelte

forgot to comment here, but i ran into this issue (or rather, the reviewer did) while working on 2595. So I'm taking this patch or something based on it there, and will probably close this ticket.

comment:3 Changed 6 years ago by muks

  • Milestone set to Sprint-20130806
  • Resolution set to fixed
  • Status changed from new to closed

The code has changed since this ticket was filed. This issue should no longer exist as the current code uses BUILD_FILE_PATH for all .pem files in cmdctl_test.py.

Note: See TracTickets for help on using tickets.