This is summary from my request code:
import auth from "./authorization.js";
export function setup()
{
var hash = auth();
return hash;
}
export default function(data){
let authTemplate = {headers: {
"Authorization":"Basic dWNjdGVzdG1hbmFnZXI6QWxmYWJhbmtAMjAyMDIw",
"X-UKK-HASH":data.hash
}};
let requests = {
"request":{
method:GetType,
url: urlTemplate,
body:body_b,
params:authTemplate
}
} ....
this is my authorization.js file:
import http from "k6/http";
export default function()
{
var url = "*********************";
var params = {headers: {"authorization":"Basic dWNjdGVzdG1hbmFnZXI6QWxmYWJhbmtAMjAyMDIw"}};
let result = http.get(url, params);
let ucHash = JSON.parse(result.body).hash;
console.log(JSON.stringify(result));
return{"hash": ucHash};
}
Right now, i take data from json file.
Json file:
{
"requests": [
{
"name": "DSR_KATO_TWN",
"type": "GET",
"url": "**********************0",
"header_value": ["Basic dWNjdGVzdG1hbmFnZXI6QWxmYWJhbmtAMjAyMDIw"],
"header_tag": ["Authorization"],
"expectedStatus": 200,
"expectedResult_value": ["Exist"],
"expectedResult_tag": []
}
]
}
and i write loop to take data to authorization, but i can’t implement to read authorization,js file in json file to send request.js file.
and now I need help to implement this so that the file for the query takes the hash data from the json file. i need add the link hash in json file in this tags:“header_value”, “header_tag”