def setUp(self):
        """Setting up test."""
        self.server_url = self.conf_get('main', 'url')

        credential_host = self.conf_get('credential', 'host')
        credential_port = self.conf_getInt('credential', 'port')
        self.username, self.pwd = xmlrpc_get_credential(
            credential_host, credential_port, "group1")

        self.lipsum = Lipsum()
Exemple #2
0
 def test_exampleGuestBook(self):
     server_url = self.zope_url
     self.get("%s/Examples/GuestBook" % server_url)
     server_url = self.zope_url
     self.setBasicAuth(self.admin_id, self.admin_pwd)
     lipsum = Lipsum()
     self.get("%s/Examples/GuestBook/addEntry.html" % server_url)
     params = [["guest_name", lipsum.getWord().capitalize()],
               ["comments", lipsum.getParagraph()]]
     self.post("%s/Examples/GuestBook/addEntry" % server_url, params)
     self.clearBasicAuth()
Exemple #3
0
    def cmfCreateNews(self, parent_url):
        # return the doc_url
        lipsum = Lipsum()
        doc_id = lipsum.getUniqWord().lower()
        params = [["type_name", "News Item"], ["id", doc_id], ["add", "Add"]]
        self.post("%s/folder_factories" % parent_url,
                  params,
                  description="Create an empty news")
        params = [["allow_discussion", "default"],
                  ["title", lipsum.getSubject()],
                  ["description:text",
                   lipsum.getParagraph()], ["subject:lines",
                                            lipsum.getWord()],
                  ["format", "text/plain"],
                  ["change_and_view", "Change and View"]]
        doc_url = "%s/%s" % (parent_url, doc_id)
        self.post("%s/metadata_edit_form" % doc_url,
                  params,
                  description="Set metadata")
        self.assert_('Metadata changed.' in self.getBody())

        params = [["text_format", "plain"],
                  ["description:text",
                   lipsum.getParagraph()], ["text:text",
                                            lipsum.getMessage()],
                  ["change_and_view", "Change and View"]]
        self.post("%s/newsitem_edit_form" % doc_url,
                  params,
                  description="Set news content")
        self.assert_('News Item changed.' in self.getBody())
        return doc_url
class VideoGranulateBench(FunkLoadTestCase):
    """This test use a configuration file Simple.conf."""

    def __init__(self, *args, **kwargs):
        FunkLoadTestCase.__init__(self, *args, **kwargs)
        """Setting up the benchmark cycle."""
        self.server_url = self.conf_get('main', 'url')
        self.sam = Restfulie.at('http://localhost:8888/').auth('test', 'test').as_('application/json')
        self.lipsum = Lipsum()
        self.uid_list = []
        self.video_file = b64encode(open(join(FOLDER_PATH, 'input', 'working_google.flv')).read())

    def test_granulate(self):
        server_url = self.server_url
        self.setBasicAuth('test', 'test')

        # The description should be set in the configuration file
        filename = self.lipsum.getUniqWord() + ".flv"

        body = dumps({'video': self.video_file, 'filename':filename})

        # begin of test ---------------------------------------------
        self.post(server_url, description='Send many videos with 5mb each.',
                  params=Data('application/json', body))
        response = loads(self.getBody())
        self.uid_list.extend(response.values())
        # end of test -----------------------------------------------

    def tearDown(self):
        for uid in self.uid_list:
            self.sam.delete(key=uid)
 def setUp(self):
     """Setting up test."""
     self.logd("setUp")
     self.server_url = self.conf_get('main', 'url')
     self.users_list = open(os.path.dirname(os.path.dirname(__file__)) + '/profiles/contentcreation/users_list.txt', 'r').readlines()
     self.user_id = random.choice(self.users_list).strip()         
     self.lipsum = Lipsum(vocab=V_ASCII, chars=CHARS, sep=SEP)
 def __init__(self, *args, **kwargs):
     FunkLoadTestCase.__init__(self, *args, **kwargs)
     """Setting up the benchmark cycle."""
     self.server_url = self.conf_get('main', 'url')
     self.sam = Restfulie.at('http://localhost:8888/').auth('test', 'test').as_('application/json')
     self.lipsum = Lipsum()
     self.uid_list = []
     self.video_file = b64encode(open(join(FOLDER_PATH, 'input', 'working_google.flv')).read())
    def test_buy_tickets(self):
        get_request = self.get(self.site_url + '/get')
        self.assert_(get_request.code == 200, "expecting a 200")

        item = Lipsum().getWord()
        id_ = Lipsum().getUniqWord()

        post_request = self.post(self.site_url + '/post',
                                 params=[['item', item],
                                         ['id', id_]])

        self.assert_(post_request.code == 200, "expecting a 200")

        put_request = self.put(self.site_url + '/put',
                               params=[['item', item],
                                       ['id', id_]])
        self.assert_(put_request.code == 200, "expecting a 200")
    def cmfCreateNews(self, parent_url):
        # return the doc_url
        lipsum = Lipsum()
        doc_id = lipsum.getUniqWord().lower()
        params = [["type_name", "News Item"],
                  ["id", doc_id],
                  ["add", "Add"]]
        self.post("%s/folder_factories" % parent_url, params,
                  description="Create an empty news")
        params = [["allow_discussion", "default"],
                  ["title", lipsum.getSubject()],
                  ["description:text", lipsum.getParagraph()],
                  ["subject:lines", lipsum.getWord()],
                  ["format", "text/plain"],
                  ["change_and_view", "Change and View"]]
        doc_url = "%s/%s" % (parent_url, doc_id)
        self.post("%s/metadata_edit_form" % doc_url, params,
                  description="Set metadata")
        self.assert_('Metadata changed.' in self.getBody())

        params = [["text_format", "plain"],
                  ["description:text", lipsum.getParagraph()],
                  ["text:text", lipsum.getMessage()],
                  ["change_and_view", "Change and View"]]
        self.post("%s/newsitem_edit_form" % doc_url, params,
                  description="Set news content")
        self.assert_('News Item changed.' in self.getBody())
        return doc_url
Exemple #9
0
    def setUp(self):
        """Setting up test."""
        self.server_url = self.conf_get('main', 'url')
        
        credential_host = self.conf_get('credential', 'host')
        credential_port = self.conf_getInt('credential', 'port')
        self.username, self.pwd = xmlrpc_get_credential(
            credential_host, credential_port, "group1")

        self.lipsum = Lipsum()
Exemple #10
0
    def test_basic_navigation(self):
        # The description should be set in the configuration file
        server_url = self.server_url
        # begin of test ---------------------------------------------

        # /var/folders/0n/nbbtwsqs6zl3z6k91czbkkvr0000gn/T/tmp6np8jv_funkload/watch0001.request
        self.get(server_url + "/", description="Get /")
        self.assert_('Typography' in self.getBody(),
                     "Home page loading failure")

        # /var/folders/0n/nbbtwsqs6zl3z6k91czbkkvr0000gn/T/tmp6np8jv_funkload/watch0042.request
        self.get(server_url + "/news", description="Get /news")
        self.assert_('List of news' in self.getBody(),
                     "News list loading failure")
        # store the number of news
        # nb_news_before = len(self.listHref(content_pattern='View article'))

        # /var/folders/0n/nbbtwsqs6zl3z6k91czbkkvr0000gn/T/tmp6np8jv_funkload/watch0078.request
        self.get(server_url + "/news/create", description="Get /news/create")
        self.assert_('Create a news item' in self.getBody(),
                     "News form loading failure")

        # /var/folders/0n/nbbtwsqs6zl3z6k91czbkkvr0000gn/T/tmp6np8jv_funkload/watch0097.request
        title = Lipsum().getSubject(uniq=True)
        self.post(server_url + "/news/create",
                  params=[['title', title], ['text',
                                             Lipsum().getParagraph()],
                          ['submit', 'Create news item']],
                  description="Post /news/create")
        self.assert_('Congrats' in self.getBody(), "News creation failure")

        # /var/folders/0n/nbbtwsqs6zl3z6k91czbkkvr0000gn/T/tmp6np8jv_funkload/watch0099.request
        self.get(server_url + "/news", description="Get /news")
        # do we have one more news ?
        news_links = self.listHref(content_pattern='View article')
        # nb_news_after = len(news_links)
        # self.assert_(nb_news_after == nb_news_before + 1, "New news not listed")

        # /var/folders/0n/nbbtwsqs6zl3z6k91czbkkvr0000gn/T/tmp6np8jv_funkload/watch0101.request
        last_news = news_links[-1]
        self.get(server_url + "/%s" % last_news, description="Get new news")
class Webengine(FunkLoadTestCase):
    """Basic test of nuxeo webengine"""
    server_url = None
    _lipsum = Lipsum()
    ws_title = "FLNXTEST Webengine workspace"
    ws_id = "FLNXTEST Webengine works"
    dir_title = "FLNXTEST Page folder"
    dir_id = "FLNXTEST Page folder"
    tag = "FLNXTEST"

    def setUp(self):
        self.server_url = self.conf_get('main', 'url')
        self.credential_host = self.conf_get('credential', 'host')
        self.credential_port = self.conf_getInt('credential', 'port')
        self.cred_admin = xmlrpc_get_credential(self.credential_host,
                                                self.credential_port, 'admin')
        self.cred_member = xmlrpc_get_credential(self.credential_host,
                                                 self.credential_port,
                                                 'members')
        self.logd("setUp")

    def test_testWebengine(self):
        # begin of test ---------------------------------------------
        p = WebenginePage(self)

        (p.home().login(*self.cred_admin).admin().user_management())

        ws_path = '/'.join(('workspaces', self.ws_id))
        if p.viewDocumentPath(ws_path, raiseOn404=False) is None:
            p.createDocument('workspaces', self.ws_title, doc_type="Workspace")
        parent = '/'.join((ws_path, self.dir_id))
        if p.viewDocumentPath(parent, raiseOn404=False) is None:
            p.createDocument(ws_path, self.dir_title, doc_type="Folder")
        p.viewDocumentPath(parent)

        p.deleteDocument(ws_path)

        p.createUser('john', 'tiger', groups='members')
        p.logout()

        (p.home().login('john', 'tiger').home().logout())

        (p.home().login(*self.cred_admin).deleteUser('john').logout())

        # end of test -----------------------------------------------

    def tearDown(self):
        """Setting up test."""
        self.logd("tearDown.")
Exemple #12
0
 def test_05_verifyUsers(self):
     server_url = self.server_url
     user_mail = self.conf_get('test_05_verifyUsers', 'mail')
     lipsum = Lipsum()
     self.setBasicAuth(*self.cred_admin)
     for user_id, user_pwd in xmlrpc_list_credentials(
             self.credential_host, self.credential_port, 'FL_Member'):
         params = [["member_id", user_id], ["member_email", user_mail],
                   ["password", user_pwd], ["confirm", user_pwd],
                   ["add", "Register"]]
         self.post("%s/join_form" % server_url, params)
         html = self.getBody()
         self.assert_(
             'Member registered' in html
             or 'The login name you selected is already in use' in html,
             "Member %s not created" % user_id)
     self.clearBasicAuth()
Exemple #13
0
class CMF(NuxeoTestCase):
    """CMF
    This test use a configuration file CMF.conf.
    """
    _lipsum = Lipsum()
    usersWithTasks = []

    def setUp(self):
        """Setting up test."""
        self.logd("setUp")
        NuxeoTestCase.setUp(self)
        self.memberList = xmlrpc_list_credentials(self.credential_host,
                                                  self.credential_port,
                                                  'members')

    def createCaseItem(self, user, passwd, case, caseItem, pathToPdf):
        caseItemId = MailboxPage(self).login(
            user,
            passwd).viewDraftTab().createCaseItem(case, caseItem, pathToPdf)
        MailboxPage(self).logout()
        return caseItemId
