tsrc/testing/tools/wshTestRun_network.vbs
branchRCL_3
changeset 23 befca0ec475f
parent 0 96612d01cf9f
equal deleted inserted replaced
22:839377eedc2b 23:befca0ec475f
       
     1 '
       
     2 ' WScript that will invoke the test run execute functionality at ATS3 web server without installing any ATS3
       
     3 ' specific programs on the local PC.
       
     4 '
       
     5 ' Password must be given in encrypted format and the path to test drop must be in URLEncoded
       
     6 '
       
     7 ' Usage cscript wshRunX.vbs <username> <password> <server hostname> <path to testDrop.zip>
       
     8 '
       
     9 
       
    10 ' Get the command line arguments
       
    11 set args = WScript.Arguments
       
    12 
       
    13 ' Check that all arguments have been specified
       
    14 Set objShell = WScript.CreateObject("WScript.Shell")
       
    15 Set env = objShell.Environment("Process")
       
    16 checkEnvVars(env)
       
    17 
       
    18 ' Invoke the web application and write the result to stdOut
       
    19 WScript.StdOut.Write doTestRunX(env("ats3.username"), env("ats3.password"), env("ats3.host"), URLEncode( env("ats3.pathToDrop") ))
       
    20 
       
    21 ' Quit the script
       
    22 Wscript.Quit
       
    23 
       
    24 Function checkEnvVars(env)
       
    25 	if env("ats3.username") = "" then
       
    26 		WScript.Echo "Environment variable ats3.username not specified"
       
    27 		WScript.Quit 1
       
    28 	elseif env("ats3.password") = "" then
       
    29 		WScript.Echo "Environment variable ats3.password not specified"
       
    30 		WScript.Quit 1
       
    31 	elseif env("ats3.host") = "" then
       
    32 		WScript.Echo "Environment variable ats3.host not specified"
       
    33 		WScript.Quit 1		
       
    34 	elseif env("ats3.pathToDrop") = "" then
       
    35 		WScript.Echo "Environment variable ats3.pathToDrop not specified"
       
    36 		WScript.Quit 1	
       
    37 	end if
       
    38 End Function
       
    39 
       
    40 ' Invoke the ATS3 web application in given host with the specified username, password and file path
       
    41 Function doTestRunX(uname, password, hostName, pathToDrop)
       
    42 	Set objxmlHTTP = CreateObject("Microsoft.XMLHTTP")
       
    43 	
       
    44 	Call objxmlHTTP.open("GET", "http://" & hostName & "/ats3/XTestRunExecute.do?username=" & uname & "&password=" & password & "&testrunpath=" & pathToDrop, False)
       
    45 	objxmlHTTP.Send()
       
    46 
       
    47 	doTestRunX = objxmlHTTP.ResponseText
       
    48 End Function
       
    49 
       
    50 Function URLEncode(data)
       
    51 	data = replace(data,"\","/")
       
    52 	data = replace(data,"$","%24")
       
    53 	data = replace(data,"&","%26")
       
    54 	data = replace(data,"+","%2B")
       
    55 	data = replace(data,",","%2C")
       
    56 	data = replace(data,"/","%2F")
       
    57 	data = replace(data,":","%3A")
       
    58 	data = replace(data,";","%3B")
       
    59 	data = replace(data,"=","%3D")
       
    60 	data = replace(data,"?","%3F")
       
    61 	data = replace(data,"@","%40")
       
    62 	URLEncode = data
       
    63 End Function