Ignore:
Timestamp:
18 Jan 2018, 07:34:42 (7 years ago)
Author:
Henrik Bettermann
Message:

Do not allow uploading data with trailing whitespaces.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/tests/test_browser.py

    r14511 r14939  
    4040SAMPLE_FILE = os.path.join(os.path.dirname(__file__), 'test_file.csv')
    4141FORBIDDEN_FILE = os.path.join(os.path.dirname(__file__), 'forbidden_file.csv')
     42FORBIDDEN_FILE_2 = os.path.join(
     43    os.path.dirname(__file__), 'forbidden_file_2.csv')
    4244
    4345class UniversitySetup(FunctionalTestCase):
     
    193195        self.assertTrue(
    194196            'Your file contains forbidden characters or'
     197            in self.browser.contents)
     198        logfile = os.path.join(
     199            self.app['datacenter'].storage, 'logs', 'datacenter.log')
     200        logcontent = open(logfile).read()
     201        self.assertTrue('zope.mgr - browser.pages.DatacenterUploadPage - '
     202            'invalid file uploaded:' in logcontent)
     203        return
     204
     205    def test_forbidden_file_upload_2(self):
     206        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     207        self.browser.open(self.datacenter_path)
     208        self.assertEqual(self.browser.headers['Status'], '200 Ok')
     209        self.assertEqual(self.browser.url, self.datacenter_path)
     210        self.browser.getLink("Upload data").click()
     211        file = open(FORBIDDEN_FILE_2)
     212        ctrl = self.browser.getControl(name='uploadfile:file')
     213        file_ctrl = ctrl.mech_control
     214        file_ctrl.add_file(file, filename='my_corrupted_file.csv')
     215        self.browser.getControl('Upload').click()
     216        self.assertTrue(
     217            'The data in your file contain trailing whitespaces.'
    195218            in self.browser.contents)
    196219        logfile = os.path.join(
Note: See TracChangeset for help on using the changeset viewer.