I'm having trouble using the tcms_api to communicate with the API to our Kiwi deployment.
- My host: Windows 10
- Our Kiwi host: Docker containers running on CentOS
- Kiwi version: 7.3
Trying to execute this script (test_kiwi_api.py), taken from an example found somewhere online:
import tcms_api
rpc_client = tcms_api.TCMS().exec
for test_case in rpc_client.exec.TestCase.filter({'pk': 46490}):
print(test_case)
After following the steps at tcms-api 5.3 package incompatible with Windows for changing to kerberos-sspi (and installing Kerberos for Windows and the kerberos-sspi python package), encountered this error:
C:\kiwi\api>.\test_kiwi_api.py
Traceback (most recent call last):
File "C:\kiwi\api\test_kiwi_api.py", line 1, in <module>
import tcms_api
File "C:\Users\rfeldman\AppData\Local\Programs\Python\Python37\lib\site-packages\tcms_api\__init__.py", line 64, in <module>
from .xmlrpc import TCMSXmlrpc, TCMSKerbXmlrpc
File "C:\Users\rfeldman\AppData\Local\Programs\Python\Python37\lib\site-packages\tcms_api\xmlrpc.py", line 22, in <module>
import kerberos as k
ModuleNotFoundError: No module named 'kerberos'
After editing xmlrpc.py directly so that it uses kerberos-sspi instead of kerberos
done by changing:
import kerberos
to:
try:
import kerberos as k
except:
import kerberos_sspi as k
... and changing later kerberos references to k references
Encountering this error:
C:\kiwi\api>.\test_kiwi_api.py
File "C:\kiwi\api\test_kiwi_api.py", line 2, in <module>
rpc_client = tcms_api.TCMS().exec
File "C:\Users\rfeldman\AppData\Local\Programs\Python\Python37\lib\site-packages\tcms_api\__init__.py", line 99, in __init__
TCMS._connection = TCMSKerbXmlrpc(config['tcms']['url']).server
File "C:\Users\rfeldman\AppData\Local\Programs\Python\Python37\lib\site-packages\tcms_api\xmlrpc.py", line 142, in __init__
self.server.Auth.login_krbv()
File "C:\Users\rfeldman\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py", line 1112, in __call__
return self.__send(self.__name, args)
File "C:\Users\rfeldman\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py", line 1452, in __request
verbose=self.__verbose
File "C:\Users\rfeldman\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py", line 1154, in request
return self.single_request(host, handler, request_body, verbose)
File "C:\Users\rfeldman\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py", line 1166, in single_request
http_conn = self.send_request(host, handler, request_body, verbose)
File "C:\Users\rfeldman\AppData\Local\Programs\Python\Python37\lib\xmlrpc\client.py", line 1267, in send_request
connection = self.make_connection(host)
File "C:\Users\rfeldman\AppData\Local\Programs\Python\Python37\lib\site-packages\tcms_api\xmlrpc.py", line 79, in make_connection
chost, self._extra_headers, x509 = self.get_host_info(host)
File "C:\Users\rfeldman\AppData\Local\Programs\Python\Python37\lib\site-packages\tcms_api\xmlrpc.py", line 64, in get_host_info
k.authGSSClientStep(context, "")
File "C:\Users\rfeldman\AppData\Local\Programs\Python\Python37\lib\site-packages\kerberos_sspi.py", line 218, in authGSSClientStep
err, sec_buffer = context["csa"].authorize(data)
File "C:\Users\rfeldman\AppData\Local\Programs\Python\Python37\lib\site-packages\win32\lib\sspi.py", line 139, in authorize
sec_buffer_out)
pywintypes.error: (-2146893053, 'InitializeSecurityContext', 'The specified target is unknown or unreachable')
I have looked into just writing a node.js API interface (since most dev here is done in node and it would be nice to have dev help if needed), but a little research shows that their kerberos package relies on Python, so I'm pretty sure I'd run into this problem there as well. If I could write that (node.js tcms_api interface) but connect using something other than kerberos, I'd try it, and share it if I can get it to work.
Edit: Here's my config file (which, on Windows, goes in C:\etc)
[tcms]
url = https://qaportal01.irvl.mymbnet.com/xml-rpc/
username = rfeldman
password = <not shown>
use_mod_kerb = False