#=============================================================================================
#
# @TITLE			Configure users - Create new user in Group
#
# @NUMBER			DBM3_DBUser_014_Configure_users_NewUser_inG
#
# @DESCRIPTION		Create a new user in existing Group
#
#=============================================================================================

static TestName = "DBM3_DBUser_014_Configure_users_NewUser_inG";
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;

val_comUsermode = "STANDARD";
val_comConnectmode = "NOT EXCLUSIVE";
val_timeout = "32400";
val_costwarning = "1";
val_costlimit = "10";
val_defaultcode = "DEFAULT";

#=============================================================================================
# @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_GROUP and double click it ---> texit
#=============================================================================================	
set_window ("Configuration Wizard", 1);
if (list_select_item ("lvwSQLUser", "TEST_GROUP") != E_OK)
{
	tl_step ("No TEST_GROUP",1,"Testname: " & TestName & ", Line:" & getvar("line_no"));
	texit("true");
}

list_activate_item ("lvwSQLUser", "TEST_GROUP");


#=============================================================================================
# @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 == 1 || btn_Copy == 1 || btn_Delete == 1 || btn_Rename == 1 )
{
	tl_step ("Toolbar Buttons not in correct state",1,"Testname: " & TestName & ", Line:" & getvar("line_no")); 
	Failure = 1;
}


#=============================================================================================
# @STEP 5		Check create NewUser for User Group Button and press it
#=============================================================================================

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

toolbar_button_press ("msvb_lib_toolbar", "New User for User Group");

#=============================================================================================
# @STEP 6	 	Check if User Properties - New user for user group Window appears ---> texit
#=============================================================================================
if (win_exists("SQL User *",0) != E_OK)
{
	tl_step ("User Properties - New user for user group 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 *");
ActiveX_get_info("DBMLbl3.Label","text",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;
}	

#check name & password fields
obj_get_info("txtName","enabled",text_name);
obj_get_info("txtPassword","enabled",text_password);
obj_get_info("txtConfirmPassword","enabled",text_confirm_password);
if (text_password == 0 || text_confirm_password == 0 || text_name == 0)
{
	tl_step ("Name/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 username/password
edit_set("txtName","TEST_USER_GROUP");
password_edit_set("txtPassword", "dygsfzbscynsnzes");
password_edit_set("txtConfirmPassword", "dygsfzbscynsnzes");

#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;
}

#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"));



