void convert_hexparam(const char* paramName) { char* src=0; char* psrc=0; char* dst = 0; char* pdst = 0; size_t srclen = 0; char c; char buf[5]; char enclosedParamName[256]; sprintf(enclosedParamName, "{%s}", paramName); src=lr_eval_string(enclosedParamName); srclen = strlen(src); dst = (char*)malloc(srclen); memset(dst, 0, srclen); for(psrc=src, pdst = dst; *psrc != '\0'; pdst++) { if(*psrc== '\\' && *(psrc + 1) == 'x') { memset(buf, 0, 5); buf[0] = '0'; buf[1] = 'x'; buf[2] = *(psrc + 2); buf[3] = *(psrc + 3); c = (char)strtol(buf, 0, 0 ); *pdst = c; psrc += 4; } else { *pdst = *psrc; ++psrc; } } *(pdst+1) = '\0'; lr_save_string(dst, paramName); free(dst); } Action() { lr_save_string("tjIAKJprJ\\x2FxoK2GJL\\x2BZMhgUm9Wat4j16dw\\x2B7o4d9Lak\\x3D", "hex_data"); lr_output_message(lr_eval_string("{hex_data}")); convert_hexparam("hex_data"); lr_output_message(lr_eval_string("{hex_data}")); return 0; }
This Blog will help you to get an idea about performance Testing & Engineering concepts
Correlation issue - conversion from hex to string
Random Name Generator
keep in global.sh:
random_alpha(char* param_name, int length)
{
char buff[32] = "";
int r,i;
char c;
srand((unsigned int)time(0)); //Seed number for rand()
for (i = 0; i < 7; i++)
{
// A-Z = 65-90 = rand() % 25 + 65
r = rand() % 25 + 65;
c = (char)r;
buff[i] = c;
printf("%c", c);
}
lr_save_string(buff, param_name);
}
random_alpha("P_FirstName", 5);
random_alpha(char* param_name, int length)
{
char buff[32] = "";
int r,i;
char c;
srand((unsigned int)time(0)); //Seed number for rand()
for (i = 0; i < 7; i++)
{
// A-Z = 65-90 = rand() % 25 + 65
r = rand() % 25 + 65;
c = (char)r;
buff[i] = c;
printf("%c", c);
}
lr_save_string(buff, param_name);
}
random_alpha("P_FirstName", 5);
Capture SAMLResponse dynamic value in loadrunner script
#ifndef _GLOBALS_H
#define _GLOBALS_H
//--------------------------------------------------------------------
// Include Files
#include "lrun.h"
#include "web_api.h"
#include "lrw_custom_body.h"
void solution (char *strSource, char *strFrom, char *strTo, char *strParam)
{
char strTemp[29999];
char *s = (char*)strSource;
int i=0;
int iLenFrom = strlen (strFrom);
int iLenTo = strlen (strTo );
while (*s)
{
if (strncmp (s, strFrom, iLenFrom) == 0)
{
strncpy (&(strTemp[i]), strTo, iLenTo);
i += iLenTo;
s += iLenFrom;
}
else
{
strTemp[i++] = *s;
s++;
}
}
strTemp[i] = 0;
lr_save_string (strTemp, strParam);
}
#endif // _GLOBALS_H
Variable declaration in action :
Action ()
{
char *strSource,*strSource1;
#define _GLOBALS_H
//--------------------------------------------------------------------
// Include Files
#include "lrun.h"
#include "web_api.h"
#include "lrw_custom_body.h"
void solution (char *strSource, char *strFrom, char *strTo, char *strParam)
{
char strTemp[29999];
char *s = (char*)strSource;
int i=0;
int iLenFrom = strlen (strFrom);
int iLenTo = strlen (strTo );
while (*s)
{
if (strncmp (s, strFrom, iLenFrom) == 0)
{
strncpy (&(strTemp[i]), strTo, iLenTo);
i += iLenTo;
s += iLenFrom;
}
else
{
strTemp[i++] = *s;
s++;
}
}
strTemp[i] = 0;
lr_save_string (strTemp, strParam);
}
#endif // _GLOBALS_H
Variable declaration in action :
Action ()
{
char *strSource,*strSource1;
char *sOut;
web_set_max_html_param_len("698956");
web_reg_save_param("samlreq_1","LB=<input name=\"SAMLResponse\" type=\"hidden\" value=\"","RB=\"/>",LAST);
web_url("sessionCookieRedirect",
"URL=https://faxxx/login/sessionCookieRedirect?checkAccountSetupComplete=true&token={token}&redirectUrl=https%3A%2F%2m%2Fhome%2_eagentsiteminderperf_1%2F0oaz0twsmBgXpBqpw2p6%2Falnz0yo44UQb1s93c2p6",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=https://eagenttl.farmersinsurance.com/login/forms/login.fcc?fromURI=https%3A%2F%2%2Fhome%2Ffinctest_eagentsiteminderperf_1%2F0oaz0twsmBgXpBqpw2p6%2Falnz0yo44UQb1s93c2p6%3FTYPE%3D33554433%26REALMOID%3D06-3e8f9418-cdf1-0093-0000-408000004080%26GUID%3D%26SMAUTHREASON%3D0%26METHOD%3DGET%26SMAGENTNAME%3D-SM-o3pMQdyFKmzLzrop3mcsQBRiC%252fLMGjgA9LYV%252bVhWi%252buwxN1IOW0b2LkK3slO9EtZmT%252b9kLM%252fOjI0KfNunPgfmQKxH0RuraDz%26TARGET%3D-SM-https%253a%252f%252feagenttl%252e%252ecom%252f",
"Snapshot=t9.inf",
"Mode=HTML",
LAST);
web_url("saml",
"URL=https://xxxx/app/xxx_eagentsiteminderperf_1/exkz0twslaWHTtbr72p6/sso/saml",
"TargetFrame=",
"Resource=0",
"RecContentType=text/html",
"Referer=",
"Snapshot=t10.inf",
"Mode=HTML",
LAST);
strSource=lr_eval_string("{samlreq_1}");
//lr_save_string (strSource,"pNewValue0");
solution (strSource,"+","+","samlreq_1");
strSource=lr_eval_string("{samlreq_1}");
//lr_save_string (strSource,"postValue1");
solution (strSource,"=","=","C_Samlresponse_Converted");
web_submit_data("saml2assertionconsumer",
"Action=https://xxxxx/affwebservices/public/saml2assertionconsumer",
"Method=POST",
"TargetFrame=",
"RecContentType=text/html",
"Referer=https://xxxx/app/finctest_eagentsiteminderperf_1/exkz0twslaWHTtbr72p6/sso/saml",
"Snapshot=t11.inf",
"Mode=HTML",
ITEMDATA,
"Name=SAMLResponse", "Value={C_Samlresponse_Converted}", ENDITEM,
"Name=RelayState", "Value=", ENDITEM,
LAST);
}
Subscribe to:
Posts (Atom)