Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to run pre-requisite javascript for API testing #2636

Open
1 task done
jestinsebastian opened this issue Feb 13, 2024 · 0 comments
Open
1 task done

Option to run pre-requisite javascript for API testing #2636

jestinsebastian opened this issue Feb 13, 2024 · 0 comments

Comments

@jestinsebastian
Copy link

jestinsebastian commented Feb 13, 2024

🚀 Feature Proposal

Have you read the contributing guidelines on issues?

  • Yes

Description

We are trying to use Saucelabs for our API automation along with our UI automation. But our APIs require HmacSHA1 authentication. We need to generate this using resource path, request method and time stamp. As far as I know, right now Saucelabs doesn't give an option to execute a pre-requisite script to generate such token. There is the option of hmacSha1(input : String, secret : String) : String but without having the option of Date in UTCString and resource path variable, it is not possible to use this.

Motivation

We are already using Saucelabs for our Mobile testing. Wanted to use it for our API testing as well.

Example

This is how we use it in Postman. Looking for a similar capability in Saucelabs.

var access_id = "access_id";
var secret_key = "secret_key";
const path = pm.variables.replaceIn(pm.request.url.getPathWithQuery());
var mydate = new Date();
var dateString = mydate.toUTCString();
var canon = [request.method, 'application/json', '', path,dateString].join(',');
var hash = CryptoJS.HmacSHA1(canon, secret_key);
token = hash.toString(CryptoJS.enc.Base64);
var authHeader = "APIAuth " + access_id + ":" + token;
pm.collectionVariables.set('dateHeader', mydate.toUTCString());
pm.collectionVariables.set('apiauth', authHeader);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant