Exemple #1
0
    def test_automation_cleanup(self):
        # make sure a lock uuid is created
        manager = self._start_manager()
        manager.stop_service()
        manager.wait_service()

        # insert a new work request
        remediation = request_email_remediation('<message_id>', '<recipient@localhost>',
                                                saq.test.UNITTEST_USER_ID, saq.COMPANY_ID)

        # pretend it started processing
        saq.db.execute(Remediation.__table__.update().values(
            lock=manager.systems['email'].lock,
            lock_time=func.now(),
            status=REMEDIATION_STATUS_IN_PROGRESS).where(and_(
            Remediation.company_id == saq.COMPANY_ID,
            Remediation.lock == None,
            Remediation.status == REMEDIATION_STATUS_NEW)))
        saq.db.commit()

        # start up the system again
        manager = self._start_manager()

        # and it should process that job
        wait_for(
            lambda: len(saq.db.query(Remediation).filter(
                Remediation.id == remediation.id,
                Remediation.status == REMEDIATION_STATUS_COMPLETED).all()) > 0,
            1, 5)

        manager.stop_service()
        manager.wait_service()
Exemple #2
0
    def test_remediation_request(self):
        remediation = request_email_remediation('<message_id>', '<recipient@localhost>',
                                                saq.test.UNITTEST_USER_ID, saq.COMPANY_ID)
        self.assertTrue(isinstance(remediation, Remediation))
        remediation = saq.db.query(Remediation).filter(Remediation.id == remediation.id).one()
        self.assertIsNotNone(remediation)
        self.assertEquals(remediation.type, REMEDIATION_TYPE_EMAIL)
        self.assertEquals(remediation.action, REMEDIATION_ACTION_REMOVE)
        self.assertIsNotNone(remediation.insert_date)
        self.assertEquals(remediation.user_id, saq.test.UNITTEST_USER_ID)
        self.assertEquals(remediation.key, create_email_remediation_key('<message_id>', '<recipient@localhost>'))
        self.assertIsNone(remediation.result)
        self.assertIsNone(remediation.comment)
        self.assertIsNone(remediation.successful)
        self.assertEquals(remediation.company_id, saq.COMPANY_ID)
        self.assertIsNone(remediation.lock)
        self.assertIsNone(remediation.lock_time)
        self.assertEquals(remediation.status, REMEDIATION_STATUS_NEW)

        remediation = request_email_restoration('<message_id>', '<recipient@localhost>',
                                                saq.test.UNITTEST_USER_ID, saq.COMPANY_ID)
        self.assertTrue(isinstance(remediation, Remediation))
        remediation = saq.db.query(Remediation).filter(Remediation.id == remediation.id).one()
        self.assertIsNotNone(remediation)
        self.assertEquals(remediation.action, REMEDIATION_ACTION_RESTORE)
Exemple #3
0
    def test_automation_queue(self):
        manager = self._start_manager()
        remediation = request_email_remediation('<message_id>', '<recipient@localhost>',
                                                saq.test.UNITTEST_USER_ID, saq.COMPANY_ID)
        wait_for(
            lambda: len(saq.db.query(Remediation).filter(
                Remediation.id == remediation.id,
                Remediation.status == REMEDIATION_STATUS_COMPLETED).all()) > 0,
            1, 5)

        manager.stop_service()
        manager.wait_service()