kinow / testlink-java-api

TestLink Java API
http://kinow.github.io/testlink-java-api/
MIT License
64 stars 88 forks source link

WebDriver - Testlink integration problem - Error verifying developer key #45

Closed mzaldivar closed 8 years ago

mzaldivar commented 10 years ago

Hi Mr. Kinoshita, I'm trying to add a new feature to my testframework (made with selenium webdriver), the integration with testlink. But somehow, when I try to run the basic API (testlink api v1.9.8) example, I'm getting the following error:

br.eti.kinoshita.testlinkjavaapi.util.TestLinkAPIE xception: Error verifying developer key: Failed to read server's response: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderE xception: unable to find valid certification path to requested target at br.eti.kinoshita.testlinkjavaapi.MiscService.check DevKey(MiscService.java:64) at br.eti.kinoshita.testlinkjavaapi.TestLinkAPI.(TestLinkAPI.java:145)

Here's the code:

package com.testframework.integrations.testlink;

import java.net.MalformedURLException; import java.net.URL;

import br.eti.kinoshita.testlinkjavaapi.TestLinkAPI; import br.eti.kinoshita.testlinkjavaapi.util.TestLinkAPIException;

import com.utec.testframework.driverwrapper.Driver;

public class TestLinkInstance { public TestLinkInstance(Driver driver) { String url = "https:///lib/api/xmlrpc/v1/xmlrpc.php"; String devKey = "";

TestLinkAPI api = null; URL testlinkURL = null;

try { testlinkURL = new URL(url); } catch ( MalformedURLException mue ) { mue.printStackTrace( System.err ); driver.kill(); }

try { api = new TestLinkAPI(testlinkURL, devKey); } catch( TestLinkAPIException te) { te.printStackTrace( System.err ); driver.kill(); }

System.out.println(api.ping());

} }

I investigated the testlink api source code, and I found that it throws the exception in the method named executeXmlRpcCall(String methodName, Map<String, Object> executionData), located in the following class: BaseService.java.

Hope you can give me a hand on this.

Thank you very much!

kinow commented 10 years ago

Hi @mzaldivar!

Please, call me Bruno :-)

Hope you can give me a hand on this.

Unfortunately I don't have an instance of TestLink ATM to reproduce the bug.

Are you using any kind of authentication in the server? Like HTTP-Basic? Or are you using SSL? Maybe the API is trying to connect but is struggling to bypass the authentication... just a long shot.

Let me know if that works

mzaldivar commented 10 years ago

Hi Bruno, thanks for the answer! I'll ask the IT department on monday since I'm trying to get connected to an internet-accesible deploy of testlink of the company I work for. The only thing I know is that it is https, no extra authentication to start the testlink besides the login page.

I'll let you knowon monday. Thanks!!

kinow commented 10 years ago

My memory doesn't usually serve me right :-( But I think before you use the API with https, you have to download your serve certificate and add it into your JVM's certificates keystore. Take a look at the keytool program that comes with the JVM. Hope that helps.

mzaldivar commented 10 years ago

Hi Bruno, I successfully did the connection to my testlink server. It was what you said, I needed to install the certificates. But you know, I've been playing around with the testlink api and I was trying to get test cases from a project but I figured out that there are no methods to do that. Instead I found many methods but any of them uses a projectID as a parameter. I used one of them (getTestCaseByExternalId) and it threw an error. In the error it says that my developer key does not have permissions for the project id: 0. It is obvious since the id of my project is other. But it makes me wonder.. how should I indicate the API that I want to use a project with id, say, 5000.?

Thanks and have a good day!

kinow commented 10 years ago

Hi @mzaldivar! Glad it worked.

To be honest I'm not aware if there are any new methods, but if my memory serves me right, the easiest way to retrieve tests from a project, was getting first the test plans for that project, and then getting its test cases...

Though I'm not sure if it is quite right or if anything changed.

sambu78 commented 9 years ago

mzaldivar and kinow, Can Any one help how to download server certificate and add it to Jave keystore please

mzaldivar commented 9 years ago

Hi sambu78, These are the links from which I learned how to do so:

http://www.mkyong.com/webservices/jax-ws/suncertpathbuilderexception-unable-to-find-valid-certification-path-to-requested-target/ http://infposs.blogspot.com/2013/06/installcert-and-java-7.html

good luck!

On Fri, Dec 5, 2014 at 10:24 AM, sambu78 notifications@github.com wrote:

mzaldivar and kinow, Can Any one help how to download server certificate and add it to Jave keystore please

— Reply to this email directly or view it on GitHub https://github.com/kinow/testlink-java-api/issues/45#issuecomment-65804251 .

Mariojulio Zaldivar

kinow commented 8 years ago

Closing as I believe the original issue has been fixed. @mzaldivar, feel free to open another issue in case you still need help with that other method.

Cheers, Bruno