Exemple #14
0
class CMF(NuxeoTestCase):
    """CMF

    This test use a configuration file CMF.conf.
    """
    _lipsum = Lipsum()
    usersWithTasks = []

    def setUp(self):
        """Setting up test."""
        self.logd("setUp")
        NuxeoTestCase.setUp(self)
        self.memberList =  xmlrpc_list_credentials(self.credential_host,
                                                  self.credential_port,
                                                  'members')
    
    def test_CMF(self):
        users = self.memberList
        for i in users:
            MailboxPage(self).login(i[0], i[1]).logout()    
    
    def tearDown(self):
        """Setting up test."""
        self.logd("tearDown.\n")
Exemple #15
0
import unittest
from funkload.Lipsum import Lipsum
from funkload.FunkLoadTestCase import FunkLoadTestCase
from webunit.utility import Upload
from funkload.utils import Data
import hashlib
from funkload.utils import extract_token

#from funkload.utils import xmlrpc_get_credential


def user_grade_dir_name(username):
    return hashlib.md5(username).hexdigest()[0:5] + username


lipsum = Lipsum()


class Navigation(FunkLoadTestCase):
    """XXX

    This test use a configuration file Navigation.conf.
    """
    def setUp(self):
        """Setting up test."""
        self.logd("setUp")
        self.server_url = self.conf_get('main', 'url')
        # XXX here you can setup the credential access like this
        # credential_host = self.conf_get('credential', 'host')
        # credential_port = self.conf_getInt('credential', 'port')
        # self.login, self.password = xmlrpc_get_credential(credential_host,
Exemple #16
0
class NuxeoTestCase(FunkLoadTestCase):
    server_url = None
    _lipsum = Lipsum()
    monitor_page = 0

    def setUp(self):
        self.server_url = self.conf_get('main', 'url')
        self.credential_host = self.conf_get('credential', 'host')
        self.credential_port = self.conf_getInt('credential', 'port')
        self.cred_admin = xmlrpc_get_credential(self.credential_host,
                                                self.credential_port, 'admin')
        self.cred_member = xmlrpc_get_credential(self.credential_host,
                                                 self.credential_port,
                                                 'members')
        self.pglog_file = self.conf_get('main', 'pglog', '')
        self.log_dir = self.conf_get('main', 'log_dir', '')
        if not self.in_bench_mode:
            self.monitor_page = self.conf_getInt('main', 'monitor_page', '0')
            if self.monitor_page:
                self.logd("Tracing pg and jvm heap")
                if os.path.exists(self.pglog_file):
                    self.pglogf = open(self.pglog_file)
                    self.pglogf.seek(0, 2)
                else:
                    self.pglog_file = None
        self.logd("setUp")

    def pglog(self):
        """Save the PostgreSQL log for the previous request, logtail."""
        if self.pglog_file is None:
            return
        # wait for async processing
        sleep(4)
        logfile = os.path.join(
            self.log_dir, "pg-%s-%3.3d.log" % (self.test_name, self.steps))
        lf = open(logfile, "w")
        while True:
            data = self.pglogf.read()
            if data:
                lf.write(data)
            else:
                break
        lf.close()

    def performFullGC(self):
        """Ask monitorctl.sh to perform a full GC."""
        if self.monitorctl_file is not None:
            command(self.monitorctl_file + " invoke-fgc")

    def performHeapHistoStart(self):
        """Perform a heap histo of page."""
        self.performHeapHisto("%s-%3.3d-before" %
                              (self.test_name, self.steps + 1))

    def performHeapHistoEnd(self):
        """Perform a heap histo of page."""
        self.performHeapHisto("%s-%3.3d-end" % (self.test_name, self.steps))

    def performHeapHisto(self, tag):
        """Perform a heap histo."""
        self.monitorctl_file = self.conf_get('main', 'monitorctl_file', '')
        if not os.path.exists(self.monitorctl_file):
            return
        log_dir = self.conf_get('main', 'log_dir', '')
        logfile = os.path.join(log_dir, "hh-%s.txt" % tag)
        status, output = command(self.monitorctl_file + " heap-histo")
        lf = open(logfile, "w")
        lf.write(output)
        lf.close()

    def getLastJsfState(self):
        return extractJsfState(self.getBody())

    def get(self, url, params=None, description=None, ok_codes=None):
        # Override to save pg logs and heap histo
        if self.monitor_page:
            self.performFullGC()
            self.performHeapHistoStart()
        ret = FunkLoadTestCase.get(self, url, params, description, ok_codes)
        if self.monitor_page:
            self.pglog()
            self.performHeapHistoEnd()
        return ret

    def post(self, url, params=None, description=None, ok_codes=None):
        # Override to save pg logs and heap histo
        if self.monitor_page:
            self.performFullGC()
            self.performHeapHistoStart()
        ret = FunkLoadTestCase.post(self, url, params, description, ok_codes)
        if self.monitor_page:
            self.pglog()
            self.performHeapHistoEnd()
        return ret
Exemple #17
0
    def test_critical_path(self):
        server_url = self.server_url
        self.get(server_url, description='Get root URL')
        self.get(server_url + "/users/sign_up",
                 description="View the user signup page")

        auth_token = extract_token(
            self.getBody(), 'name="authenticity_token" type="hidden" value="',
            '"')
        email = Lipsum().getUniqWord() + "@" + Lipsum().getWord() + ".com"

        self.post(self.server_url + "/users",
                  params=[['user[email]', email],
                          ['user[password]', 'alphabet'],
                          ['user[password_confirmation]', 'alphabet'],
                          ['authenticity_token', auth_token],
                          ['commit', 'Sign up']],
                  description="Create New User")

        self.get(server_url + "/communities/new",
                 description="View the new communities page")
        auth_token = extract_token(
            self.getBody(), 'name="authenticity_token" type="hidden" value="',
            '"')

        community_name = Lipsum().getSentence()
        self.post(self.server_url + "/communities",
                  params=[['community[name]', community_name],
                          ['authenticity_token', auth_token],
                          ['commit', 'Create Community']],
                  description="Create New Community")
        last_url = self.getLastUrl()

        created_community_id = last_url.split('/')[-1]
        self.get(server_url + "/communities/" + created_community_id,
                 description="View the created community page")

        self.get(server_url + "/submissions/new",
                 description="View the new submissions page")
        auth_token = extract_token(
            self.getBody(), 'name="authenticity_token" type="hidden" value="',
            '"')

        submission_title = Lipsum().getSentence()
        submission_url = "http://www." + Lipsum().getWord() + Lipsum(
        ).getUniqWord() + ".com/"
        self.post(self.server_url + "/submissions",
                  params=[['submission[title]', submission_title],
                          ['submission[url]', submission_url],
                          ['submission[community_id]', created_community_id],
                          ['authenticity_token', auth_token],
                          ['commit', 'Create Submission']],
                  description="Create New Submission")
        last_url = self.getLastUrl()
        created_submission_id = last_url.split('/')[-1]

        self.get(server_url + "/comments/new",
                 description="View the new comments page")
        auth_token = extract_token(
            self.getBody(), 'name="authenticity_token" type="hidden" value="',
            '"')

        comment_message = Lipsum().getSentence()
        comment_parent = ''
        submission_id = created_submission_id
        self.post(self.server_url + "/comments",
                  params=[['comment[message]', comment_message],
                          ['comment[submission_id]', submission_id],
                          ['comment[parent_id]', comment_parent],
                          ['authenticity_token', auth_token],
                          ['commit', 'Create Comment']],
                  description="Create New Comment")
class Contentcreation(FunkLoadTestCase.FunkLoadTestCase):
    """Content creation load test scenario

    This test use a configuration file Contentcreation.conf.
    """

    def setUp(self):
        """Setting up test."""
        self.logd("setUp")
        self.server_url = self.conf_get('main', 'url')
        self.users_list = open(os.path.dirname(os.path.dirname(__file__)) + '/profiles/contentcreation/users_list.txt', 'r').readlines()
        self.user_id = random.choice(self.users_list).strip()         
        self.lipsum = Lipsum(vocab=V_ASCII, chars=CHARS, sep=SEP)

    def test_ContentCreation(self):
        # The description should be set in the configuration file
        
        server_url = self.server_url
        # begin of test ---------------------------------------------
        
        self.post(server_url + "/coreloadtests/login_form", params=[
            ['form.submitted', '1'],
            ['js_enabled', '0'],
            ['cookies_enabled', '0'],
            ['login_name', ''],
            ['pwd_empty', '0'],
            ['came_from', 'login_success'],
            ['__ac_name', self.user_id],
            ['__ac_password', 'testpw']],
            description="Post /coreloadtests/login_form")        
        
        folder_portal_factory = self._browse(server_url + "/coreloadtests/Members/" + self.user_id +"/createObject?type_name=Folder",
                                             method='get', 
                                             follow_redirect=False,
                                             description = 'Get folder portal factory')

        folder_edit_url = folder_portal_factory.headers.get('Location')        
        folder_id = folder_edit_url.split('/')[-2]
 
        folder_created = self.post(folder_edit_url, params=[
            ['id', folder_id],
            ['title', 'folder'],
            ['description', ''],
            ['description_text_format', 'text/plain'],
            ['subject_existing_keywords:default:list', ''],
            ['location', ''],
            ['language', ''],
            ['effectiveDate', ''],
            ['effectiveDate_year', '0000'],
            ['effectiveDate_month', '00'],
            ['effectiveDate_day', '00'],
            ['effectiveDate_hour', '12'],
            ['effectiveDate_minute', '00'],
            ['effectiveDate_ampm', 'AM'],
            ['expirationDate', ''],
            ['expirationDate_year', '0000'],
            ['expirationDate_month', '00'],
            ['expirationDate_day', '00'],
            ['expirationDate_hour', '12'],
            ['expirationDate_minute', '00'],
            ['expirationDate_ampm', 'AM'],
            ['creators:lines', 'user'],
            ['contributors:lines', ''],
            ['rights', ''],
            ['rights_text_format', 'text/html'],
            ['allowDiscussion:boolean:default', ''],
            ['excludeFromNav:boolean:default', ''],
            ['nextPreviousEnabled:boolean:default', ''],
            ['fieldsets:list', 'default'],
            ['fieldsets:list', 'categorization'],
            ['fieldsets:list', 'dates'],
            ['fieldsets:list', 'ownership'],
            ['fieldsets:list', 'settings'],
            ['form.submitted', '1'],
            ['add_reference.field:record', ''],
            ['add_reference.type:record', ''],
            ['add_reference.destination:record', ''],
            ['last_referer', 'http://localhost:8080/coreloadtests/Members/' + self.user_id + '/view'],
            ['form_submit', 'Save']],
            description="Post /coreloadtests/Members/user...280843853/atct_edit")

        new_folder_id = folder_created.url.split('/')[-2]

        document_portal_factory = self._browse(server_url + "/coreloadtests/Members/" + self.user_id +"/" + new_folder_id + "/createObject?type_name=Document",
                                             method='get', 
                                             follow_redirect=False,
                                             description = 'Get document portal factory')

        document_edit_url = document_portal_factory.headers.get('Location')        
        document_id = document_edit_url.split('/')[-2]
        
        self.post(document_edit_url, params=[                                                                                                                                                         
            ['id', document_id],
            ['title', self.lipsum.getSubject(length=5, prefix=None, uniq=False,length_min=None, length_max=None)],
            ['description', self.lipsum.getMessage(length=10)],
            ['description_text_format', 'text/plain'],
            ['text_text_format', 'text/html'],
            ['text_text_format:default', 'text/html'],
            ['text', self.lipsum.getMessage(length=30)],
            ['text_file', Upload("")],
            ['subject_existing_keywords:default:list', ''],
            ['relatedItems:default:list', ''],
            ['location', ''],
            ['language', ''],
            ['effectiveDate', ''],
            ['effectiveDate_year', '0000'],
            ['effectiveDate_month', '00'],
            ['effectiveDate_day', '00'],
            ['effectiveDate_hour', '12'],
            ['effectiveDate_minute', '00'],
            ['effectiveDate_ampm', 'AM'],
            ['expirationDate', ''],
            ['expirationDate_year', '0000'],
            ['expirationDate_month', '00'],
            ['expirationDate_day', '00'],
            ['expirationDate_hour', '12'],
            ['expirationDate_minute', '00'],
            ['expirationDate_ampm', 'AM'],
            ['creators:lines', 'user'],
            ['contributors:lines', ''],
            ['rights', ''],
            ['rights_text_format', 'text/html'],
            ['allowDiscussion:boolean:default', ''],
            ['excludeFromNav:boolean:default', ''],
            ['presentation:boolean:default', ''],
            ['tableContents:boolean:default', ''],
            ['cmfeditions_version_comment', 'Lorem Ipsum'],
            ['fieldsets:list', 'default'],
            ['fieldsets:list', 'categorization'],
            ['fieldsets:list', 'dates'],
            ['fieldsets:list', 'ownership'],
            ['fieldsets:list', 'settings'],
            ['form.submitted', '1'],
            ['add_reference.field:record', ''],
            ['add_reference.type:record', ''],
            ['add_reference.destination:record', ''],
            ['last_referer', 'http://localhost:8080/coreloadtests/Members/' + self.user_id +'/' + new_folder_id + '/'],
            ['form_submit', 'Save']],
            description="Post /coreloadtests/Members/user...511052309/atct_edit")

        self.get(server_url + "/coreloadtests/logout",
            description="Get /coreloadtests/logout")

        # end of test -----------------------------------------------

    def tearDown(self):
        """Setting up test."""
        self.logd("tearDown.\n")
class ConfRegistration(FunkLoadTestCase):
    """This test use a configuration file Conf.conf."""
    def setUp(self):
        """Setting up test."""
        self.server_url = self.conf_get('main', 'url')

        credential_host = self.conf_get('credential', 'host')
        credential_port = self.conf_getInt('credential', 'port')
        self.username, self.pwd = xmlrpc_get_credential(
            credential_host, credential_port, "group1")

        self.lipsum = Lipsum()

    def tearDown(self):
        self.logout()

    def login(self, page="/index"):
        # The description should be set in the configuration file
        server_url = self.server_url

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

        csrftoken = extract_token(self.getBody(),
                                  "name='csrfmiddlewaretoken' value='", "' />")
        self.post(server_url + "/accounts/login/?next=" + page,
                  params=[['csrfmiddlewaretoken', csrftoken],
                          ['redirect_to', page], ['username', self.username],
                          ['password', self.pwd]],
                  description="Post /accounts/login/")

    def logout(self):
        self.get(self.server_url + "/accounts/logout/",
                 description="Get /accounts/logout/")

    def test_simple(self):
        # The description should be set in the configuration file
        server_url = self.server_url
        # begin of test ---------------------------------------------
        nb_time = self.conf_getInt('test_simple', 'nb_time')
        for i in range(nb_time):
            self.get(server_url, description='Get url')
        # end of test -----------------------------------------------

    def test_register(self):
        self.logout()

        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], ['affiliation', 'MIT']],
                      description="Post /register")

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

    def test_show_all_users(self):
        """
        To show all users n times:
            fl-run-test test_ConfRegistration.py \
            ConfRegistration.test_show_all_users -l 2 -n 20
        """
        page = "/users"
        self.login(page)

        reply = self.get(self.server_url + page, description="Get users")

        self.assert_(page == self.getLastUrl(), "Error in login")
        self.logout()

    def test_view_profile(self):
        page = "/accounts/profile/"
        self.login(page)
        self.assert_(page == self.getLastUrl(), "Error in login")
        reply = self.get(self.server_url + page, description="Get profile")
        self.logout()
class whitelist(FunkLoadTestCase):
    """This test uses whitelist.conf.
    
    Note I am assuming that there are no proxy exclusions (ie all requests are sent through the proxy).
    This is bad if you are using browser exclusion lists to serve your stylesheets off internal servers...
    
    """
    def setUp(self):
        """Setting up whitelist test."""
        self.title = self.conf_get('main', 'title')
        self.logd("Setting up test: %s\n" % self.title)
        self.lipsum = Lipsum()

    def test_viewwebpages(self):

        nb_time = self.conf_getInt('test_viewwebpages', 'nb_time')
        urls = self.conf_getList('test_viewwebpages', 'urls')
        for i in range(nb_time):
            self.logd('Try %i' % i)
            for url in urls:
                response = self.get("http://" + url,
                                    description='Get %s' % url)
                self.assert_(
                    response.body.find("<img") >= 0,
                    "URL: %s returned with no <img> tags.  Probably means the request failed."
                    % url)

    def testGetFormNonHTTP(self):
        """Test we are blocking the blocked domain to avoid returning forms that are
        not requests for renderable HTML - e.g. *.jpg"""

        url_404 = self.conf_get('test_404_for_blocked_nonhtml', 'url_404')
        response = self.get(url_404)
        self.assertEquals(response.code, 404,
                          "Got %s, should have been 404" % response.code)

        response = self.client.get("https://blockedwhitetrash/empty")
        self.failUnlessEqual(response.status_code, 200)

    def test_viewwhitelist(self):
        """This test is pretty CPU intensive as it parses the whole page each time looking for a /table tag (which is at the very end) to make sure we got a complete page.
        Might be a better way to do this...."""

        nb_time = self.conf_getInt('test_viewwhitelist', 'nb_time')
        whitelist_url = self.conf_get('test_viewwhitelist', 'whitelist_url')

        #Add a refresh header to really test the server and proxy caching
        self.addHeader("Cache-Control", "max-age=0")

        response = self.get(self.conf_get('test_viewwhitelist',
                                          'not_whitelist_url'),
                            description='Get whitelist')
        self.assertEquals(
            response.getDOM().getByName('title')[0][0],
            "Whitetrash: *Not* Whitelist Report",
            "Expected 'Whitetrash: *NOT* Whitelist Report' in HTML title'")
        self.assert_(
            response.body.find("</table>"),
            "Page returned with no closing </table>.  We may have got an incomplete table."
        )

        first_timestamp = ""
        for i in range(nb_time):
            self.logd('Try %i' % i)
            #The next step is very slow for large tables, not sure why.  Is fine when using Firefox.
            response = self.get(whitelist_url, description='Get whitelist')
            self.assertEquals(
                response.getDOM().getByName('title')[0][0],
                "Whitetrash Whitelist Report",
                "Expected 'Whitetrash Whitelist Report' in HTML title'")
            #Check page is being cached
            timestamp = response.getDOM().getByName('p')[0][0]
            if not first_timestamp:
                first_timestamp = timestamp
            self.assertEquals(
                timestamp, first_timestamp,
                "Caching check failed.  Page should not have regenerated.  Timestamp should be %s, but got %s"
                % (first_timestamp, timestamp))

    def add_pages(self, protocol="HTTP"):

        num_pages = self.conf_getInt('test_addto%swhitelist' % protocol,
                                     'num_pages')
        prefix = self.conf_get('test_addto%swhitelist' % protocol, 'prefix')
        suffix = self.conf_get('test_addto%swhitelist' % protocol, 'suffix')

        for i in range(num_pages):
            self.addHeader(
                "Accept",
                "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
            )
            self.addHeader("Accept-Language", "en-us,en;q=0.5")
            self.addHeader("Accept-Encoding", "gzip,deflate")
            self.addHeader("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7")
            self.addHeader("Keep-Alive", "300")
            self.addHeader("Proxy-Connection", "keep-alive")

            page = self.lipsum.getUniqWord(length_min=5, length_max=40)
            self.setHeader("Host", "www.%s.com" % page)

            if protocol == "HTTP":
                url = "http://www." + page + ".com"
            elif protocol == "SSL":
                #Funkload picks up that this is SSL by the https identifier, we don't need to tell it explicitly.
                url = "https://www." + page + ".com"

            self.logd('Requesting %s page %i: %s' % (protocol, i, url))
            response = self.get(url, description='Get %s' % url)
            self.assertEquals(
                response.getDOM().getByName('title')[0][0],
                "Internet Access Request Form",
                "Expected 'Internet Access Request Form' in HTML title'")

            if protocol == "HTTP":
                postparams = [['domain', 'www.' + page + '.com'],
                              [
                                  'comment',
                                  urllib.quote_plus(self.lipsum.getSentence())
                              ], ['url', urllib.quote_plus(url)],
                              ['protocol', protocol]]

                self.logd('Adding %s page %i: %s' % (protocol, i, postparams))
                response = self.post("http://whitetrash/addentry?",
                                     params=postparams,
                                     description='Post params:%s' % postparams)

            elif protocol == "SSL":
                #Emulate the actual process here by submitting user=ssl.
                self.logd('Adding %s page %i' % (protocol, i))
                response = self.post("https://whitetrash/addentry?",
                                     params=None)

            self.assertEquals(response.getDOM().getByName('title')[0][0],
                              "Access Granted",
                              "Expected 'Access Granted' in HTML title'")
            self.assert_(
                response.body.find(urllib.quote_plus(url)) >= 0,
                "URL %s expected but not found in response" %
                urllib.quote_plus(url))
            self.assert_(
                response.body.find(self.user) >= 0,
                "Username %s expected but not found in response" % self.user)

    def test_addtoHTTPwhitelist(self):
        self.add_pages(protocol="HTTP")

    def test_addtoSSLwhitelist(self):
        #self.add_pages(protocol="SSL")
        pass
Exemple #21
0
 def setUp(self):
     """Setting up test."""
     self.server_url = self.conf_get('main', 'url')
     self.lipsum = Lipsum()
Exemple #22
0
class CMF(NuxeoTestCase):
    """CMF

    This test use a configuration file CMF.conf.
    """
    _lipsum = Lipsum()

    def setUp(self):
        """Setting up test."""
        self.logd("setUp")
        NuxeoTestCase.setUp(self)
        self.memberList = xmlrpc_list_credentials(self.credential_host,
                                                  self.credential_port,
                                                  'members')
        self.routeManagerList = xmlrpc_list_credentials(
            self.credential_host, self.credential_port, 'routeManagers')
        f = open('./xml_importer/pdf-list.txt', 'r')
        self.pdf_files = f.readlines()
        self.routeName = "FunkloadRouteDoc"
        self.routeModelId = self.extractRouteModelId("jdoe", "jdoe1",
                                                     self.routeName)

    def executeApproveLinkOperation(self, user, passwd, mailboxId, caseId):
        self.logi("Execute approve op as: " + user)
        URL = "http://localhost:8080/nuxeo/site/automation/"
        self.setBasicAuth(user, passwd)
        data = Data(
            'application/json+nxrequest',
            '{"params":{},"context":{},"input":"docs:' + mailboxId + ',' +
            caseId + '"}')
        self.post(URL + 'Case.Management.Approve.CaseLink', data)
        self.clearBasicAuth()

    def getRandomUser(self):
        return random.choice(self.memberList)

    def getRandomAdministrator(self):
        return random.choice(self.cred_admin)

    def getRandomRouteManager(self):
        return random.choice(self.routeManagerList)

    def getPasswordForUser(self, user):
        for i in self.memberList:
            if cmp(i[0], user):
                return i[1]

    def extractRouteStepsIds(self, user, passwd, routeInstanceName):
        stepsDocIds = []
        p = RouteInstancePage(self).login(
            user, passwd).viewRouteInstance(routeInstanceName)
        #get all the route steps docIds to modify the route from the route view
        stepsDocIds = p.getStepsDocsIds(stepsDocIds)
        p.logout()
        return stepsDocIds

    def updateRoute(self, user, passwd, case, route, stepsDocIds):
        #lock route and modify steps
        routeInstance = CaseItemPage(self).login(
            user, passwd).viewRelatedStartedRoute(case)
        p = RoutePage(self).lockRoute(user, route)
        self.logi("Route " + routeInstance + " locked by " + user)
        j = 0
        usersWithTasks = []
        for i in stepsDocIds:
            randUser = self.getRandomUser()
            if RoutePage(self).stepCanBeUpdated(i, routeInstance,
                                                user) is True:
                if RoutePage(self).stepNeedsToBeApproved(
                        i, routeInstance, user) is True:
                    usersWithTasks.append(randUser)
                #TODO delete this refresh call after fixing NXCM-301
                CaseItemPage(self).refreshRelatedStartedRoute(case)
                RoutePage(self).updateStepDistributionMailboxFromRouteView(
                    i, "user-" + randUser[0], j)
            j = j + 1
        p.logout()
        return usersWithTasks
class Distribution(FunkLoadTestCase):
    """Nuxeo Courrier

    This test use a configuration file Distribution.conf.
    """
    _lipsum = Lipsum()

    def setUp(self):
        """Setting up test."""
        self.logd("setUp")
        self.addHeader('Accept-Language', 'en')
        self.server_url = self.conf_get('main', 'url')
        self.credential_host = self.conf_get('credential', 'host')
        self.credential_port = self.conf_getInt('credential', 'port')
        self.cred_admin = xmlrpc_get_credential(self.credential_host,
                                                self.credential_port, 'admin')
        self.cred_member = xmlrpc_get_credential(self.credential_host,
                                                 self.credential_port,
                                                 'members')

        self.senderList = xmlrpc_list_credentials(self.credential_host,
                                                  self.credential_port,
                                                  'writers')

        self.receiverList = xmlrpc_list_credentials(self.credential_host,
                                                    self.credential_port,
                                                    'readers')

    def getLastJsfState(self):
        return extractJsfState(self.getBody())

    def getRandReceiver(self):
        index = random.randint(0, len(self.receiverList) - 1)
        return self.receiverList[index]

    def getRandSender(self):
        index = random.randint(0, len(self.senderList) - 1)
        return self.senderList[index]

    def test_distribution(self):
        # The description should be set in the configuration file
        server_url = self.server_url
        # begin of test ---------------------------------------------
        lipsum = self._lipsum
        today = datetime.today().strftime('%m/%d/%y')
        randSender = self.getRandSender()
        receiver = self.getRandReceiver()

        self.post(server_url + "/nxstartup.faces",
                  params=[['user_name', randSender[0]],
                          ['user_password', randSender[1]],
                          ['requestedUrl', ''], ['form_submitted_marker', ''],
                          ['Submit', 'Connexion']],
                  description="Log in")
        self.assert_('You are logged as ' + randSender[0] in self.getBody())

        self.get(server_url + "/nxpath/default/correspondence/mailboxes/" +
                 randSender[0] + "@mailbox_view?tabId=&conversationId=0NXMAIN",
                 description="View personal mailbox")

        self.assert_('Create an incoming mail' in self.getBody())
        """Create incoming mail."""
        self.post(server_url + "/correspondence/mailbox/mailbox_view.faces",
                  params=[['j_id245', 'j_id245'],
                          ['javax.faces.ViewState',
                           self.getLastJsfState()],
                          ['j_id226:j_id227', 'j_id226:j_id227'],
                          ['j_id226_SUBMIT', '1']],
                  description="View mail form")

        self.assert_(
            'nxl_head_correspondence_incoming_document' in self.getBody())

        self.post(
            server_url +
            "/correspondence/mail/create_correspondence_document.faces",
            params=
            [[
                'AJAXREQUEST',
                'document_create:nxl_correspondence_document:nxw_contactsRecipients:nxw_contactsRecipients_region'
            ], ['document_create', 'document_create'],
             ['document_create:nxl_correspondence_document:nxw_title', ''],
             [
                 'document_create:nxl_correspondence_document:nxw_document_type',
                 '2'
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_sending_date',
                 ''
             ],
             [
                 'document_create_link_hidden_',
                 'document_create:nxl_correspondence_document:nxw_sending_date:trigger'
             ],
             [
                 'document_create_link_hidden_',
                 'document_create:nxl_correspondence_document:nxw_receive_date:trigger'
             ],
             [
                 'document_create_link_hidden_',
                 'document_create:nxl_correspondence_document:nxw_document_date:trigger'
             ],
             [
                 'document_create_link_hidden_',
                 'document_create:nxl_head_correspondence_incoming_document:nxw_scan_date:trigger'
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_receive_date',
                 ''
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_document_date',
                 ''
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_confidentiality',
                 '4'
             ], ['document_create:nxl_correspondence_document:nxw_origin', ''],
             ['document_create:nxl_correspondence_document:nxw_reference', ''],
             ['document_create:nxl_correspondence_document:nxw_body', ''],
             ['mce_editor_0_styleSelect', ''],
             ['mce_editor_0_formatSelect', ''],
             [
                 'document_create:nxl_head_correspondence_incoming_document:nxw_scan_site',
                 ''
             ],
             [
                 'document_create:nxl_head_correspondence_incoming_document:nxw_scan_date',
                 ''
             ],
             [
                 'document_create:nxl_file:nxw_file:nxw_file_file:choice',
                 'none'
             ], ['document_create:nxl_file:nxw_file:nxw_file_file:upload', ''],
             ['javax.faces.ViewState',
              self.getLastJsfState()], ['type', 'add'],
             [
                 'document_create:nxl_correspondence_document:nxw_contactsRecipients:nxw_contactsRecipients_add',
                 'document_create:nxl_correspondence_document:nxw_contactsRecipients:nxw_contactsRecipients_add'
             ], ['for', 'nxw_contactsRecipients_list']],
            description="Add recipient")

        self.post(
            server_url +
            "/correspondence/mail/create_correspondence_document.faces",
            params=
            [[
                'AJAXREQUEST',
                'document_create:nxl_correspondence_document:nxw_contactsSenders:nxw_contactsSenders_region'
            ], ['document_create', 'document_create'],
             ['document_create:nxl_correspondence_document:nxw_title', ''],
             [
                 'document_create:nxl_correspondence_document:nxw_document_type',
                 '2'
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_contactsRecipients:nxw_contactsRecipients_list:0:nxw_contactsRecipients_name',
                 ''
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_contactsRecipients:nxw_contactsRecipients_list:0:nxw_contactsRecipients_surname',
                 ''
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_contactsRecipients:nxw_contactsRecipients_list:0:nxw_contactsRecipients_service',
                 ''
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_sending_date',
                 ''
             ],
             [
                 'document_create_link_hidden_',
                 'document_create:nxl_correspondence_document:nxw_sending_date:trigger'
             ],
             [
                 'document_create_link_hidden_',
                 'document_create:nxl_correspondence_document:nxw_receive_date:trigger'
             ],
             [
                 'document_create_link_hidden_',
                 'document_create:nxl_correspondence_document:nxw_document_date:trigger'
             ],
             [
                 'document_create_link_hidden_',
                 'document_create:nxl_head_correspondence_incoming_document:nxw_scan_date:trigger'
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_receive_date',
                 ''
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_document_date',
                 ''
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_confidentiality',
                 '4'
             ], ['document_create:nxl_correspondence_document:nxw_origin', ''],
             ['document_create:nxl_correspondence_document:nxw_reference', ''],
             ['document_create:nxl_correspondence_document:nxw_body', ''],
             ['mce_editor_0_styleSelect', ''],
             ['mce_editor_0_formatSelect', ''],
             [
                 'document_create:nxl_head_correspondence_incoming_document:nxw_scan_site',
                 ''
             ],
             [
                 'document_create:nxl_head_correspondence_incoming_document:nxw_scan_date',
                 ''
             ],
             [
                 'document_create:nxl_file:nxw_file:nxw_file_file:choice',
                 'none'
             ], ['document_create:nxl_file:nxw_file:nxw_file_file:upload', ''],
             ['javax.faces.ViewState',
              self.getLastJsfState()],
             [
                 'document_create:nxl_correspondence_document:nxw_contactsSenders:nxw_contactsSenders_add',
                 'document_create:nxl_correspondence_document:nxw_contactsSenders:nxw_contactsSenders_add'
             ], ['type', 'add'], ['for', 'nxw_contactsSenders_list']],
            description="Add sender")

        self.post(
            server_url +
            "/correspondence/mail/create_correspondence_document.faces",
            params=
            [['document_create', 'document_create'],
             [
                 'document_create:nxl_correspondence_document:nxw_title',
                 lipsum.getSubject()
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_document_type',
                 '2'
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_contactsRecipients:nxw_contactsRecipients_list:0:nxw_contactsRecipients_name',
                 lipsum.getWord()
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_contactsRecipients:nxw_contactsRecipients_list:0:nxw_contactsRecipients_surname',
                 lipsum.getWord()
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_contactsRecipients:nxw_contactsRecipients_list:0:nxw_contactsRecipients_service',
                 lipsum.getWord()
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_sending_date',
                 today + ' 1:00 PM'
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_receive_date',
                 today + ' 2:00 PM'
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_document_date',
                 today + ' 11:00 AM'
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_confidentiality',
                 '4'
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_contactsSenders:nxw_contactsSenders_list:0:nxw_contactsSenders_name',
                 lipsum.getWord()
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_contactsSenders:nxw_contactsSenders_list:0:nxw_contactsSenders_surname',
                 lipsum.getWord()
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_contactsSenders:nxw_contactsSenders_list:0:nxw_contactsSenders_service',
                 lipsum.getWord()
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_origin',
                 lipsum.getAddress()
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_reference',
                 lipsum.getUniqWord()
             ],
             [
                 'document_create:nxl_correspondence_document:nxw_body',
                 lipsum.getParagraph()
             ],
             [
                 'document_create:nxl_head_correspondence_incoming_document:nxw_scan_site',
                 'nuxeo'
             ],
             [
                 'document_create:nxl_head_correspondence_incoming_document:nxw_scan_date',
                 today + ' 10:00 AM'
             ],
             [
                 'document_create:nxl_file:nxw_file:nxw_file_file:choice',
                 'upload'
             ], ['document_create_SUBMIT', '1'],
             [
                 'document_create:nxl_file:nxw_file:nxw_file_file:upload',
                 Upload("hello.pdf")
             ], ['document_create:j_id365', 'Create'],
             ['javax.faces.ViewState',
              self.getLastJsfState()]],
            description="Submit new mail")

        self.assert_('Incoming mail saved' in self.getBody())

        self.post(server_url +
                  "/correspondence/mail/view_correspondence_envelope.faces",
                  params=[['javax.faces.ViewState',
                           self.getLastJsfState()], ['j_id340_SUBMIT', '1'],
                          [
                              'j_id340:j_id341:j_id342:0:j_id343',
                              'j_id340:j_id341:j_id342:0:j_id343'
                          ]],
                  description="View distribution form")
        self.assert_('distribution_recipients' in self.getBody())

        self.post(
            server_url +
            "/correspondence/mail/distribution_correspondence_envelope.faces",
            params=
            [[
                'AJAXREQUEST',
                'distribution_recipients:nxl_correspondence_recipients:j_id328'
            ], ['distribution_recipients', 'distribution_recipients'],
             [
                 'distribution_recipients:nxl_correspondence_recipients:nxw_action_recipients_suggest',
                 receiver[0]
             ],
             [
                 'distribution_recipients:nxl_correspondence_recipients:nxw_action_recipients_suggestionBox_selection',
                 ''
             ],
             [
                 'distribution_recipients:nxl_correspondence_recipients:nxw_copy_recipients_suggest',
                 ''
             ],
             [
                 'distribution_recipients:nxl_correspondence_recipients:nxw_copy_recipients_suggestionBox_selection',
                 ''
             ], ['distribution_recipients:comment', ''],
             ['javax.faces.ViewState',
              self.getLastJsfState()],
             [
                 'ajaxSingle',
                 'distribution_recipients:nxl_correspondence_recipients:nxw_action_recipients_suggestionBox'
             ], ['mailboxSuggestionSearchType', ''],
             [
                 'distribution_recipients:nxl_correspondence_recipients:nxw_action_recipients_suggestionBox',
                 'distribution_recipients:nxl_correspondence_recipients:nxw_action_recipients_suggestionBox'
             ], ['inputvalue', receiver[0]], ['AJAX:EVENTS_COUNT', '1']],
            description="Search receiver")

        self.assert_(receiver[0] in self.getBody())

        self.post(
            server_url +
            "/correspondence/mail/distribution_correspondence_envelope.faces",
            params=
            [[
                'AJAXREQUEST',
                'distribution_recipients:nxl_correspondence_recipients:j_id328'
            ], ['distribution_recipients', 'distribution_recipients'],
             [
                 'distribution_recipients:nxl_correspondence_recipients:nxw_action_recipients_suggest',
                 ''
             ],
             [
                 'distribution_recipients:nxl_correspondence_recipients:nxw_action_recipients_suggestionBox_selection',
                 '0'
             ],
             [
                 'distribution_recipients:nxl_correspondence_recipients:nxw_copy_recipients_suggest',
                 ''
             ],
             [
                 'distribution_recipients:nxl_correspondence_recipients:nxw_copy_recipients_suggestionBox_selection',
                 ''
             ], ['distribution_recipients:comment', ''],
             ['javax.faces.ViewState',
              self.getLastJsfState()],
             [
                 'distribution_recipients:nxl_correspondence_recipients:nxw_action_recipients_suggestionBox:j_id335',
                 'distribution_recipients:nxl_correspondence_recipients:nxw_action_recipients_suggestionBox:j_id335'
             ], ['suggestionSelectionListId', 'nxw_action_recipients_list']],
            description="Select receiver")

        self.post(
            server_url +
            "/correspondence/mail/distribution_correspondence_envelope.faces",
            params=
            [['distribution_recipients', 'distribution_recipients'],
             [
                 'distribution_recipients:nxl_correspondence_recipients:nxw_action_recipients_suggest',
                 ''
             ],
             [
                 'distribution_recipients:nxl_correspondence_recipients:nxw_action_recipients_suggestionBox_selection',
                 ''
             ],
             [
                 'distribution_recipients:nxl_correspondence_recipients:nxw_copy_recipients_suggest',
                 ''
             ],
             [
                 'distribution_recipients:nxl_correspondence_recipients:nxw_copy_recipients_suggestionBox_selection',
                 ''
             ], ['distribution_recipients:comment',
                 lipsum.getSentence()],
             ['distribution_recipients:j_id389', 'Send'],
             ['distribution_recipients_SUBMIT', '1'],
             ['javax.faces.ViewState',
              self.getLastJsfState()]],
            description="Send mail")

        self.assert_('The distribution is done' in self.getBody())

        self.get(server_url + "/logout", description="Log out")

        # end of test -----------------------------------------------

    def tearDown(self):
        """Setting up test."""
        self.logd("tearDown.\n")
 def setUp(self):
     """Setting up test."""
     self.logd("setUp")
     self.server_url = self.conf_get('main', 'url')
     self.lipsum = Lipsum(vocab=V_ASCII, chars=CHARS, sep=SEP)
