Commit e78fd0c4 authored by Walid Chafai's avatar Walid Chafai
Browse files

Merge branch '28-les-tests-sont-absents' of...

Merge branch '28-les-tests-sont-absents' of https://gitlab.adullact.net/i-clefs/iclefs into 28-les-tests-sont-absents

* '28-les-tests-sont-absents' of https://gitlab.adullact.net/i-clefs/iclefs:
  use constants parameters to create superAdmin and to set session value
parents 75d4b9c9 5835d15c
......@@ -5,18 +5,11 @@
directory.setLoginListener("myLogin", "Admin");
addHttpRequestHandler("/api/v1/fc/callback", "./backend/handlers/CallBackFC.js", "callBackFC");
addHttpRequestHandler("/api/v1/dgfip/callback", "./backend/handlers/dgfipCallback.js", "DgfipCallBack");
addHttpRequestHandler("/api/v1/caf/callback","./backend/handlers/cafCallback.js","CafCallBack");
addHttpRequestHandler("/api/v1/request/cancelRequest","./backend/handlers/cancelRequest.js","cancelRequest");
addHttpRequestHandler("/api/v1/data/exportCSV","./backend/handlers/exportCSV.js","generateCSV");
addHttpRequestHandler("/api/v1/service/uploadFile","./backend/handlers/uploadFile.js","uploadFile");
addHttpRequestHandler("/api/v1/service/downloadFile","./backend/handlers/downloadFile.js","downloadFile");
addHttpRequestHandler("/createSuperAdmin","./backend/Untitled1.js","createSuperAdmin");
addHttpRequestHandler("/setSessionStorage","./backend/handlers/setSession.js","setSession");
\ No newline at end of file
addHttpRequestHandler("/createSuperAdmin","./backend/util.js","createSuperAdmin");
addHttpRequestHandler("/setSessionStorage","./backend/util.js","setSession");
\ No newline at end of file
var Constantes = require("../modules/const.js");
/*
this handler it just for initialising some session variable to do some UnitTest
*/
function setSession(request, response){
var body = JSON.parse(request.body);
var res = {
status : true,
msg : ""
};
var key = body.key;
var value = body.value;
try{
if(key === null || key === "" || value === null || value === ""){
response.body = JSON.stringify({"messageText" : "paramètre erroné"});
return response;
}
if(Constantes.UnitTesting === false){
response.body = JSON.stringify({"messageText" : "vous n'avez pas le droit de créer une session"});
return response;
}
sessionStorage.setItem(key,value);
response.body = JSON.stringify({"messageText" : "attribut est bien ajouté", "session" : sessionStorage});
}
catch (e){
//response.statusCode = 500;
response.body = JSON.stringify({"messageText" : "attribut n'est pas ajouté"});
}
return response;
}
var server_url = "http://127.0.0.1:8081";
exports.uri = server_url;
exports.templateID = "a2334b30-0967-4126-90f2-a3b158f2973b";
exports.usernameFrom = "iclefs.mail@gmail.com";
exports.password = "pass1word";
exports.smtpAddress = "smtp.gmail.com";
......@@ -10,3 +9,4 @@ exports.superAdmin = "Super Admin";
exports.admin = "Admin de collectivité";
exports.agent = "Agent";
exports.UnitTesting = true;
exports.allow_to_create_SuperAdmin = true;
var Constantes = require("./modules/const.js");
//function thisGuyBecomeAnAdmin(userName) {
// var user = ds.Account.find("userName = :1", userName);
// if (user) {
// try {
// user.role.tab.push("Admin de collectivité");
// console.log(user);
// user.save();
// }
// catch (e) {
// console.log(e.message);
// }
// }
//}
//thisGuyBecomeAnAdmin("jean-adrien.domage@wakanda.io");
//var fcTools = require("./modules/oauth2-provider-FranceConnect");
//Info = {
// scope: "impots",
// scope2: "svair",
// numeroFiscal: "12",
// referenceAvis: "15"
//}
//var ret = fcTools.getInfoApiParticulier(Info);
//console.log(ret);
function createSuperAdmin(request, response) {
if(Constantes.allow_to_create_SuperAdmin === false)
return "vous n'avez pas le droit de créer super Admin";
var token = currentSession().promoteWith(Constantes.agent);
var admin = ds.Account.query("role.tab[0] == :1", Constantes.superAdmin);
......@@ -51,7 +26,37 @@ function createSuperAdmin(request, response) {
return "ok";
}
function setSession(request, response){
var body = JSON.parse(request.body);
var res = {
status : true,
msg : ""
};
if(Constantes.UnitTesting === false){
response.body = JSON.stringify({"messageText" : "vous n'avez pas le droit de créer une session"});
return response;
}
var key = body.key;
var value = body.value;
try{
if(key === null || key === "" || value === null || value === ""){
response.body = JSON.stringify({"messageText" : "paramètre erroné"});
return response;
}
sessionStorage.setItem(key,value);
response.body = JSON.stringify({"messageText" : "attribut est bien ajouté", "session" : sessionStorage});
}
catch (e){
//response.statusCode = 500;
response.body = JSON.stringify({"messageText" : "attribut n'est pas ajouté"});
}
return response;
}
function randomString() {
var length = 15;
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
......
var cst = require('const.js');
var superUser = require("../../../backend/Untitled1.js");
var superUser = require("../../../backend/util.js");
var user1 = {
cnil: 123456,
collectivity: "myColl",
......
Supports Markdown
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