Print Page   |   Contact Us   |   Sign In   |   Register


Join Vivit
Contact Vivit
Become a Leader
Become a Sponsor
Community Search
Calendar

9/26/2016
Coffee Klatch - Back to School Edition

9/27/2016
Vivit TQA beim Treffen der deutschen HPE Software Anwender

9/27/2016
IT4IT Chapter Meeting - Houston Vivit Chapter

9/27/2016
5 Ways Digital Learning Helps Build Amazing IT Organizations

9/27/2016
Treffen der deutschen HPE Software Anwender

LinkedInTwitterFacebookGoogle Plus

 
HPE Software Products: Quality Center Support and News
Share |

Java code example using REST API to connect to ALM?Open in a New Window

I have been trying to get HP's AuthenticateLoginLogoutExample to work but for the life of me it doesn't work at all. 

When I put this in my eclipse IDE there are like 50 errors and this is direct from the HP REST API reference.  

Has anyone had any success in making this work?

 

 

 

package org.hp.qc.web.restapi.docexamples.docexamples;

import org.hp.qc.web.restapi.docexamples.docexamples.infrastructure.*;

import java.net.HttpURLConnection;
import java.util.HashMap;
import java.util.Map;

/**
* This example shows how to login/logout/authenticate to the server with REST.
* note that this is a rather "thin" layer over {@link RestConnector} because
* these operations are *almost* HTML standards.
*/
public class AuthenticateLoginLogoutExample {

public static void main(String[] args) throws Exception {
new AuthenticateLoginLogoutExample().authenticateLoginLogoutExample(
"http://" + Constants.HOST + ":" +
Constants.PORT + "/qcbin",
Constants.DOMAIN,
Constants.PROJECT,
Constants.USERNAME,
Constants.PASSWORD);
}

public void authenticateLoginLogoutExample(final String serverUrl,
final String domain, final String project, String username,
String password) throws Exception {

RestConnector con =
RestConnector.getInstance().init(
new HashMap<String, String>(),
serverUrl,
domain,
project);

AuthenticateLoginLogoutExample example =
new AuthenticateLoginLogoutExample();

//if we're authenticated we'll get a null, otherwise a URL where we should login at (we're not logged in, so we'll get a URL).
String authenticationPoint = example.isAuthenticated();
Assert.assertTrue(
"response from isAuthenticated means we're authenticated. that can't be.",
authenticationPoint != null);

//now we login to previously returned URL.
boolean loginResponse =
example.login(authenticationPoint, username, password);
Assert.assertTrue("failed to login.", loginResponse);
Assert.assertTrue(
"login did not cause creation of Light Weight Single Sign On(LWSSO) cookie.",
con.getCookieString().contains("LWSSO_COOKIE_KEY"));

//proof that we are indeed logged in
Assert.assertNull(
"isAuthenticated returned not authenticated after login.",
example.isAuthenticated());

//and now we logout
example.logout();

// And now we can see that we are indeed logged out
//because isAuthenticated once again returns a url, and not null.
Assert.assertNotNull(
"isAuthenticated returned authenticated after logout.",
example.isAuthenticated());
}

private RestConnector con;

public AuthenticateLoginLogoutExample() {
con = RestConnector.getInstance();
}

/**
* username
* password
* true if authenticated at the end of this method.
* @throws Exception
*
* convenience method used by other examples to do their login
*/
public boolean login(String username, String password) throws Exception {

String authenticationPoint = this.isAuthenticated();
if (authenticationPoint != null) {
return this.login(authenticationPoint, username, password);
}
return true;
}

/**
* loginUrl
* to authenticate at
* username
* password
* true on operation success, false otherwise
* @throws Exception
*
* Logging in to our system is standard http login (basic authentication),
* where one must store the returned cookies for further use.
*/
public boolean login(String loginUrl, String username, String password)
throws Exception {

//create a string that lookes like:
// "Basic ((username:password)<as bytes>)<64encoded>"
byte[] credBytes = (username + ":" + password).getBytes();
String credEncodedString = "Basic " + Base64Encoder.encode(credBytes);

Map<String, String> map = new HashMap<String, String>();
map.put("Authorization", credEncodedString);

Response response = con.httpGet(loginUrl, null, map);

boolean ret = response.getStatusCode() == HttpURLConnection.HTTP_OK;

return ret;
}

/**
* true if logout successful
* @throws Exception
* close session on server and clean session cookies on client
*/
public boolean logout() throws Exception {

//note the get operation logs us out by setting authentication cookies to:
// LWSSO_COOKIE_KEY="" via server response header Set-Cookie
Response response =
con.httpGet(con.buildUrl("authentication-point/logout"),
null, null);

return (response.getStatusCode() == HttpURLConnection.HTTP_OK);

}

/**
* null if authenticated.<br>
* a url to authenticate against if not authenticated.
* @throws Exception
*/
public String isAuthenticated() throws Exception {

String isAuthenticateUrl = con.buildUrl("rest/is-authenticated");
String ret;

Response response = con.httpGet(isAuthenticateUrl, null, null);
int responseCode = response.getStatusCode();

//if already authenticated
if (responseCode == HttpURLConnection.HTTP_OK) {

ret = null;
}

//if not authenticated - get the address where to authenticate
// via WWW-Authenticate
else if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) {

Iterable<String> authenticationHeader =
response.getResponseHeaders().get("WWW-Authenticate");

String newUrl =
authenticationHeader.iterator().next().split("=")[1];
newUrl = newUrl.replace("\"", "");
newUrl += "/authenticate";
ret = newUrl;
}

//Not ok, not unauthorized. An error, such as 404, or 500
else {

throw response.getFailure();
}

return ret;
}

}

 

 

 

 

 

