Esempio n. 1
0
    def testRepeatedFailedLogin(self):
        from auditcare.decorators import login
        login.FAILURE_LIMIT = 3
        login.LOCK_OUT_AT_FAILURE=True
        login.COOLOFF_TIME = timedelta(seconds=4)

        start_count = AccessAudit.view('auditcare/login_events', key=['user', '*****@*****.**']).count()
        response = self.client.post(reverse('auth_login'), {'username': '******', 'password': '******'})

        firstlogin_count = AccessAudit.view('auditcare/login_events', key=['user', '*****@*****.**']).count()
        self.assertEquals(start_count+1, firstlogin_count)


        first_audit = get_latest_access(['user', '*****@*****.**'])
        self.assertEquals(first_audit.access_type, models.ACCESS_FAILED)
        self.assertEquals(first_audit.failures_since_start, 1)
        start_failures = first_audit.failures_since_start

        for n in range(1,3):
            #we are logging in within the cooloff period, so let's check to see if it doesn't increment.
            response = self.client.post(reverse('auth_login'), {'username': '******', 'password': '******'})
            next_count = AccessAudit.view('auditcare/login_events', key=['user', '*****@*****.**']).count()
            self.assertEquals(firstlogin_count, next_count)

            next_audit = get_latest_access(['user', '*****@*****.**'])
            self.assertEquals(next_audit.access_type, models.ACCESS_FAILED)
            self.assertEquals(next_audit.failures_since_start, n+start_failures)
            time.sleep(1)
        time.sleep(3)
        response = self.client.post(reverse('auth_login'), {'username': '******', 'password': '******'})
        cooled_audit = get_latest_access(['user', '*****@*****.**'])
        self.assertEquals(cooled_audit.failures_since_start,1)
Esempio n. 2
0
    def testRepeatedFailedLogin(self):
        from auditcare.decorators import login
        login.FAILURE_LIMIT = 3
        login.LOCK_OUT_AT_FAILURE=True
        login.COOLOFF_TIME = timedelta(seconds=4)

        start_count = AccessAudit.view('auditcare/login_events', key=['user', '*****@*****.**']).count()
        response = self.client.post(reverse('auth_login'), {'username': '******', 'password': '******'})

        firstlogin_count = AccessAudit.view('auditcare/login_events', key=['user', '*****@*****.**']).count()
        self.assertEquals(start_count+1, firstlogin_count)


        first_audit = get_latest_access(['user', '*****@*****.**'])
        self.assertEquals(first_audit.access_type, models.ACCESS_FAILED)
        self.assertEquals(first_audit.failures_since_start, 1)
        start_failures = first_audit.failures_since_start

        for n in range(1, 3):
            #we are logging in within the cooloff period, so let's check to see if it doesn't increment.
            response = self.client.post(reverse('auth_login'), {'username': '******', 'password': '******'})
            next_count = AccessAudit.view('auditcare/login_events', key=['user', '*****@*****.**']).count()
            self.assertEquals(firstlogin_count, next_count)

            next_audit = get_latest_access(['user', '*****@*****.**'])
            self.assertEquals(next_audit.access_type, models.ACCESS_FAILED)
            self.assertEquals(next_audit.failures_since_start, n+start_failures)
            time.sleep(1)
        time.sleep(3)
        response = self.client.post(reverse('auth_login'), {'username': '******', 'password': '******'})
        cooled_audit = get_latest_access(['user', '*****@*****.**'])
        self.assertEquals(cooled_audit.failures_since_start, 1)
Esempio n. 3
0
    def testLogin(self):

        #login
        start_count = AccessAudit.view('auditcare/login_events', key=['user', '*****@*****.**']).count()
        response = self.client.post(reverse('auth_login'), {'username': '******', 'password': '******'})
        login_count = AccessAudit.view('auditcare/login_events', key=['user', '*****@*****.**']).count()
        self.assertEqual(start_count+1, login_count)

        latest_audit = get_latest_access(['user', '*****@*****.**'])
        self.assertEquals(latest_audit.access_type, models.ACCESS_LOGIN)
Esempio n. 4
0
    def testLogin(self):

        #login
        start_count = AccessAudit.view('auditcare/login_events', key=['user', '*****@*****.**']).count()
        response = self.client.post(reverse('auth_login'), {'username': '******', 'password': '******'})
        login_count = AccessAudit.view('auditcare/login_events', key=['user', '*****@*****.**']).count()
        self.assertEqual(start_count+1, login_count)

        latest_audit = get_latest_access(['user', '*****@*****.**'])
        self.assertEquals(latest_audit.access_type, models.ACCESS_LOGIN)
Esempio n. 5
0
    def testSingleFailedLogin(self):
        start_count = AccessAudit.view('auditcare/login_events', key=['user', '*****@*****.**']).count()
        response = self.client.post(reverse('auth_login'), {'username': '******', 'password': '******'})

        login_count = AccessAudit.view('auditcare/login_events', key=['user', '*****@*****.**']).count()
        self.assertEquals(start_count+1, login_count)
        #got the basic count, now let's inspect this value to see what kind of result it is.

        latest_audit = get_latest_access(['user', '*****@*****.**'])
        self.assertEquals(latest_audit.access_type, models.ACCESS_FAILED)
        self.assertEquals(latest_audit.failures_since_start, 1)
Esempio n. 6
0
    def testSingleFailedLogin(self):
        start_count = AccessAudit.view('auditcare/login_events', key=['user', '*****@*****.**']).count()
        response = self.client.post(reverse('auth_login'), {'username': '******', 'password': '******'})

        login_count = AccessAudit.view('auditcare/login_events', key=['user', '*****@*****.**']).count()
        self.assertEquals(start_count+1, login_count)
        #got the basic count, now let's inspect this value to see what kind of result it is.

        latest_audit = get_latest_access(['user', '*****@*****.**'])
        self.assertEquals(latest_audit.access_type, models.ACCESS_FAILED)
        self.assertEquals(latest_audit.failures_since_start, 1)