#=============================================================================================
#
# @TITLE			Configure users - check new user in Group
#
# @NUMBER			DBM3_DBUser_015_Configure_users_NewUser_inG_check
#
# @DESCRIPTION		check new user in existing Group
#
#=============================================================================================

static TestName = "DBM3_DBUser_015_Configure_users_NewUser_inG_check";
static expHeaderTitle = "Configure Database Users / User Groups";
static expHeaderSubtitle = "Configure database user for the database administrator 'DBA'.";
static Failure = 0;

static val_comUsermode;
static val_comConnectmode;
static val_timeout;
static val_costwarning;
static val_costlimit;
static val_defaultcode;
static val_userName;

if (newGroupUser_properties == "check_create_values")
{
val_userName = "TEST_GROUP:TEST_USER";
val_comUsermode = "STANDARD";
val_comConnectmode = "NOT EXCLUSIVE";
val_timeout = "32400";
val_costwarning = "1";
val_costlimit = "10";
val_defaultcode = "DEFAULT";
}

if (newGroupUser_properties == "check_new_values")
{
val_userName = "TEST_GROUP:TEST_USER";
val_comUsermode = "RESOURCE";
val_comConnectmode = "EXCLUSIVE";
val_timeout = "32399";
val_costwarning = "2";
val_costlimit = "9";
val_defaultcode = "ASCII";
}

#=============================================================================================
# @STEP 1			check if Config Wizard is open --> texit
#=============================================================================================
if (win_exists("Configuration Wizard",0) != E_OK)
{
	tl_step ("Wizard not open",1,"Testname: " & TestName & ", Line:" & getvar("line_no"));
	texit("true");
}	

#=============================================================================================
# @STEP 2		check header title ---> texit
#=============================================================================================	
#get header title
set_window("Configuration Wizard", 1);
ActiveX_get_info("DBMWfr3.Framework","HeaderTitle",HeaderTitle);
ActiveX_get_info("DBMWfr3.Framework","HeaderSubtitle",HeaderSubtitle);

# check if header title is correct
if (HeaderTitle != expHeaderTitle || HeaderSubtitle != expHeaderSubtitle)
{
	tl_step ("Header title not correct",1,"Testname: " & TestName & ", Line:" & getvar("line_no"));
	texit("true");
}

#=============================================================================================
# @STEP 3		Check TEST_USER_GROUP ---> texit
#=============================================================================================	
set_window ("Configuration Wizard", 1);

#check if current state is "outside" the group,if then double click it
toolbar_get_button("msvb_lib_toolbar",0,first_toolbar_button);
if (first_toolbar_button == "New User")
{
	list_activate_item ("lvwSQLUser", "TEST_GROUP");
}
	
if (list_select_item ("lvwSQLUser", "TEST_USER_GROUP") != E_OK)
{
	tl_step ("No TEST_USER_GROUP",1,"Testname: " & TestName & ", Line:" & getvar("line_no"));
	texit("true");
}

#=============================================================================================
# @STEP 4		Check  Toolbar Buttons
#=============================================================================================	

toolbar_get_button_info("msvb_lib_toolbar","Close User Group",ENABLED,btn_CloseUserGroup);
toolbar_get_button_info("msvb_lib_toolbar","New User",ENABLED,btn_NewUser);
toolbar_get_button_info("msvb_lib_toolbar","Properties",ENABLED,btn_Properties);
toolbar_get_button_info("msvb_lib_toolbar","Copy",ENABLED,btn_Copy);
toolbar_get_button_info("msvb_lib_toolbar","Delete",ENABLED,btn_Delete);
toolbar_get_button_info("msvb_lib_toolbar","Rename",ENABLED,btn_Rename);

