示例#1
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
    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
示例#3
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()
示例#4
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")
示例#5
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()
示例#6
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()
示例#7
0
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()
示例#8
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 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")