class Dav(FunkLoadTestCase):
    ws_title = "FLNXTest-Dav-workspace"
    dir_title = "FLNXTEST-Dav-folder"
    tag = "FLNXTEST"
    _lipsum = Lipsum()

    def setUp(self):
        self.server_url = self.conf_get('main', 'url')
        self.credential_host = self.conf_get('credential', 'host')
        self.credential_port = self.conf_getInt('credential', 'port')
        self.cred_admin = xmlrpc_get_credential(self.credential_host,
                                                self.credential_port, 'admin')
        self.dav_url = self.server_url + "/site/dav"
        self.nb_docs = self.conf_getInt('testWriter', 'nb_docs')
        self.cred_member = xmlrpc_get_credential(self.credential_host,
                                                 self.credential_port,
                                                 'members')

    def initWorkspace(self):
        """Create an initial workspace using rest,
        because DAV is not allowed to create workspace."""
        r = RestAPI(self)
        r.login(*self.cred_admin)
        root_uid = r.getRootWorkspaceUid()
        ws_uid = r.getChildUid(root_uid, self.ws_title, 'Workspace')
        if not ws_uid:
            ws_uid = r.createDocument(root_uid, 'Workspace', self.ws_title,
                                      'DAV Test workspace description.')

    def testDav(self):
        self.initWorkspace()
        self.setBasicAuth(*self.cred_admin)
        dav_url = self.dav_url

        resp = self.options(dav_url, description="option on root")
        dav = resp.headers.get('DAV')
        self.assert_(dav is not None)
        self.assert_(dav == '1,2')
        allow = resp.headers.get('Allow')
        for method in ['PROPPATCH', 'MKCOL', 'COPY', 'MOVE', 'LOCK', 'UNLOCK']:
            self.assert_(method in allow)

        resp = self.propfind(dav_url,
                             depth=0,
                             description="propfind root depth0")
        # dom = parseString(self.getBody())
        #for node in dom.firstChild.childNodes:
        #    print node.toxml()
        resp = self.propfind(dav_url,
                             depth=1,
                             description="propfind root depth1")
        dom = parseString(self.getBody())
        for node in dom.getElementsByTagName('ns2:href'):
            url = node.firstChild.data
            # print url

        url = dav_url + "/" + self.ws_title
        folder_url = url + "/" + self.dir_title
        self.delete(folder_url,
                    ok_codes=[204, 404],
                    description="Remove folder")

        self.method("MKCOL",
                    folder_url,
                    ok_codes=[
                        201,
                    ],
                    description="Create a folder")
        resp = self.propfind(folder_url,
                             depth=0,
                             description="propfind root depth0")

        # create file
        doc_url = folder_url + '/' + self._lipsum.getUniqWord() + '.txt'
        content = self._lipsum.getSentence()
        self.put(doc_url,
                 params=Data(None, content),
                 description="Create a doc",
                 ok_codes=[
                     201,
                 ])
        # self.delete(folder_url, ok_codes=[204, ],
        #            description="Remove folder")

        self.clearBasicAuth()

    def testWriter(self):
        self.initWorkspace()
        self.setBasicAuth(*self.cred_admin)
        dav_url = self.dav_url
        url = dav_url + "/" + self.ws_title

        folder_url = url + "/" + self._lipsum.getUniqWord()
        # create a folder
        self.method("MKCOL",
                    folder_url,
                    ok_codes=[
                        201,
                    ],
                    description="Create a folder")
        #resp = self.propfind(folder_url, depth=0,
        #                     description="propfind root depth0")
        # create files
        for i in range(self.nb_docs):
            doc_url = folder_url + '/' + self._lipsum.getUniqWord() + '.txt'
            content = self._lipsum.getParagraph()
            self.put(doc_url,
                     params=Data(None, content),
                     description="Create a doc " + str(i),
                     ok_codes=[
                         201,
                     ])
        self.clearBasicAuth()

    def testUserAgents(self):
        dav_url = self.dav_url
        # check that nuxeo ask for digest auth for the following ua
        uas = [
            "MSFrontPage 1", "Microsoft-WebDAV-MiniRedir 1", "DavClnt"
            "litmus 1", "gvfs 1", "davfs 1", "WebDAV 1", "cadaver 1"
        ]
        for ua in uas:
            self.setUserAgent(ua)
            resp = self.propfind(dav_url,
                                 description="test ua auth for " + ua,
                                 ok_codes=[
                                     401,
                                 ])
            auth = resp.headers.get('WWW-Authenticate')
            # print auth
            self.assert_("Digest realm" in auth, "%s: %s" % (ua, auth))
        # unknown UA also requires authentication
        self.setUserAgent("FunkLoad")
        resp = self.propfind(dav_url,
                             description="test non DAV ua",
                             ok_codes=[
                                 401,
                             ])

    def testLocks(self):
        self.initWorkspace()
        self.setBasicAuth(*self.cred_admin)
        dav_url = self.dav_url
        url = dav_url + "/" + self.ws_title
        doc_url = url + "/" + "lockme"
        content = self._lipsum.getParagraph()

        self.delete(doc_url,
                    ok_codes=[204, 404],
                    description="Remove doc if exists")

        self.put(doc_url,
                 params=Data(None, content),
                 description="Create a doc",
                 ok_codes=[
                     201,
                 ])

        data = Data(
            'text/xml', """<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<lockinfo xmlns='DAV:'>
 <lockscope><exclusive/></lockscope>
<locktype><write/></locktype><owner>funkload test suite</owner>
</lockinfo>""")
        self.method("LOCK", doc_url, params=data, description="Lock")

        self.propfind(doc_url, ok_codes=[
            207,
        ], description="Get info")
        # nothing in the response tell that the doc is locked :/
        # print self.getBody()
        self.method("UNLOCK", doc_url, ok_codes=[
            204,
        ], description="Unlock")

        self.delete(doc_url, ok_codes=[
            204,
        ], description="Remove doc")

    def testCreateUpdate(self):
        self.initWorkspace()
        self.setBasicAuth(*self.cred_admin)
        dav_url = self.dav_url
        url = dav_url + "/" + self.ws_title

        folder_url = url + "/" + self._lipsum.getUniqWord()
        # create a folder
        self.method("MKCOL",
                    folder_url,
                    ok_codes=[
                        201,
                    ],
                    description="Create a folder")
        # create files
        for i in range(self.nb_docs):
            doc_url = folder_url + '/' + self._lipsum.getUniqWord() + '.txt'
            content = self._lipsum.getParagraph()
            self.put(doc_url,
                     params=Data(None, content),
                     description="Create a doc " + str(i),
                     ok_codes=[
                         201,
                     ])
            content += self._lipsum.getParagraph() + " UPDATE"
            self.put(doc_url,
                     params=Data(None, content),
                     description="Update doc " + str(i),
                     ok_codes=[
                         201,
                     ])
            #self.delete(doc_url, ok_codes=[204, ], description="Delete doc")
        self.clearBasicAuth()
Exemple #26
0
 def setUp(self):
     """Setting up test."""
     self.server_url = self.conf_get('main', 'url')
     self.lipsum = Lipsum()