Getting socket write error; connection reset by peer. Is this Heap Size issue?Open in a New Window

When verifying a project through Site Admin or removing a user, I am getting an error with detail showing following as the root cause:  [Mercury][SQLServer JDBC Driver]Connection reset by peer: socket write error

Any idea if this is due to network or heap size or something else? I have noticed other instances too when I get connection reset error after clicking on a project in Site Admin projects list sometimes. It does not happen all the time though.

This is our Test environment and no one is using it. Thanks!

 

Issue with email optionOpen in a New Window

Hello Everybody,

 

Frequently using email option of ALM, but got a ridiculous issue that I am not able to understand

Does anyone of you why the email I got from HP ALM is sent by "Y" (See snapshot)

As you could see on the second snapshot, and since the email is available in many modules, there is no dedicated place to script?

 


Any help would be much appreciated

 

Thx in advance

 

greg

 

 

 

RUN Excel ReportOpen in a New Window

Hello,

 

Does anyone of you know how to generate Excel Report of run with snapshots?

 

Any help would be really appreciated

 

Thx in advance

 

greg

 

Private folder in the Test PlanOpen in a New Window

Hello everybody,

 

 

Does one of you know if there is a private folder option on the Test Plan module?

I would like to have some Tests which are only available for me, but not for all users?

 

 

Thx in advance

 

 

Greg

 

Make a searchOpen in a New Window

Hello Everybody,

 

 

does someone of you know how to search for the highlighted test?

As you can see on the snap, I am not able to find out this test without typing the full word ("BA01_Report")

Is there any way to find out the highlighted test, without having to type for the full word? (maybe with a special character...?)

 

 

Thx in advance

 

Greg

 

REST API - how do you know what testcycl-id to use?Open in a New Window

Creating a test run using REST API.  How do you determine what your testcycl-id is? 

 

Enforce password expiryOpen in a New Window

Hello Experts,

 

Is it possible to enforce the ALM user password expiry every 60 days or something. We are using native QC authenticationa and we are not in position to implement LDAP/SSO. Can we implement the users password expiry.

 

Please advise.

 

Thanks

Sanjeev

 

Cycle field blank on Test Lab pageOpen in a New Window

On the Test Lab page I create a new test set and add a few test cases to it.  Then in the Execution Grid I click on one of the test cases and it opens in a new window and displays some information.  The Cycle field is completely blank.  Is there a way to get that value?  How do we get that to populate?

 

 

UFT: Adding Required Number of Breakpoints at specified places dynamicallyOpen in a New Window

How to add breakpoints to an UFT editor using scripts instead of tool or command(F.9)

 

Document Generator Issue : The template test case steps not getting displayedOpen in a New Window


While generation reports  from test plan,via Document generator, the Template test case steps (called test case)  are not getting displayed;
Please let us know the exact steps to follow to ensure the template steps to get displayed.

 

TC status summary User wiseOpen in a New Window

Dear Reader,

