예제 #1
0
    def __init__(self):
        # Login URL
        request = HTTPRequest(url="https://login.site.com")
        ##### reset to the all cookies #####
        threadContext = HTTPPluginControl.getThreadHTTPClientContext() 
        self.cookies = CookieModule.listAllCookies(threadContext) 
        for c in self.cookies: CookieModule.removeCookie(c, threadContext)

        # do login
        request.POST("/login/do", ( NVPair("id", "my_id"),NVPair("pw", "my_passwd")));
        ##### save to the login info in cookies #####
        self.cookies = CookieModule.listAllCookies(threadContext)
예제 #2
0
파일: login.py 프로젝트: 654894017/ngrinder
    def __init__(self):
        # Login URL
        request = HTTPRequest(url="https://login.site.com")
        ##### reset to the all cookies #####
        threadContext = HTTPPluginControl.getThreadHTTPClientContext() 
        self.cookies = CookieModule.listAllCookies(threadContext) 
        for c in self.cookies: CookieModule.removeCookie(c, threadContext)

        # do login
        request.POST("/login/do", ( NVPair("id", "my_id"),NVPair("pw", "my_passwd")));
        ##### save to the login info in cookies #####
        self.cookies = CookieModule.listAllCookies(threadContext)
예제 #3
0
    def __call__(self):
        # The cache of cookies for each  worker thread will be reset at
        # the start of each run.

        result = request1.GET("http://localhost:7001/console/?request1")

        # If the first response set any cookies for the domain,
        # they willl be sent back with this request.
        result2 = request1.GET("http://localhost:7001/console/?request2")

        # Now let's add a new cookie.
        threadContext = HTTPPluginControl.getThreadHTTPClientContext()

        expiryDate = Date()
        expiryDate.year += 10

        cookie = Cookie("key", "value","localhost", "/", expiryDate, 0)

        CookieModule.addCookie(cookie, threadContext)

        result = request1.GET("http://localhost:7001/console/?request3")

        # Get all cookies for the current thread and write them to the log
        cookies = CookieModule.listAllCookies(threadContext)
        for c in cookies: log("retrieved cookie: %s" % c)

        # Remove any cookie that isn't ours.
        for c in cookies:
            if c != cookie: CookieModule.removeCookie(c, threadContext)

        result = request1.GET("http://localhost:7001/console/?request4")
예제 #4
0
    def __call__(self):
        # The cache of cookies for each  worker thread will be reset at
        # the start of each run.

        result = request1.GET("http://localhost:7001/console/?request1")

        # If the first response set any cookies for the domain,
        # they willl be sent back with this request.
        result2 = request1.GET("http://localhost:7001/console/?request2")

        # Now let's add a new cookie.
        threadContext = HTTPPluginControl.getThreadHTTPClientContext()

        expiryDate = Date()
        expiryDate.year += 10

        cookie = Cookie("key", "value", "localhost", "/", expiryDate, 0)

        CookieModule.addCookie(cookie, threadContext)

        result = request1.GET("http://localhost:7001/console/?request3")

        # Get all cookies for the current thread and write them to the log
        cookies = CookieModule.listAllCookies(threadContext)
        for c in cookies:
            log("retrieved cookie: %s" % c)

        # Remove any cookie that isn't ours.
        for c in cookies:
            if c != cookie: CookieModule.removeCookie(c, threadContext)

        result = request1.GET("http://localhost:7001/console/?request4")
예제 #5
0
파일: waasd123.py 프로젝트: liwenson/zhao
 def __init__(self):
     grinder.statistics.delayReports = True
     headers = [
         NVPair('Content-Type', 'application/json'),
         NVPair('Accept', 'application/json'),
     ]
     data = '{"email": "*****@*****.**","passwd": "e10adc3949ba59abbe56e057f20f883e"}'
     result = HTTPRequest().POST(
         'https://cmdb.uyuntest.cn/tenant/api/v1/user/login', data, headers)
     self.threadContext = HTTPPluginControl.getThreadHTTPClientContext()
     self.login_cookies = CookieModule.listAllCookies(self.threadContext)
