def on_start(self): global user global logins_per_acc mutex.acquire() rem = int(user) % NR_SHARELATEX_USERS i = NR_SHARELATEX_USERS if rem == 0 else rem i += USER_START_INDEX-1 self.email = "*****@*****.**" % i self.name = "locust%d" % i user += Fraction(1, int(logins_per_acc)) print('Using user: %s' % self.email) mutex.release() login(self) r = self.client.get("/project", name='get_project_list') self.csrf_token = csrf.find_in_page(r.content) if len(USER_PROJECTS): user_projects = json.loads(USER_PROJECTS) if self.name in user_projects: self.predef_projects = user_projects[self.name] else: self.predef_projects = PREDEF_PROJECTS.split(',') self.nr_users = NR_SHARELATEX_USERS self.koala_enabled = KOALA_ENABLED == 1
def login(l): # login(userbehavior) # print "Enter:" + str(getframeinfo(currentframe()).filename + ":" + getframeinfo(currentframe()).function) + "-LINE:" + str(getframeinfo(currentframe()).lineno) + str(traceback.format_stack()) resp = l.client.get( "/login") # userbehavior.client.get -> WebsiteUser.client.get l.csrf_token = csrf.find_in_page(resp.content) data = {"_csrf": l.csrf_token, "email": l.email, "password": "******"} r = l.client.post("/login", data)
def login(l): resp = l.client.get("/login") l.csrf_token = csrf.find_in_page(resp.content) data = { "_csrf": l.csrf_token, "email": l.email, "password": "******" } r = l.client.post("/login", data) assert r.json().get("redir", None) == "/project"
def on_start(self): # print "Enter:" + str(getframeinfo(currentframe()).filename + ":" + getframeinfo(currentframe()).function) + "-LINE:" + str(getframeinfo(currentframe()).lineno) + str(traceback.format_stack()) r = self.client.get("/project") projects = re.search("\"projects\":(\\[[^\\]]*\\])", r.content.decode("utf-8"), re.MULTILINE) projects = re.search("\"projects\":(\\[[^\\]]*\\])", r.content.decode("utf-8"), re.MULTILINE).group(1) self.projects = json.loads(projects) self.projects = [x for x in self.projects if x["archived"] == False] assert len(self.projects) > 0, "No project founds create some!" self.csrf_token = csrf.find_in_page(r.content)
def login(l): resp = l.client.get("/login", name='get_login_page') l.csrf_token = csrf.find_in_page(resp.content) data = {"_csrf": l.csrf_token, "email": l.email, "password": "******"} # tb= current_milli_time() r = l.client.post("/login", data, name='login') # ta= current_milli_time() # print ('%s' % str(ta-tb)) assert r.json().get("redir", None) == "/project" resp = l.client.get("/user/settings", name='get_settings') l.user_id = find_user_id(resp.content) pass
def on_start(self): r = self.client.get("/project") projects = re.search("projects: (\\[.*\\])", r.content, re.MULTILINE).group(1) self.projects = json.loads(projects) assert len(self.projects) > 0, "No project founds create some!" self.csrf_token = csrf.find_in_page(r.content)