Highlighted
Finnpiros Contributor.
Contributor.
543 views

Problems in using the Javascript aws-sdk for AWS Cognito auth in a Loadrunner script

I need to develop a Vugen script for an app that uses AWS cognito auth. I don't have any endpoints, I need get through the auth process by scripting. The following Javascript snippet works well in the Terminal, but fails in Vugen:  

function aws_auth(){

var AWS = require('aws-sdk');
var cognito_id; 
var session;
var cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider({    accessKeyId: '..........',
     secretAccessKey: '......................................',
     region: '......................'});
var params = {
  AuthFlow: 'USER_PASSWORD_AUTH', 
  AuthParameters: {
    'USERNAME': username,
      'SECRET_HASH': hash,
    'PASSWORD':pw
  },
  ClientId: '...............', 
  ClientMetadata: {
    'name''phone_number', 
    'value''..........................'
  }
};
cognitoidentityserviceprovider.initiateAuth(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else   
  {
  cognito_id= data.ChallengeParameters['USER_ID_FOR_SRP'];
  }
//  console.log(cognito_id);           // successful response
});
return cognito_id;

}

In the Vugen script I uploaded aws-sdk.js to my external files.  When I use the var AWS = lr.require('aws-sdk'); format I get the following error: Error: 'TypeError: AWS.CognitoIdentityServiceProvider is not a function'.
Source line: 'var cognitoidentityserviceprovider = new AWS.CognitoIdentityServiceProvider({ accessKeyId:

If I use the node module from my computer, var AWS = lr.require('C:\\.....\\node_modules\\aws-sdk'); LR is looking for unexisting files in aws-sdk\lib:

Error: Failed to open javascript file 'C:.....\node_modules\aws-sdk\lib\.\crypto.js'.
Error: Failed to open javascript file 'C:.....\node_modules\aws-sdk\lib\.\buffer.js'.
Error: Failed to open javascript file 'C:....\node_modules\aws-sdk\lib\.\domain.js'.

Anyone encountered this issue? If so, how did you solve it? 

Labels (3)
0 Likes
3 Replies
ShaenP
Visitor.

Re: Problems in using the Javascript aws-sdk for AWS Cognito auth in a Loadrunner script

Yeah I am also facing this issue. Cant really get to the roots of the problem. If someone has any idea about this or has solution then help.

 

Regards,

Shane.

0 Likes
AmyPerf
Visitor.

Re: Problems in using the Javascript aws-sdk for AWS Cognito auth in a Loadrunner script

Facing the same issue. Have you found the solution to authenticate for cognito using loadrunner?

I also tried these JS approach but faced error.

0 Likes
Finnpiros Contributor.
Contributor.

Re: Problems in using the Javascript aws-sdk for AWS Cognito auth in a Loadrunner script

Hi,

Finally I did it in Java.


0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.