if (btn_NewUser == 0 || btn_CloseUserGroup == 0 || btn_Properties == 0 || btn_Copy == 0 || btn_Delete == 0 || btn_Rename == 0 )
{
	tl_step ("Toolbar Buttons not in correct state",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}


#=============================================================================================
# @STEP 5		Check create User properties Button and press it
#=============================================================================================

set_window ("Configuration Wizard", 7);
toolbar_get_button_info("msvb_lib_toolbar","Properties",ENABLED,btn_properties);
if (btn_NewUserGroup == 0)
{
	tl_step ("btn_properties not available",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	texit("true");
}

toolbar_button_press ("msvb_lib_toolbar", "Properties");

#=============================================================================================
# @STEP 6	 	Check User Properties - ---> texit
#=============================================================================================
if (win_exists("SQL User *",0) != E_OK)
{
	tl_step ("User Properties window not opened",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	texit("true");
}

set_window("SQL User *");

#=============================================================================================
# @STEP 7 	 Select <General> Tab & check all Elements
#=============================================================================================
tab_select_item("tabPages","&General");

set_window("SQL User *");
edit_get_text("txtName",OutValue);
if (match(OutValue,"TEST_GROUP") == 0)
{
	tl_step ("New group user inherits from false group",1,"Testname: " & TestName & ", Line:" & getvar("line_no"));
	Failure = 1;
}	

#=============================================================================================
# @STEP 7.1 	 check change password Button 
#=============================================================================================
#check if change (password) Button is enabled
obj_get_info("Change ...","enabled",text_change);
if (text_change == 0)
{
	tl_step ("Password change Button not enabled",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	texit("true");
}

button_press ("Change ...");

#check password fields
obj_get_info("txtPassword","enabled",text_password);
obj_get_info("txtConfirmPassword","enabled",text_confirm_password);
if (text_password == 0 || text_confirm_password == 0)
{
	tl_step ("Password settings not enabled",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	texit("true");
}

#check if OK is disabled
obj_get_info("OK","enabled",btn_OK);
if (btn_OK == 1)
{
	tl_step ("OK Button not disabled",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}

#enter new password (pw: testgu)
password_edit_set("txtPassword", "dygsfzbsgydt");
password_edit_set("txtConfirmPassword", "dygsfzbsgydt");


#check if OK is now enabled
obj_get_info("OK","enabled",btn_OK);
if (btn_OK == 0)
{
	tl_step ("OK Button not enabled",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}

#=============================================================================================
# @STEP 7.2 	 check other elements 
#=============================================================================================
#check user name
edit_get_text("txtName",compare);
if (compare != val_userName)
{
	tl_step ("False user name in properties window",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}
#check user mode text
edit_get_text("txtUsermode",compare);
if (compare != val_comUsermode)
{
	tl_step ("False USER MODE in properties Window",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}
#check connect mode text
edit_get_text("txtConnectMode",compare);

if (compare != val_comConnectmode)
{
	tl_step ("False CONNECT MODE in properties Window",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}

#=============================================================================================
# @STEP 8		Select <Extended> Tab & check all Elements
#=============================================================================================
tab_select_item("tabPages","&Extended");


#obj_get_info("txtPermlimit","enabled",text_Permlimit);
#obj_get_info("txtTemplimit","enabled",text_TempLimit);

#check Timeout text
edit_get_text("txtTimeout",compare);
if (compare != val_timeout)
{
	tl_step ("False TIMEOUT VALUE in properties Window",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}
#check cotswarning text
edit_get_text("txtCostwarning",compare);
if (compare != val_costwarning)
{
	tl_step ("False COSTWARNING VALUE in properties Window",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}
#check costlimit text
edit_get_text("txtCostlimit",compare);
if (compare != val_costlimit)
{
	tl_step ("False COSTLIMIT in properties Window",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}
#check defaultcode text
edit_get_text("txtDefaultCode",compare);
if (compare != val_defaultcode)
{
	tl_step ("False DEFAULT CODE VALUE in properties Window",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}

button_press("OK");

#=============================================================================================
# @STEP 9		check if test passed successfully
#=============================================================================================	
if (Failure == 0)
	tl_step ("Test passed successfully",0,"Testname: " & TestName & ", Line:" & getvar("line_no"));



