Ignore:
Timestamp:
12 May 2015, 15:19:10 (10 years ago)
Author:
Henrik Bettermann
Message:

Enable temporary suspension of officer accounts. Plugins must be updated after restart.

File:
1 edited

Legend:

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

    r12841 r12926  
    3030from waeup.kofa.testing import FunctionalLayer, FunctionalTestCase
    3131from waeup.kofa.app import University
    32 from waeup.kofa.interfaces import IJobManager
     32from waeup.kofa.interfaces import IJobManager, IUserAccount
    3333from waeup.kofa.tests.test_async import FunctionalAsyncTestCase
    3434from waeup.kofa.university.faculty import Faculty
     
    445445            'faculties']['fac1']['dep1'].certificates['CERT1'])
    446446        return
     447
     448    def test_suspended_officer(self):
     449        self.app['users'].addUser(
     450            'officer', 'secret', title='Bob Officer', email='aa@aa.ng')
     451        # Officer can't login if their password is not set
     452        self.app['users']['officer'].password = None
     453        self.browser.open('http://localhost/app/login')
     454        self.browser.getControl(name="form.login").value = 'officer'
     455        self.browser.getControl(name="form.password").value = 'secret'
     456        self.browser.getControl("Login").click()
     457        self.assertTrue(
     458            'You entered invalid credentials.' in self.browser.contents)
     459        # We set the password again
     460        IUserAccount(
     461            self.app['users']['officer']).setPassword('secret')
     462        # Officers can't login if their account is suspended/deactivated
     463        self.app['users']['officer'].suspended = True
     464        self.browser.open('http://localhost/app/login')
     465        self.browser.getControl(name="form.login").value = 'officer'
     466        self.browser.getControl(name="form.password").value = 'secret'
     467        self.browser.getControl("Login").click()
     468        self.assertMatches(
     469            '...but yor account has been temporarily deactivated...',
     470            self.browser.contents)
     471        self.assertFalse("Bob Officer" in self.browser.contents)
     472        self.app['users']['officer'].suspended = False
     473        self.browser.open('http://localhost/app/login')
     474        self.browser.getControl(name="form.login").value = 'officer'
     475        self.browser.getControl(name="form.password").value = 'secret'
     476        self.browser.getControl("Login").click()
     477        self.assertMatches(
     478            '...You logged in...', self.browser.contents)
     479        self.assertTrue("Bob Officer" in self.browser.contents)
     480        self.browser.getLink("Logout").click()
     481        # Suspended accounts are marked
     482        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     483        self.browser.open('http://localhost/app/users')
     484        self.assertFalse('(suspended)' in self.browser.contents)
     485        self.app['users']['officer'].suspended = True
     486        self.browser.open('http://localhost/app/users')
     487        self.assertTrue(
     488            '<span style="color:red">(suspended)</span>'
     489            in self.browser.contents)
     490        self.browser.open('http://localhost/app/users/officer')
     491        self.assertTrue(
     492            'This account has been suspended.' in self.browser.contents)
     493        self.app['users']['officer'].suspended = False
     494        self.browser.open('http://localhost/app/users/officer')
     495        self.assertFalse(
     496            'This account has been suspended.' in self.browser.contents)
     497        return
Note: See TracChangeset for help on using the changeset viewer.