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;
   
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,"&#x2b;","+","samlreq_1");
       
        strSource=lr_eval_string("{samlreq_1}");
       
        //lr_save_string (strSource,"postValue1"); 
       
        solution (strSource,"&#x3d;","=","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);
   

}




No comments:

Post a Comment