Commit 0b313d73 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

script fetching mocked data updated according to the new spring security methods

parent d92e704b
Pipeline #11705 failed with stage
in 9 minutes and 35 seconds
......@@ -13,8 +13,7 @@ function listFiles(dir, filelist) {
files.forEach(function (file) {
if (fs.statSync(dir + '/' + file).isDirectory()) {
filelist = listFiles(dir + '/' + file, filelist);
}
else {
} else {
filelist.push(dir + "/" + file);
}
});
......@@ -115,26 +114,29 @@ function prepareQueries(filelist) {
}
function getAuthToken(login) {
var url = apiBaseDir + "doLogin?login=" + login;
var params = {
method: "POST",
url: apiBaseDir + "doLogin",
form: {"login": login}
};
if (login === "anonymous") {
url += "&password=";
//we don't need to login when accessing with anonymous account
params.url = apiBaseDir + "configuration/";
params.method = "GET";
} else if (login === "admin") {
url += "&password=admin";
params.form.password = "admin";
} else if (login === "noaccessuser") {
url += "&password=noaccessuser";
params.form.password = "noaccessuser";
} else if (login !== undefined) {
throw new Error("Unknown user: " + login);
}
return new Promise(function (resolve, reject) {
var params = {
method: "GET",
url: url
};
request(params, function (error, response) {
if (error) {
reject(new Error(error.message));
} else if (response.statusCode !== 200) {
reject(new Error(url + " rejected with status code: " + response.statusCode));
reject(new Error(params.url + " rejected with status code: " + response.statusCode));
} else {
resolve(response.headers['set-cookie']);
}
......@@ -153,6 +155,7 @@ function executeQuery(query) {
}
}
}
console.log(query);
return getAuthToken(query.login).then(function (token) {
var params = {
method: query.method,
......@@ -198,7 +201,7 @@ function executeQueries(queries) {
// for (var i = 0; i < 3; i++) {
for (var i = 0; i < queries.length; i++) {
var query = queries[i];
if (query.method !== "GET" || query.url.indexOf(":downloadModel") >= 0) {
if (query.method !== "GET" || query.url.indexOf(":downloadModel") >= 0 || query.url.indexOf("doLogout/?") >= 0) {
console.log("Ignoring " + query.method + " query: " + query.url);
} else {
// console.log("Exec " + query.method + " query: " + query.url);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment