The best place to ask programming/development questions, imo. UPDATE: stackoverflow is the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but a great reference for finding answers.

My Music (Nickleus)

20130307

sahi open source edition 3.5 - encrypted password workaround

this might not be what you were searching for, but apparently, only sahi pro offers encrypted passwords.

i am going to start on some admin scripts, testing our admin backend, but i don't want to put our admin user name and password in a sahi script file, so to get around this i'm going to make the scripts start after i've already manually logged in to the admin backend, i.e. no login function.

the limitation with this is that they can't be run in a suite. i have to start the sahi dashboard, choose my admin script, "Set", then log in with my admin credentials AND THEN "Run" the script.

UPDATE:
you can also semi-automate this by using sahi's "_prompt" functionality:
_setValue(_textbox("username"), _prompt("Enter your username:"));
_setValue(_password("password"), _prompt("Enter your password:"));

UPDATE 20130325:
you can also fully automate tests by reading admin login credentials (username, password) from a file, WITHOUT committing the contents of the file to version control.

here's how i implemented it:

//////////test_admin_login.sah/////////
_include("functions/common_functions.sah");
...
my_login_admin();
...
//////////////////////////////////////////////////

//////////common_functions.sah/////////
function my_login( $username, $password){
    _assert(_isVisible(_button("Login")));
    _setValue(_textbox("loginForm:username"), $username);
    _setValue(_password("loginForm:password"), $password);

    _click(_button("Login"));
    _assert(_isVisible(_label("Logged in as:")));
}
 

...
function my_login_admin(){
    var $ar = _readCSVFile("functions/admin_login_DO_NOT_COMMIT_THIS_FILE_WITH_ADMIN_USER_PASS_IN_IT.csv", "\t");
    my_login($ar[0][0], $ar[0][1]);
}

...
//////////////////////////////////////////////////

contents of the admin login credentials file committed to svn:
/////admin_login_DO_NOT_COMMIT_THIS_FILE_WITH_ADMIN_USER_PASS_IN_IT.csv///////

"" ""

//////////////////////////////////////////////////

contents of the admin login credentials file on your local machine:
/////admin_login_DO_NOT_COMMIT_THIS_FILE_WITH_ADMIN_USER_PASS_IN_IT.csv///////

"myAdminUser" "myAdminPassword"

 //////////////////////////////////////////////////

NOTE: those fields are tab-separated


No comments:

Post a Comment