예제 #6
0
def getCSRF():
    threadContext = HTTPPluginControl.getThreadHTTPClientContext()
    CookieModule.discardAllCookies(threadContext)
    result = request1.GET(url0 + '/api/account/get')
    assert result.getStatusCode() == 200, result
    csrf = linkdrop = None
    for cookie in CookieModule.listAllCookies(threadContext):
        if cookie.name == "linkdrop":
            linkdrop = cookie
        if cookie.name == "csrf":
            csrf = cookie.value
    assert csrf and linkdrop
    return csrf, linkdrop
예제 #7
0
파일: send.py 프로젝트: LeonardoXavier/f1
def getCSRF():
    threadContext = HTTPPluginControl.getThreadHTTPClientContext()
    CookieModule.discardAllCookies(threadContext)
    result = request1.GET(linkdrop_host + '/api/account/get')
    assert result.getStatusCode()==200, result
    csrf = linkdrop = None
    for cookie in CookieModule.listAllCookies(threadContext):
        if cookie.name == "linkdrop":
            linkdrop = cookie
        if cookie.name == "csrf":
            csrf = cookie.value
    assert csrf and linkdrop
    return csrf, linkdrop
예제 #8
0
def setStubbornAuthToken():
    threadContext = HTTPPluginControl.getThreadHTTPClientContext()
    cookies = CookieModule.listAllCookies(threadContext)

    for cookie in cookies:
        if cookie.getName() == 'sso.auth_token':
            CookieModule.removeCookie(cookie, threadContext)

            expiryDate = Date()
            expiryDate.year += 10
            stubbornAuthToken = StubbornCookie('sso.auth_token', cookie.getValue(),
                                               '.wgenhq.net', '/', expiryDate, False)

            CookieModule.addCookie(stubbornAuthToken, threadContext)
            grinder.logger.output("Replaced sso.auth_token with a stubborn version of itself")
예제 #9
0
 def __init__(self):
     grinder.statistics.delayReports=True
     headers = [NVPair('Content-Type', 'application/json'),NVPair('Accept', 'application/json'),]
     login_msg=PTS.get_tenant()
     lenth=len(login_msg)
     i=0
     grinder.logger.info(login_msg[i][0])
     grinder.logger.info(login_msg[i][1])
     data= '{"email": "%s", "passwd": "%s", "code": "uyun", "authCode": "YQTxa8TT6tnQ23IOt23YSAqotUw9KgItxqq4gem+n+f4KB5cINEWr4nMMLeTPBaZobmLzsm1nz9wjVm31fFjrQ=="}' % (login_msg[i][0], login_msg[i][1])
     grinder.logger.info(data)
     if i >= lenth-1:
         i=0
     i+=1
     result = HTTPRequest().POST('http://10.1.11.254/tenant/api/v1/user/login', data, headers)
     self.threadContext = HTTPPluginControl.getThreadHTTPClientContext()
     self.login_cookies = CookieModule.listAllCookies(self.threadContext)
예제 #10
0
def authService():
    threadContext = HTTPPluginControl.getThreadHTTPClientContext()
    CookieModule.discardAllCookies(threadContext)
    # Call authorize requesting we land back on /account/get - after
    # a couple of redirects for auth, we should wind up with the data from
    # account/get - which should now include our account info.
    result = request1.POST(linkdrop_host + '/api/account/authorize',
      (
        NVPair('domain', linkdrop_service),
        NVPair('end_point_success', '/api/account/get'),
        NVPair('end_point_auth_failure', '/current/send/auth.html#oauth_failure'), ),
      ( NVPair('Content-Type', 'application/x-www-form-urlencoded'), ))
    assert result.getStatusCode()==200, result
    data = json_loads(result.getText())
    assert data, 'account/get failed to return data'
    userid = data[0]['accounts'][0]['userid']
    for cookie in CookieModule.listAllCookies(threadContext):
        if cookie.name == "linkdrop":
            linkdrop_cookie = cookie
    assert linkdrop_cookie
    return userid, linkdrop_cookie