Exemple #27
0
class ConfDBScaling(FunkLoadTestCase):
    """This test use a configuration file Conf.conf."""
    def setUp(self):
        """Setting up test."""
        self.server_url = self.conf_get('main', 'url')

        credential_host = self.conf_get('credential', 'host')
        credential_port = self.conf_getInt('credential', 'port')
        self.username, self.pwd = xmlrpc_get_credential(
            credential_host, credential_port, "group1")

        self.lipsum = Lipsum()

    def tearDown(self):
        self.logout()

    def login(self, page="/index"):
        # The description should be set in the configuration file
        server_url = self.server_url

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

        csrftoken = extract_token(self.getBody(),
                                  "name='csrfmiddlewaretoken' value='", "' />")
        self.post(server_url + "/accounts/login/?next=" + page,
                  params=[['csrfmiddlewaretoken', csrftoken],
                          ['redirect_to', page], ['username', self.username],
                          ['password', self.pwd]],
                  description="Post /accounts/login/")

    def logout(self):
        self.get(self.server_url + "/accounts/logout/",
                 description="Get /accounts/logout/")

    def test_show_all_papers(self):
        page = "/index"
        self.login(page)
        self.assert_(page == self.getLastUrl(), "Error in login")
        reply = self.get(self.server_url + page, description="Get papers")
        self.logout()

    def test_show_all_users(self):
        page = "/users"
        self.login(page)
        self.assert_(page == self.getLastUrl(), "Error in login")
        reply = self.get(self.server_url + page, description="Get papers")
        self.logout()

    def test_view_paper(self):
        page = "/paper?id=1"  #EnGM55IPia7nBrhBHuDqSbeG6nDghG8l"
        self.login(page)
        reply = self.get(self.server_url + page, description="Get paper")
        self.assert_("paper" in self.getLastUrl(), "Error in showing paper")
        self.logout()

    # TODO: Submit a paper.
    def test_submit_paper(self):
        page = "/submit"
        self.login(page)
        self.assert_(page == self.getLastUrl(), "Error in login")

        num_papers = self.conf_getInt('test_submit_paper', 'num_papers')
        for i in range(num_papers):
            csrftoken = extract_token(self.getBody(),
                                      "name='csrfmiddlewaretoken' value='",
                                      "' />")
            self.post(
                self.server_url + "/submit",
                params=[['csrfmiddlewaretoken', csrftoken],
                        ['coauthors[]', self.lipsum.getWord()],
                        ['coauthors[]', self.lipsum.getWord()],
                        ['title', self.lipsum.getSentence()],
                        ['contents',
                         Upload('files/rms_crossstitch.pdf')],
                        ['abstract', self.lipsum.getMessage()]],
                description="Post /accounts/login/")
            self.assert_("paper" in self.getLastUrl(), "Error in login")

    # TODO: View profile.
    def test_view_profile(self):
        page = "/accounts/profile/"
        self.login(page)
        self.assert_(page == self.getLastUrl(), "Error in login")
class SeamBooking(FunkLoadTestCase):
    """Simple test to register a new user and book an hotel.

    This test uses the configuration file SeamBooking.conf.
    """

    jsf_tag_tree = '<input type="hidden" name="jsf_tree_64" id="jsf_tree_64" value="'
    jsf_tag_state = '<input type="hidden" name="jsf_state_64" id="jsf_state_64" value="'

    hotel_names = ["Tower", "Ritz", "Sea", "Hotel"]
    nb_letters = 3  # number of letter to type when searching an hotel
    password = "******"  # password used for users

    def jsfParams(self, params):
        """Helper to extarct jsf states from the last page and add them to the params."""
        html = self.getBody()
        tag = self.jsf_tag_tree
        start = html.find(tag) + len(tag)
        end = html.find('"', start)
        if start < 0 or end < 0:
            raise ValueError('No Jsf STATE TREE found in the previous page.')
        state = html[start:end]
        params.insert(0, ["jsf_tree_64", state])
        tag = self.jsf_tag_state
        start = html.find(tag) + len(tag)
        end = html.find('"', start)
        if start < 0 or end < 0:
            raise ValueError('No Jsf STATE STATE found in the previous page.')
        state = html[start:end]
        params.insert(1, ["jsf_state_64", state])
        return params

    def setUp(self):
        """Setting up test."""
        self.logd("setUp")
        self.server_url = self.conf_get('main', 'url')
        self.lipsum = Lipsum()

    def test_seam_booking(self):
        # The description should be set in the configuration file
        server_url = self.server_url

        self.get(server_url + "/seam-booking/home.seam",
                 description="Booking home page")
        register_link = self.listHref(content_pattern="Register New User")
        self.assert_(len(register_link), "Register link not found")
        register_link = register_link[0]

        self.get(server_url + register_link, description="Register new User")
        self.assert_("register_SUBMIT" in self.getBody(),
                     "Failing to view Registration page.")

        username = self.lipsum.getUniqWord()
        realname = username + " " + self.lipsum.getUniqWord()
        password = self.password

        self.post(
            server_url + "/seam-booking/register.seam",
            self.jsfParams(params=[
                ['register:username', username], ['register:name', realname],
                ['register:password', password], ['register:verify', password],
                ['register:register', 'Register'], ['register_SUBMIT', '1'],
                ['register:_link_hidden_', ''],
                ['jsf_viewid', '/register.xhtml']
            ]),
            description="Submit register form")
        self.assert_("Successfully registered as" in self.getBody(),
                     "Failing register new user.")
        params = self.jsfParams(
            params=[['login:username', username], ['login:password', password],
                    ['login:login', 'Account Login'], ['login_SUBMIT', '1'],
                    ['login:_link_hidden_', ''], ['jsf_viewid', '/home.xhtml']
                    ])
        self.post(server_url + "/seam-booking/home.seam",
                  params,
                  description="Submit account login")
        self.assert_(
            username in self.getBody(), "Failing login new user %s:%s" %
            (username, password) + str(params))
        self.assert_(
            "No Bookings Found" in self.getBody(),
            "Weird there should be no booking for new user %s:%s" %
            (username, password))

        # Simulate ajax search for an hotel by typing nb_letters
        nb_letters = self.nb_letters
        hotel_query = random.choice(self.hotel_names)
        for i in range(1, nb_letters + 1):
            self.post(
                server_url + "/seam-booking/main.seam",
                self.jsfParams(
                    params=[['AJAXREQUEST', '_viewRoot'],
                            ['main:searchString', hotel_query[:i]],
                            ['main:pageSize', '10'], ['main_SUBMIT', '1'],
                            ['jsf_viewid', '/main.xhtml'],
                            ['main:findHotels', 'main:findHotels']]),
                description="Ajax search %i letter" % i)
            self.assert_("View Hotel" in self.getBody(),
                         "No match for search hotel.")

        # Extract the list of link to hotel and choose a random one
        hotel_links = self.listHref(content_pattern="View Hotel")
        self.get(server_url + random.choice(hotel_links),
                 description="View a random hotel in the result list")
        self.assert_("hotel_SUBMIT" in self.getBody())

        self.post(
            server_url + "/seam-booking/hotel.seam",
            self.jsfParams(
                params=[['hotel:bookHotel', 'Book Hotel'],
                        ['hotel_SUBMIT', '1'], ['hotel:_link_hidden_', ''],
                        ['jsf_viewid', '/hotel.xhtml']]),
            description="Book hotel")
        self.assert_("booking_SUBMIT" in self.getBody())

        self.post(
            server_url + "/seam-booking/book.seam",
            self.jsfParams(
                params=[['booking:checkinDate', '11/07/2008'],
                        ['booking:checkoutDate', '11/08/2008'],
                        ['booking:beds', '1'], ['booking:smoking', 'false'],
                        ['booking:creditCard', '1234567890123456'],
                        ['booking:creditCardName', realname],
                        ['booking:creditCardExpiryMonth', '1'],
                        ['booking:creditCardExpiryYear', '2009'],
                        ['booking:proceed', 'Proceed'],
                        ['booking_SUBMIT', '1'], ['booking:_link_hidden_', ''],
                        ['jsf_viewid', '/book.xhtml']]),
            description="Proceed booking")
        self.assert_("confirm_SUBMIT" in self.getBody())

        self.post(
            server_url + "/seam-booking/confirm.seam",
            self.jsfParams(
                params=[['confirm:confirm', 'Confirm'],
                        ['confirm_SUBMIT', '1'], ['confirm:_link_hidden_', ''],
                        ['jsf_viewid', '/confirm.xhtml']]),
            description="Confirm booking")
        self.assert_("No Bookings Found" not in self.getBody(),
                     "Booking is not taken in account.")

        # Logout
        logout_link = self.listHref(content_pattern="Logout")
        self.assert_(len(logout_link), "Logout link not found")
        logout_link = logout_link[0]
        self.get(server_url + logout_link, description="Logout")
        self.assert_("login_SUBMIT" in self.getBody())

        # end of test -----------------------------------------------

    def tearDown(self):
        """Setting up test."""
        self.logd("tearDown.\n")
Exemple #29
0
class Hipaa(FunkLoadTestCase):
    """This test use a configuration file Conf.conf."""

    def setUp(self):
        """Setting up test."""
        self.server_url = self.conf_get('main', 'url')
        self.lipsum = Lipsum()

    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

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

        csrftoken = extract_token(self.getBody(), "name='csrfmiddlewaretoken' value='", "' />")
        self.post(server_url + "/accounts/login/?next=" + pageURL,
            params=[['csrfmiddlewaretoken', csrftoken],
            ['redirect_to', pageURL],
            ['username', username],
            ['password', password]],
            description="Post /accounts/login/")

    def logout(self):
        self.get(self.server_url + "/accounts/logout/",
                    description="Get /accounts/logout/")

    def test_simple(self):
        # The description should be set in the configuration file
        server_url = self.server_url
        # begin of test ---------------------------------------------
        nb_time = self.conf_getInt('test_simple', 'nb_time')
        for i in range(nb_time):
            self.get(server_url, description='Get url')
        # end of test -----------------------------------------------

    def test_login(self):
        page="/index"
        self.login_as("admin", "admin")
        reply = self.get(self.server_url + page, description="Get index")
        self.logout()

    def test_register(self):
        self.logout()

        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')
        credential_port = self.conf_getInt('credential', 'port')
        login, pwd = xmlrpc_get_credential(credential_host, credential_port
            , "group1")
        self.login_as(login, pwd)
        self.logout()

    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()
Exemple #30
0
class Rest(FunkLoadTestCase):
    ws_title = "FLNXTEST Rest workspace"
    dir_title = "FLNXTEST Rest folder"
    tag = "FLNXTEST"
    _lipsum = Lipsum()

    def setUp(self):
        self.server_url = self.conf_get('main', 'url')
        self.nb_doc = self.conf_getInt('testWriter', 'nb_doc')
        self.nb_read = self.conf_getInt('testReader', 'nb_read')
        self.credential_host = self.conf_get('credential', 'host')
        self.credential_port = self.conf_getInt('credential', 'port')
        self.cred_admin = xmlrpc_get_credential(self.credential_host,
                                                self.credential_port, 'admin')

    def FAIL_testUpload(self):
        r = RestAPI(self)
        r.login(*self.cred_admin)
        uid = '44f1af7e-5206-4f39-b935-55bb32ab3112'
        r.uploadFile(uid, 'foo.txt')

        r.logout()

    def testWriter(self):
        # Create a folder and few documents
        r = RestAPI(self)
        r.login(*self.cred_admin)
        root_uid = r.getRootWorkspaceUid()
        ws_uid = r.getChildUid(root_uid, self.ws_title, 'Workspace')
        if not ws_uid:
            ws_uid = r.createDocument(root_uid, 'Workspace', self.ws_title,
                                      'Test workspace description.')
        dir_uid = r.getChildUid(ws_uid, self.dir_title, 'Folder')
        if not dir_uid:
            dir_uid = r.createDocument(ws_uid, 'Folder', self.dir_title,
                                       'Test folder description')
        for i in range(self.nb_doc):
            title = self._lipsum.getSubject(uniq=True, prefix=self.tag)
            description = self.tag + ' ' + self._lipsum.getParagraph(1)
            uid = r.createDocument(dir_uid, 'File', title, description)
        r.logout()

    def testReader(self):
        # browse the workspace
        r = RestAPI(self)
        r.login(*self.cred_admin)
        uid = r.getRootWorkspaceUid()
        uid = r.getChildUid(uid, self.ws_title, 'Workspace')
        self.assert_(uid, 'Workspace "%s" not found.' % self.ws_title)
        uid = r.getChildUid(uid, self.dir_title, 'Folder')
        self.assert_(uid, 'Folder "%s" not found.' % self.dir_title)
        count = 0
        nb_read = self.nb_read
        for item in r.browse(uid):
            ret = r.exportTree(item.id)
            zc = ZipFile(StringIO(ret))
            self.assert_('.nuxeo-archive' in zc.namelist())
            count += 1
            if count > nb_read:
                break
        r.logout()
