Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanqasaur committed Feb 13, 2016
1 parent 063ad44 commit cbeca06
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 53 deletions.
2 changes: 1 addition & 1 deletion test/web/coursemanager/Jcourse.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
title=Conf FunkLoad tests
description=Simply testing a default static page
# the server url to test
url=http://54.148.81.226
url=http://54.200.253.211
#http://jcourse.jeeves.csail.mit.edu

# the User-Agent header to send
Expand Down
5 changes: 4 additions & 1 deletion test/web/hipaa/Hipaa.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
title=Hipaa FunkLoad tests
description=Simply testing a default static page
# the server url to test
url = http://54.148.81.226/
url = http://54.213.184.86
# url=http://hipaa.jeeves.csail.mit.edu

# the User-Agent header to send
Expand All @@ -25,6 +25,9 @@ nb_time=20
[test_login]
description=Login in.

[test_register]
num_users=1020

# ------------------------------------------------------------
# Credential access
#
Expand Down
82 changes: 31 additions & 51 deletions test/web/hipaa/test_Hipaa.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,17 @@ def setUp(self):
self.server_url = self.conf_get('main', 'url')
self.lipsum = Lipsum()

def login_as(self, username, password):
def login_as(self, username, password, pageURL="/index", descr="Get index"):
# The description should be set in the configuration file
server_url = self.server_url

self.get(server_url + "/",
description="Get /")
reply = self.get(server_url + "/index",
description="Get index")

csrftoken = extract_token(self.getBody(), "name='csrfmiddlewaretoken' value='", "' />")
self.post(server_url + "/accounts/login/?next=/",
self.post(server_url + "/accounts/login/?next=" + pageURL,
params=[['csrfmiddlewaretoken', csrftoken],
['redirect_to', '/index'],
['redirect_to', pageURL],
['username', username],
['password', password]],
description="Post /accounts/login/")
Expand All @@ -54,31 +52,31 @@ def test_login(self):
reply = self.get(self.server_url + page, description="Get index")
self.logout()

"""
self.login_as("admin", "admin")
self.logout()
"""


def test_register(self):
username = self.lipsum.getUniqWord()
password = self.lipsum.getWord()
name = self.lipsum.getWord() + " " + self.lipsum.getWord()
email = self.lipsum.getWord() + "@example.org"

server_url = self.server_url
# self.get(server_url + "/register", description='Get url')
self.logout()

csrftoken = extract_token(self.getBody(), "name='csrfmiddlewaretoken' value='", "' />")
self.post(server_url + "/register",
params=[ ['csrfmiddlewaretoken', csrftoken],
['username', username],
['password1', password],
['password2', password],
['name', name],
['email', email],
['profiletype', '1']],
description="Post /register")
num_users = self.conf_getInt('test_register', 'num_users')
for i in range(num_users):
username = self.lipsum.getUniqWord()
password = self.lipsum.getWord()
name = self.lipsum.getWord() + " " + self.lipsum.getWord()
email = self.lipsum.getWord() + "@example.org"

server_url = self.server_url

csrftoken = extract_token(self.getBody(), "name='csrfmiddlewaretoken' value='", "' />")
self.post(server_url + "/register",
params=[ ['csrfmiddlewaretoken', csrftoken],
['username', username],
['password1', password],
['password2', password],
['name', name],
['email', email],
['profiletype', '1']],
description="Post /register")

self.assert_("index" in self.getLastUrl(), "Error in registration")
self.logout()

def test_credential(self):
credential_host = self.conf_get('credential', 'host')
Expand All @@ -88,29 +86,11 @@ def test_credential(self):
self.login_as(login, pwd)
self.logout()

def test_random_register(self):
self.logout()

username = self.lipsum.getUniqWord()
password = self.lipsum.getUniqWord()

server_url = self.server_url
# self.get(server_url + "/register", description='Get url')

csrftoken = extract_token(self.getBody(), "name='csrfmiddlewaretoken' value='", "' />")
self.post(server_url + "/register",
params=[ ['csrfmiddlewaretoken', csrftoken],
['username', username],
['password1', password],
['password2', password],
['name', 'New User'],
['email', '[email protected]'],
['profiletype', '1']],
description="Post /register")

# TODO: Check page after logging in.
self.logout()
self.login_as(username, password)
def test_show_all_users(self):
page = "/users"
self.login_as("admin", "admin", page, "Get users")
self.assert_(page == self.getLastUrl(), "Error in login")
reply = self.get(self.server_url + page, description="Get users")
self.logout()

if __name__ in ('main', '__main__'):
Expand Down

0 comments on commit cbeca06

Please sign in to comment.