예제 #11
0
 def __init__(self):
     grinder.statistics.delayReports = True
     headers = [
         NVPair('Content-Type', 'application/json'),
         NVPair('Accept', 'application/json'),
     ]
     #data = '{"email": "*****@*****.**","passwd": "0e7517141fb53f21ee439b355b5a1d0a"}'
     login_msg = PTS.get_tenant()
     lenth = len(login_msg)
     i = 0
     #grinder.logger.info(login_msg[i][0])
     #grinder.logger.info(login_msg[i][1])
     data = '{"email": "%s", "passwd": "%s", "code": "uyun", "authCode": "fd9552d74e7113c7970226443dd4efd4181dd5aa068a8917c6357b6606b6994b"}' % (
         login_msg[i][0], login_msg[i][1])
     #grinder.logger.info(data)
     if i >= lenth - 1:
         i = 0
     i += 1
     result = HTTPRequest().POST(
         'http://10.1.11.254/tenant/api/v1/user/login', data, headers)
     self.threadContext = HTTPPluginControl.getThreadHTTPClientContext()
     self.login_cookies = CookieModule.listAllCookies(self.threadContext)
예제 #12
0
 def __init__(self):
     self.threadContext = PTS.Context.getThreadContext()
     self.init_cookies = CookieModule.listAllCookies(self.threadContext)
     self.dealApiURL = "https://deal-api.kuick.cn"