Exemple #31
0
class Hipaa(FunkLoadTestCase):
    """This test use a configuration file Conf.conf."""
    def setUp(self):
        """Setting up test."""
        self.server_url = self.conf_get('main', 'url')
        self.lipsum = Lipsum()

    def login_as(self, username, password):
        # 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=/",
                  params=[['csrfmiddlewaretoken', csrftoken],
                          ['redirect_to', '/index'], ['username', username],
                          ['password', password]],
                  description="Post /accounts/login/")

    def logout(self):
        self.get(self.server_url + "/accounts/logout/",
                 description="Get /accounts/logout/")

    def test_simple(self):
        # The description should be set in the configuration file
        server_url = self.server_url
        # begin of test ---------------------------------------------
        nb_time = self.conf_getInt('test_simple', 'nb_time')
        for i in range(nb_time):
            self.get(server_url, description='Get url')
        # end of test -----------------------------------------------

    def test_login(self):
        page = "/index"
        self.login_as("admin", "admin")
        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')

        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")

    def test_credential(self):
        credential_host = self.conf_get('credential', 'host')
        credential_port = self.conf_getInt('credential', 'port')
        login, pwd = xmlrpc_get_credential(credential_host, credential_port,
                                           "group1")
        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', '*****@*****.**'],
                          ['profiletype', '1']],
                  description="Post /register")

        # TODO: Check page after logging in.
        self.logout()
        self.login_as(username, password)
        self.logout()
 def setUp(self):
     """Setting up whitelist test."""
     self.title = self.conf_get('main', 'title')
     self.logd("Setting up test: %s\n" % self.title)
     self.lipsum = Lipsum()
Exemple #33
0
class ConfDBScaling(FunkLoadTestCase):
    """This test use a configuration file Conf.conf."""

    def setUp(self):
        """Setting up test."""
        self.server_url = self.conf_get('main', 'url')
        
        credential_host = self.conf_get('credential', 'host')
        credential_port = self.conf_getInt('credential', 'port')
        self.username, self.pwd = xmlrpc_get_credential(
            credential_host, credential_port, "group1")

        self.lipsum = Lipsum()

    def tearDown(self):
        self.logout()

    def login(self, page="/index"):
        # The description should be set in the configuration file
        server_url = self.server_url

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

        csrftoken = extract_token(self.getBody(), "name='csrfmiddlewaretoken' value='", "' />")
        self.post(server_url + "/accounts/login/?next=" + page,
            params=[['csrfmiddlewaretoken', csrftoken],
            ['redirect_to', page],
            ['username', self.username],
            ['password', self.pwd]],
            description="Post /accounts/login/")

    def logout(self):
        self.get(self.server_url + "/accounts/logout/",
                    description="Get /accounts/logout/")

    def test_show_all_papers(self):
        page = "/index"
        self.login(page)
        self.assert_(page == self.getLastUrl(), "Error in login")
        reply = self.get(self.server_url + page, description="Get papers")
        self.logout()

    def test_show_all_users(self):
        page = "/users"
        self.login(page)
        self.assert_(page == self.getLastUrl(), "Error in login")
        reply = self.get(self.server_url + page, description="Get papers")
        self.logout()

    def test_view_paper(self):
        page = "/paper?id=1" #EnGM55IPia7nBrhBHuDqSbeG6nDghG8l"
        self.login(page)
        reply = self.get(self.server_url + page, description = "Get paper")
        self.assert_("paper" in self.getLastUrl(), "Error in showing paper")
        self.logout()

    # TODO: Submit a paper.
    def test_submit_paper(self):
        page = "/submit"
        self.login(page)
        self.assert_(page == self.getLastUrl(), "Error in login")

        num_papers = self.conf_getInt('test_submit_paper', 'num_papers')
        for i in range(num_papers):
            csrftoken = extract_token(self.getBody(), "name='csrfmiddlewaretoken' value='", "' />")
            self.post(self.server_url + "/submit",
                params=[['csrfmiddlewaretoken', csrftoken],
                ['coauthors[]', self.lipsum.getWord()],
                ['coauthors[]', self.lipsum.getWord()], 
                ['title', self.lipsum.getSentence()],
                ['contents', Upload('files/rms_crossstitch.pdf')],
                ['abstract', self.lipsum.getMessage()]],
                description="Post /accounts/login/")
            self.assert_("paper" in self.getLastUrl(), "Error in login")

    # TODO: View profile.
    def test_view_profile(self):
        page = "/accounts/profile/"
        self.login(page)
        self.assert_(page == self.getLastUrl(), "Error in login")
class SeamBooking(FunkLoadTestCase):
    """Simple test to register a new user and book an hotel.

    This test uses the configuration file SeamBooking.conf.
    """

    jsf_tag_tree = '<input type="hidden" name="jsf_tree_64" id="jsf_tree_64" value="'
    jsf_tag_state = '<input type="hidden" name="jsf_state_64" id="jsf_state_64" value="'

    hotel_names = ["Tower", "Ritz", "Sea", "Hotel"]
    nb_letters = 3        # number of letter to type when searching an hotel
    password = "******" # password used for users

    def jsfParams(self, params):
        """Helper to extarct jsf states from the last page and add them to the params."""
        html = self.getBody()
        tag = self.jsf_tag_tree
        start = html.find(tag) + len(tag)
        end = html.find('"', start)
        if start < 0 or end < 0:
            raise ValueError('No Jsf STATE TREE found in the previous page.')
        state = html[start:end]
        params.insert(0, ["jsf_tree_64", state])
        tag = self.jsf_tag_state
        start = html.find(tag) + len(tag)
        end = html.find('"', start)
        if start < 0 or end < 0:
            raise ValueError('No Jsf STATE STATE found in the previous page.')
        state = html[start:end]
        params.insert(1, ["jsf_state_64", state])
        return params


    def setUp(self):
        """Setting up test."""
        self.logd("setUp")
        self.server_url = self.conf_get('main', 'url')
        self.lipsum = Lipsum()


    def test_seam_booking(self):
        # The description should be set in the configuration file
        server_url = self.server_url

        self.get(server_url + "/seam-booking/home.seam",
            description="Booking home page")
        register_link = self.listHref(content_pattern="Register New User")
        self.assert_(len(register_link), "Register link not found")
        register_link = register_link[0]

        self.get(server_url + register_link,
                 description="Register new User")
        self.assert_("register_SUBMIT" in self.getBody(),
                     "Failing to view Registration page.")

        username = self.lipsum.getUniqWord()
        realname = username + " " + self.lipsum.getUniqWord()
        password = self.password

        self.post(server_url + "/seam-booking/register.seam", self.jsfParams(params=[
            ['register:username', username],
            ['register:name', realname],
            ['register:password', password],
            ['register:verify', password],
            ['register:register', 'Register'],
            ['register_SUBMIT', '1'],
            ['register:_link_hidden_', ''],
            ['jsf_viewid', '/register.xhtml']]),
            description="Submit register form")
        self.assert_("Successfully registered as" in self.getBody(),
                     "Failing register new user.")
        params = self.jsfParams(params=[
            ['login:username', username],
            ['login:password', password],
            ['login:login', 'Account Login'],
            ['login_SUBMIT', '1'],
            ['login:_link_hidden_', ''],
            ['jsf_viewid', '/home.xhtml']])
        self.post(server_url + "/seam-booking/home.seam", params,
            description="Submit account login")
        self.assert_(username in self.getBody(),
                     "Failing login new user %s:%s" % (username, password) + str(params))
        self.assert_("No Bookings Found" in self.getBody(),
                     "Weird there should be no booking for new user %s:%s" %
                     (username, password))

        # Simulate ajax search for an hotel by typing nb_letters
        nb_letters = self.nb_letters
        hotel_query = random.choice(self.hotel_names)
        for i in range(1, nb_letters + 1):
            self.post(server_url + "/seam-booking/main.seam", self.jsfParams(params=[
            ['AJAXREQUEST', '_viewRoot'],
            ['main:searchString', hotel_query[:i]],
            ['main:pageSize', '10'],
            ['main_SUBMIT', '1'],
            ['jsf_viewid', '/main.xhtml'],
            ['main:findHotels', 'main:findHotels']]),
            description="Ajax search %i letter" % i)
            self.assert_("View Hotel" in self.getBody(),
                         "No match for search hotel.")

        # Extract the list of link to hotel and choose a random one
        hotel_links = self.listHref(content_pattern="View Hotel")
        self.get(server_url + random.choice(hotel_links),
                 description="View a random hotel in the result list")
        self.assert_("hotel_SUBMIT" in self.getBody())

        self.post(server_url + "/seam-booking/hotel.seam", self.jsfParams(params=[
            ['hotel:bookHotel', 'Book Hotel'],
            ['hotel_SUBMIT', '1'],
            ['hotel:_link_hidden_', ''],
            ['jsf_viewid', '/hotel.xhtml']]),
            description="Book hotel")
        self.assert_("booking_SUBMIT" in self.getBody())

        self.post(server_url + "/seam-booking/book.seam", self.jsfParams(params=[
            ['booking:checkinDate', '11/07/2008'],
            ['booking:checkoutDate', '11/08/2008'],
            ['booking:beds', '1'],
            ['booking:smoking', 'false'],
            ['booking:creditCard', '1234567890123456'],
            ['booking:creditCardName', realname],
            ['booking:creditCardExpiryMonth', '1'],
            ['booking:creditCardExpiryYear', '2009'],
            ['booking:proceed', 'Proceed'],
            ['booking_SUBMIT', '1'],
            ['booking:_link_hidden_', ''],
            ['jsf_viewid', '/book.xhtml']]),
            description="Proceed booking")
        self.assert_("confirm_SUBMIT" in self.getBody())

        self.post(server_url + "/seam-booking/confirm.seam", self.jsfParams(params=[
            ['confirm:confirm', 'Confirm'],
            ['confirm_SUBMIT', '1'],
            ['confirm:_link_hidden_', ''],
            ['jsf_viewid', '/confirm.xhtml']]),
            description="Confirm booking")
        self.assert_("No Bookings Found" not in self.getBody(),
                     "Booking is not taken in account.")

        # Logout
        logout_link = self.listHref(content_pattern="Logout")
        self.assert_(len(logout_link), "Logout link not found")
        logout_link = logout_link[0]
        self.get(server_url + logout_link,
            description="Logout")
        self.assert_("login_SUBMIT" in self.getBody())

        # end of test -----------------------------------------------

    def tearDown(self):
        """Setting up test."""
        self.logd("tearDown.\n")
Exemple #35
0
class Pages(NuxeoTestCase):
    ws_title = "FLNXTEST Page workspace"
    dir_title = "FLNXTEST Page folder"
    tag = "FLNXTEST"
    _lipsum = Lipsum()

    def testAvailable(self):
        BasePage(self).available()

    def testLoginPage(self):
        (LoginPage(self).view().login(*self.cred_admin).logout())
        LoginPage(self).loginInvalid('foo', 'bar')

    def testBasePageViewDocumentPath(self):
        # fluent test
        p = (LoginPage(self).login(
            *self.cred_admin).getRootWorkspaces().logout())

        p = (LoginPage(self).login(
            *self.cred_admin).viewDocumentPath("workspaces"))
        # TODO assert we are on workspaces
        ret = p.viewDocumentPath("workspaces/that/does/not/exists",
                                 raiseOn404=False)
        self.assert_(ret is None, "Expecting None for a 404.")
        p.logout()

    def testNavigation(self):
        p = (LoginPage(self).login(*self.cred_admin).getRootWorkspaces())
        p = (p.rights().manage())
        p = (
            p.getRootWorkspaces().personalWorkspace().getRootWorkspaces()
            #XXX NXP-15036 Update search method with search tab
            #.search('workspaces')
            .logout())

    def testSections(self):
        title = self._lipsum.getSubject(uniq=True, prefix=self.tag)
        description = self.tag + ' ' + self._lipsum.getParagraph(1)
        p = (LoginPage(self).login(
            *self.cred_admin).getRootSections().createSection(
                title, description))
        p = (p.getRootSections().deleteItem(title, "Section").logout())

    def dbgtestPublish(self):
        p = LoginPage(self).login(*self.cred_admin)
        p.viewDocumentPath(
            'workspaces/flnxtest-page-workspace/flnxtest-page-folder/flnxtest-tsoc1g7-tris'
        )
        p.publish().publishOnFirstSection()
        p.logout()

    def testPublish(self):
        title = self._lipsum.getSubject(uniq=True, prefix=self.tag)
        description = self.tag + ' ' + self._lipsum.getParagraph(1)
        title_section = self._lipsum.getSubject(uniq=True, prefix=self.tag)

        p = (LoginPage(self).login(
            *self.cred_admin).getRootSections().createSection(
                title_section,
                description).rights().grant('ReadWrite',
                                            'Members group').view())
        p = (LoginPage(self).login(
            *self.cred_admin).getRootWorkspaces().createWorkspace(
                self.ws_title, 'A description').view().createFolder(
                    self.dir_title,
                    'A description').createFile(title, description))
        p = (p.publish().publishOnFirstSection())
        p = (p.getRootWorkspaces().deleteItem(
            self.ws_title).getRootSections().deleteItem(
                title_section, "Section"))
        p.logout()

    def testFolderPage(self):
        title = self._lipsum.getSubject(uniq=True, prefix=self.tag)
        description = self.tag + ' ' + self._lipsum.getParagraph(1)
        p = (LoginPage(self).login(
            *self.cred_admin).getRootWorkspaces().createWorkspace(
                self.ws_title, 'A description').rights().grant(
                    'ReadWrite', 'Members group').view().createFolder(
                        self.dir_title, 'A description'))
        fuid = p.getDocUid()
        p.createFile(title, description)
        p = (p.viewDocumentUid(fuid).sort('author').sort('title').sort(
            'lifecycle').sort('date'))
        p = (p.getRootWorkspaces().deleteItem(self.ws_title).logout())

    def testFileTabs(self):
        title = self._lipsum.getSubject(uniq=True, prefix=self.tag)
        description = self.tag + ' ' + self._lipsum.getParagraph(1)
        p = (LoginPage(self).login(
            *self.cred_admin).getRootWorkspaces().createWorkspace(
                self.ws_title, 'A description').view().createFolder(
                    self.dir_title,
                    'A description').createFile(title, description))
        p = (p.edit().files().publish().relations().comments().history())
        p = (p.getRootWorkspaces().deleteItem(self.ws_title).logout())

    def testUsersGroupsPage(self):
        p = LoginPage(self).login(*self.cred_admin)
        login = self.tag.lower()
        pwd = 'secret'
        p = (p.adminCenter().usersAndGroupsPage().createUser(
            login,
            '*****@*****.**',
            pwd,
            groups='members',
            firstname="first",
            lastname=login.capitalize()).createUser(login,
                                                    '*****@*****.**',
                                                    pwd,
                                                    groups='members',
                                                    firstname='first',
                                                    lastname='last'))
        p.exitAdminCenter().logout()
        p.login(login, pwd).getRootWorkspaces().logout()
class Writeheavy(FunkLoadTestCase.FunkLoadTestCase):
    """Heavy write load test scenario

    This test use a configuration file Writeheavy.conf.
    """

    def setUp(self):
        """Setting up test."""
        self.logd("setUp")
        self.server_url = self.conf_get('main', 'url')
        self.lipsum = Lipsum(vocab=V_ASCII, chars=CHARS, sep=SEP)
        # XXX here you can setup the credential access like this
        # credential_host = self.conf_get('credential', 'host')
        # credential_port = self.conf_getInt('credential', 'port')
        # self.login, self.password = xmlrpc_get_credential(credential_host,
        #                                                   credential_port,
        # XXX replace with a valid group
        #                                                   'members')

    def test_WriteHeavy(self):
        # The description should be set in the configuration file
        
        server_url = self.server_url
        # begin of test ---------------------------------------------

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

        join_form = self.get(server_url + "/coreloadtests/register",
                          description="Get /coreloadtests/register")

        _authenticator = AUTHENTICATOR_RE.search(join_form.body).group(1)

        user_id = self.lipsum.getWord()
        user_fullname = self.lipsum.getSubject(length=2, prefix=None, uniq=True)
        
        self.post(server_url + "/coreloadtests/register", params=[
            ['form.fullname', user_fullname],
            ['form.username', user_id],
            ['form.email', '*****@*****.**'],
            ['form.password', '12345'],
            ['form.password_ctl', '12345'],
            ['form.actions.register', 'Register'],
            ['_authenticator', _authenticator]],
            description="Post /coreloadtests/register")

        self.post(server_url + "/coreloadtests/login_form", params=[
            ['form.submitted', '1'],
            ['js_enabled', '0'],
            ['cookies_enabled', '0'],
            ['login_name', ''],
            ['pwd_empty', '0'],
            ['came_from', 'login_success'],
            ['__ac_name', user_id],
            ['__ac_password', '12345']],
            description="Post /coreloadtests/login_form")

        self.get(server_url + "/coreloadtests/dashboard",
            description="Get /coreloadtests/dashboard")

        self.get(server_url + "/coreloadtests/Members/" + user_id +"/view",
            description="Get /coreloadtests/Members/user/view")

        folder_portal_factory = self._browse(server_url + "/coreloadtests/Members/" + user_id +"/createObject?type_name=Folder",
                                             method='get', 
                                             follow_redirect=False,
                                             description = 'Get folder portal factory')

        folder_edit_url = folder_portal_factory.headers.get('Location')        
        folder_id = folder_edit_url.split('/')[-2]
 
        folder_created = self.post(folder_edit_url, params=[
            ['id', folder_id],
            ['title', 'folder'],
            ['description', ''],
            ['description_text_format', 'text/plain'],
            ['subject_existing_keywords:default:list', ''],
            ['location', ''],
            ['language', ''],
            ['effectiveDate', ''],
            ['effectiveDate_year', '0000'],
            ['effectiveDate_month', '00'],
            ['effectiveDate_day', '00'],
            ['effectiveDate_hour', '12'],
            ['effectiveDate_minute', '00'],
            ['effectiveDate_ampm', 'AM'],
            ['expirationDate', ''],
            ['expirationDate_year', '0000'],
            ['expirationDate_month', '00'],
            ['expirationDate_day', '00'],
            ['expirationDate_hour', '12'],
            ['expirationDate_minute', '00'],
            ['expirationDate_ampm', 'AM'],
            ['creators:lines', 'user'],
            ['contributors:lines', ''],
            ['rights', ''],
            ['rights_text_format', 'text/html'],
            ['allowDiscussion:boolean:default', ''],
            ['excludeFromNav:boolean:default', ''],
            ['nextPreviousEnabled:boolean:default', ''],
            ['fieldsets:list', 'default'],
            ['fieldsets:list', 'categorization'],
            ['fieldsets:list', 'dates'],
            ['fieldsets:list', 'ownership'],
            ['fieldsets:list', 'settings'],
            ['form.submitted', '1'],
            ['add_reference.field:record', ''],
            ['add_reference.type:record', ''],
            ['add_reference.destination:record', ''],
            ['last_referer', 'http://localhost:8080/coreloadtests/Members/' + user_id + '/view'],
            ['form_submit', 'Save']],
            description="Post /coreloadtests/Members/user...280843853/atct_edit")

        new_folder_id = folder_created.url.split('/')[-2]

        document_portal_factory = self._browse(server_url + "/coreloadtests/Members/" + user_id +"/" + new_folder_id + "/createObject?type_name=Document",
                                             method='get', 
                                             follow_redirect=False,
                                             description = 'Get document portal factory')

        document_edit_url = document_portal_factory.headers.get('Location')        
        document_id = document_edit_url.split('/')[-2]
        
        self.post(document_edit_url, params=[
            ['id', document_id],
            ['title', self.lipsum.getSubject(length=5, prefix=None, uniq=False,length_min=None, length_max=None)],
            ['description', self.lipsum.getMessage(length=10)],
            ['description_text_format', 'text/plain'],
            ['text_text_format', 'text/html'],
            ['text_text_format:default', 'text/html'],
            ['text', self.lipsum.getMessage(length=30)],
            ['text_file', Upload("")],
            ['subject_existing_keywords:default:list', ''],
            ['relatedItems:default:list', ''],
            ['location', ''],
            ['language', ''],
            ['effectiveDate', ''],
            ['effectiveDate_year', '0000'],
            ['effectiveDate_month', '00'],
            ['effectiveDate_day', '00'],
            ['effectiveDate_hour', '12'],
            ['effectiveDate_minute', '00'],
            ['effectiveDate_ampm', 'AM'],
            ['expirationDate', ''],
            ['expirationDate_year', '0000'],
            ['expirationDate_month', '00'],
            ['expirationDate_day', '00'],
            ['expirationDate_hour', '12'],
            ['expirationDate_minute', '00'],
            ['expirationDate_ampm', 'AM'],
            ['creators:lines', 'user'],
            ['contributors:lines', ''],
            ['rights', ''],
            ['rights_text_format', 'text/html'],
            ['allowDiscussion:boolean:default', ''],
            ['excludeFromNav:boolean:default', ''],
            ['presentation:boolean:default', ''],
            ['tableContents:boolean:default', ''],
            ['cmfeditions_version_comment', 'Lorem Ipsum'],
            ['fieldsets:list', 'default'],
            ['fieldsets:list', 'categorization'],
            ['fieldsets:list', 'dates'],
            ['fieldsets:list', 'ownership'],
            ['fieldsets:list', 'settings'],
            ['form.submitted', '1'],
            ['add_reference.field:record', ''],
            ['add_reference.type:record', ''],
            ['add_reference.destination:record', ''],
            ['last_referer', 'http://localhost:8080/coreloadtests/Members/' + user_id +'/' + new_folder_id + '/'],
            ['form_submit', 'Save']],
            description="Post /coreloadtests/Members/user...511052309/atct_edit")

        self.get(server_url + "/coreloadtests/logout",
            description="Get /coreloadtests/logout")

        # end of test -----------------------------------------------

    def tearDown(self):
        """Setting up test."""
        self.logd("tearDown.\n")