Esempio n. 1
0
File: login.py Progetto: 1-Hash/Toto
def login(user_id, password):
  response = toto_request('account.login', {'user_id': user_id, 'password': password})
  if 'result' in response:
    with open('session.conf', 'wb') as session_file:
      session_file.write("session_id='%s'\n" % response['result']['session_id'])
      session_file.write("user_id='%s'\n" % response['result']['user_id'])
  return response
Esempio n. 2
0
def create_account(user_id, password):
  response = toto_request('account.create', {'user_id': user_id, 'password': password})
  if 'result' in response:
    with open('session.conf', 'wb') as session_file:
      session_file.write("session_id='%s'\n" % response['result']['session_id'])
      session_file.write("user_id='%s'\n" % response['result']['user_id'])
  return response
Esempio n. 3
0
def create_account(user_id, password):
    response = toto_request("account.create", {"user_id": user_id, "password": password})
    if "result" in response:
        with open("session.conf", "wb") as session_file:
            session_file.write("session_id='%s'\n" % response["result"]["session_id"])
            session_file.write("user_id='%s'\n" % response["result"]["user_id"])
    return response
Esempio n. 4
0
def checkresponse(response):
    if 'error' in response:
        print response['error']
        exit()
    return response


def verify_count(response, n):
    response = checkresponse(response)
    if n != response['result']['count']:
        print 'Counter not incrementing, expected %s got %s' % (
            n, response['result']['count'])
        print response
        exit()
    return response


count = int(raw_input('How many requests? (default 1000)') or 1000)
user_id = uuid4().hex
password = uuid4().hex
print "user_id: %s password: %s" % (user_id, password)
print checkresponse(create_account(user_id, password))
session = {}
execfile('session.conf', session, session)
start = time()
for i in xrange(1, count + 1):
    verify_count(toto_request('increment', session=session), i)
total = time() - start
print 'Ran %s successful requests in %s seconds' % (count, total)
Esempio n. 5
0
#!/usr/bin/python

from request import toto_request

session = {}
execfile('session.conf', session, session)

print toto_request('increment', session=session)
Esempio n. 6
0
def verify_count(response, n):
  response = checkresponse(response)
  if n != response['result']['count']:
    print 'Counter not incrementing, expected %s got %s' % (n, response['result']['count'])
    print response
    exit()
  return response

user_id = uuid4().hex
password = uuid4().hex
print "user_id: %s password: %s" % (user_id, password)

print checkresponse(create_account(user_id, password))
session = {}
execfile('session.conf', session, session)
print verify_count(toto_request('increment', session=session), 1)
print verify_count(toto_request('increment', session=session), 2)
print verify_count(toto_request('increment', session=session), 3)
're-authenticate'
print checkresponse(login(user_id, password))
session = {}
execfile('session.conf', session, session)
print verify_count(toto_request('increment', session=session), 1)
print verify_count(toto_request('increment', session=session), 2)
print verify_count(toto_request('increment', session=session), 3)
print 'new user'
user_id = uuid4().hex
password = uuid4().hex
print "user_id: %s password: %s" % (user_id, password)
print checkresponse(create_account(user_id, password))
session = {}
Esempio n. 7
0

def checkresponse(response):
    if "error" in response:
        print response["error"]
        exit()
    return response


def verify_count(response, n):
    response = checkresponse(response)
    if n != response["result"]["count"]:
        print "Counter not incrementing, expected %s got %s" % (n, response["result"]["count"])
        print response
        exit()
    return response


count = int(raw_input("How many requests? (default 1000)") or 1000)
user_id = uuid4().hex
password = uuid4().hex
print "user_id: %s password: %s" % (user_id, password)
print checkresponse(create_account(user_id, password))
session = {}
execfile("session.conf", session, session)
start = time()
for i in xrange(1, count + 1):
    verify_count(toto_request("increment", session=session), i)
total = time() - start
print "Ran %s successful requests in %s seconds" % (count, total)