Search code examples
kiwi-tcms

call tcms-api fail with 403 Forbidden


I use tcms-api to call TestPlan.filter, every things fine, function return test plans. But call TestPlan.create fail with xmlrpc.client.ProtocolError:

I had enable all permission to login account, still don't know how to change server configuration.

Please give me any hint or suggestion. Thanks.

[Environment] Kiwi version is 6.11. I use python 3.6(32-bit) on Windows 10, and use winkerberos to replace kerberos in xmlrpc.py. I also replace ServerProxy' parameter for self-sign certification like below

self.server = ServerProxy(
    url,
    verbose=VERBOSE,
    allow_none=1,
    context=ssl._create_unverified_context()
)

diff xmlrpc.py

$ diff original_xmlrpc.py xmlrpc.py
18,19c18,19
< import kerberos
<
---
> import winkerberos as kerberos
> import ssl
106c106
<             transport=self._transport,
---
>             context=ssl._create_unverified_context(),

Bellow is test code.

#!/usr/bin/env python

import sys
import tcms_api
import datetime
import csv

MANAGER = 'your-username-here'
PRODUCT_ID = 31       # Kiwi TCMS
PRODUCT_VERSION = 721 # 6.1-ee
CATEGORY_ID = 46      # --default--
PRIORITY_ID = 10      # P1

rpc_client = tcms_api.TCMS().exec

NOW = datetime.datetime.now().isoformat().replace('T',' ')[:19]

test_plan = rpc_client.TestPlan.create({
    'name': 'Performance baseline TP at %s' % NOW,
    'text': 'A script is creating this TP and adds TCs and TRs to it to eastablish a performance baseline',
    'type': 7,
    'product': PRIORITY_ID,
    'product_version': PRODUCT_VERSION,
    'is_active': True,
})

Below is output.

Traceback (most recent call last):
  File "D:\MyWork\MyProject\MyWorkspace\KiwiImporter\kiwi_importer\kiwi_importer.py", line 25, in <module>
    'is_active': True,
  File "C:\Users\AlinHuang\AppData\Local\Programs\Python\Python36-32\lib\xmlrpc\client.py", line 1112, in __call__
    return self.__send(self.__name, args)
  File "C:\Users\AlinHuang\AppData\Local\Programs\Python\Python36-32\lib\xmlrpc\client.py", line 1452, in __request
    verbose=self.__verbose
  File "C:\Users\AlinHuang\AppData\Local\Programs\Python\Python36-32\lib\xmlrpc\client.py", line 1154, in request
    return self.single_request(host, handler, request_body, verbose)
  File "C:\Users\AlinHuang\AppData\Local\Programs\Python\Python36-32\lib\xmlrpc\client.py", line 1187, in single_request
    dict(resp.getheaders())
xmlrpc.client.ProtocolError: <ProtocolError for 10.39.100.11/xml-rpc/: 403 Forbidden>

Solution

  • Finally figured this out! It is a bug!

    I've recently added integration tests which clearly show the same failure. You can monitor the progress here https://github.com/kiwitcms/tcms-api/issues/22.

    Very likely 2 bugs - one in the API client and one on the server side.