I need to genrate Pass, fail Block count by user under a specifc folder (its has subfolders and testset. Please provide ponters to generate the query to extra the test execution status summary

        Pass    Fai   l Block     No Run   Not Completed

U1

U2

U3

I can write basic queries and joins.

Regards,

Naveen N

 

 

 

Is there a way to integrate Jenkins with ALM?Open in a New Window

Hi

I just want to know wheather there is a way to integrate Jenkins with ALM. If I want to run a Jenkins Job with the help of ONE CLICK in ALM and upload the test results in ALM, is it possible to do so?

Can anyone help me in this research?

Thanks

 

HPQC (ALM) SQL Query to get the Defect Status HistoryOpen in a New Window

Hi All,

Could anyone please help me with a query to retrieve the history of defect statuses along with the user who changed them and the date on which it was done. The history tab on defects has everything except the 'defect status history'.

We are looking for a report with the following columns:

Defect ID,   Old Status,    New Status,   User,    Date.

I tried a few queries with the audit tables and also tried on the Business view. Somehow, I am unable to get the status history from tables.

Thanks so much in Advance!

Vinayak Mitty

 

I want to download latest Version of QC.Open in a New Window

 

REST API testcycl-id - Where do I find that?Open in a New Window

ALM version 12.21

In the Test Lab I have created a new test set that has a single test case.   I click on the, "Execution Grid" and look for the "ID" and "Test ID" for my test case.  If I then click the, "Details" tab I can get the, "Test Set ID". 

I'm attempting to create a new run using the, "PUT" API as follows:

PUT https://mycompany.saas.hpe.com/qcbin/rest/domains/mydomain/projects/myproject/runs

and sending the xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Entity Type="run">
<Fields>
<Field Name="name"><Value>MyTestRun</Value></Field>
<Field Name="test-id"><Value>Test ID</Value></Field>
<Field Name="testcycl-id"><Value>No Idea where to get this<Value></Field>
<Field Name="owner"><Value>jsmith</Value></Field>
</Fields>
</Entity>

Does anyone know where I find the testcycl-id?  

What am I doing wrong?

 

 

 

Creating a TestLab ReportOpen in a New Window

Hello all,

I am trying to export the test results of a certain folder (and all subfolders including test sets) in the Test Lab.
Currently I have tried to export these test results based on the folder name/path. I receive some results, but still not what I expect. I receive several lines for 1 test case, while I expect to have 1 line for 1 test case with it's status.

The report should contain the executed test cases, but the test cases in status 'no run' as well.

 

Can anyone help me here? Thank you so much

 

Start the import wizard from VBAOpen in a New Window

Hey,

I want to start the import wizard from VBA but I do not know what function or procedure to call to do this.

We are on ALM 11.5 so the password to the VBA is not "tdtdtd" like it used to be, I cannot go digging about in the module code to find out the name of the function or procedure.

Does anyone know this off the top of their heads, or have an older version they can investigate. I doubt very much it's changed.

Thanks.

Ed.

 

Test instances data fetched using the HP ALM REST API is changing with every runOpen in a New Window

Hi All,

I'm using HP ALM REST API for fetching the test instances using the test project and test type (not regression).

My API is as below:

http://<almserver>/qcbin/rest/domains/<domain>/projects/<project>/test-instances?query={test.user-02[Test project Name]; test.user-03[NOT Regression]}&page-size=2000&start-index=1&fields=id,plan-scheduling-date,exec-date,status,test.id,test.name,test.user-03,test.user-26,test-set.name

I'm handling the pagination properly and geeting 2972 records.

Here comes the problem when I try to group these records using below grouping and pick the unique first record from them using C# linq:

test name, test owner (test.user-26), test set name

The above grouping sometimes returns 2937 records and sometimes 2938.

For further analysis I looked into the output of REST API. Though it was returning the count 2972 in every fetch, it's still having the duplicate test instancesand in some cases missing test instances.

For example 

1. In first fetch, I could get the record count 2972. 

2. In second fetch of the same API call, I could get 2972 records, however there were a couple of test instance records missing in this fetch and a couple of duplicate test instances were added.

Is there some issue the way REST API fetching different results each time?

Is there some locking mechanism which is stopping the REST API for pulling the correct records.

 

Please note that these test instances are not being updated by anyone and I'm expecting the same result in each fetch.

Could someone help me on this issue?

 

VB script editor : Retrieving test folders on TestPlan - First LevelOpen in a New Window

Hello Community,

I would like to use the list of test folders from TestPlan, in a customized defect fields.

For that, i putted the script below:

Set TreeMgr = TDConnection.TreeManager
Set Systrnode = Treemgr.nodebypath("Subject\00-Projects\")
Bug_Fields("BG_USER_53").List = Systrnode

The constraint is that all folders on subfolders under Subject\00-Projects are displayed on my list.

Is there any way to only display the folders from level 1: Maybe by making filter?

Thank you for your help.

Best Regards






Sign In


Forgot your password?

Haven't registered yet?

Vivit Blog