예제 #13
0
		def __call__(self):
				domain = 'http://test.constellation.tv'
				screening = 'thevowevent'
				films = [ 87 ]
				film = str(random.choice( films ))
				
				# start signup service
				pwd = '123456'
				for i in range(10):
					numba = random.randint(48,122)
					if ((numba != 96) and (numba != 94) and (numba != 92) and (numba != 69) and (numba != 60) and (numba != 62) and (numba != 58) and (numba != 59)):
						pwd += chr(numba)
				
				signupRequest = test1.wrap(HTTPRequest(url=domain + "/services/Join"))
				parameters = (
						NVPair("username", str(random.randint(0,255))),
						NVPair("email", "grind-" + pwd + "@constellation.tv"),
						NVPair("password", pwd),
						NVPair("password2", pwd)
				)
				signupRequest.POST(parameters)
				
				viewRequest = test2.wrap(HTTPRequest(url=domain + '/theater/'+screening))
				viewRequest.GET()
				
				purchaseRequest = test3.wrap(HTTPRequest(url=domain + '/screening/'+film+'/purchase/'+screening))
				post_body=(
						NVPair("b_address1", str('1 main street')),
						NVPair("b_address2", str('Apt 3')),
						NVPair("b_city", str('San Jose')),
						NVPair("b_country", str('US')),
						NVPair("b_state", str('CA')),
						NVPair("b_zipcode", str('95131')),
						NVPair("card_verification_number", str('962')),
						NVPair("confirm_email", str('grind-'+pwd+'@constellation.tv')),
						NVPair("credit_card_number", str('4286546374372331')),
						NVPair("dohbr", str('false')),
						NVPair("email", str('grind-'+pwd+'@constellation.tv')),
						NVPair("expiration_date_month", str("6")),
						NVPair("expiration_date_year", str("2012")),
						NVPair("first_name", str('First')),
						NVPair("invite_count",  str('0')),
						NVPair("last_name", str('Last')),
						NVPair("promo_code", str('0')),
						NVPair("ticket_code", str('false')),
						NVPair("ticket_price", str('0.00')), 
						NVPair("username", str('User ' + pwd))			
				)
				result = purchaseRequest.POST(post_body)
				
				enterRequest = test4.wrap(HTTPRequest(url=domain + '/theater/'+screening))
				result = enterRequest.GET()
				html = result.getText()
					
				the_user = re.search('<span class="reqs" id="mechanize_userId">([^<].*)</span>', html)
				log("USER IS: " + str(the_user.group(1)))
				user = str(the_user.group(1))
				
				the_cmo = re.search('<span class="reqs" id="mechanize_cmo">([^<].*)</span>', html)
				log("CMO IS: " + str(the_cmo.group(1)))
				cmo = str(the_cmo.group(1))
				
				threadContext = HTTPPluginControl.getThreadHTTPClientContext()
				cookies = CookieModule.listAllCookies(threadContext)
				for c in cookies:
					if c.getName() == "constellation_frontend":
						log("retrieved cookie: %s" % c.getValue())
						thacook = c.getValue()
				the_film = re.search('<span class="reqs" id="mechanize_filmId">([^<].*)</span>', html)
				log("FILM IS: " + str(the_film.group(1)))
				film = str(the_film.group(1))
				the_instance = re.search('<span class="reqs" id="mechanize_instance">([^<].*)</span>', html)
				log("THE INSTANCE IS: " + str(the_instance.group(1)))
				instance = str(the_instance.group(1))
				is_host = re.search('<span class="reqs" id="mechanize_ishost">([^<].*)</span>', html)
				log("THE HOST IS: " + str(is_host.group(1)))
				host = str(is_host.group(1))
				the_mdt = re.search('<span class="reqs" id="mechanize_mdt">([^<].*)</span>', html)
				log("THE MDT IS: " + str(the_mdt.group(1)))
				mdt = str(the_mdt.group(1))
				the_image = re.search('<span class="reqs" id="mechanize_userImage">([^<].*)</span>', html)
				log("THE IMAGE IS: " + str(the_image.group(1)))
				image = str(the_image.group(1))
				the_port = re.search('<span class="reqs" id="mechanize_port">([^<].*)</span>', html)
				log("THE PORT IS: " + str(the_port.group(1)))
				aport = str(the_port.group(1))
				
				time_to_stop = time.time() + time_to_run
				#chatRequest = test5.wrap(HTTPRequest(url='http://www.google.com/'))
				#chatRequest.GET()
	
				myRandom = random.random()
		
				if myRandom > .5:
					#READ CHANNEL
					while time.time() < time_to_stop:
						read_chatRequest = test5.wrap(HTTPRequest(url=domain + '/services/chat/update'))
						read_chat_body=(
							NVPair("cmo", str(cmo)),
							NVPair("cookie", str(thacook)),
							NVPair("instance", str(instance)),
							NVPair("ishost", str(host)),
							NVPair("mdt", str(mdt)),
							NVPair("room", str(screening)),
							NVPair("s", "0"),
							NVPair("a", "0"),
							NVPair("c", "6"),
							NVPair("t", time.time()),
							NVPair("p", str(aport)),
							NVPair("u", str(user))
						)
						read_chatRequest.POST(read_chat_body)
				else:
					#WRITE CHANNEL
					while time.time() < time_to_stop:
						chatRequest = test6.wrap(HTTPRequest(url=domain + '/services/chat/post'))
						chat_body=(
							NVPair("author", str(user)),
							NVPair("body", str(user + datetime.now().strftime("%H:%M %s"))),
							NVPair("cmo", str(cmo)),
							NVPair("cookie", str(thacook)),
							NVPair("film", str(film)),
							NVPair("instance", str(instance)),
							NVPair("ishost", str(host)),
							NVPair("mdt", str(mdt)),
							NVPair("room", str(screening)),
							NVPair("type", str('chat')),
							NVPair("user_image", str(image)),
							NVPair("p", str(aport))
						)
						chatRequest.POST(chat_body)
예제 #14
0
def listAllCookies():
    cookies = CookieModule.listAllCookies()
    grinder.logger.output("CURRENT COOKIES:")
    for cookie in cookies:
        grinder.logger.output(cookie.getName() + ": " + cookie.getValue())