Пример #1
0
    def test_create_audit_entry(self):

        finish_tokens = FinishTokens(valid_tokens=[],
                                     challenge_tokens=[],
                                     pin_matching_tokens=[],
                                     invalid_tokens=[],
                                     validation_results={},
                                     user=None,
                                     options=None,
                                     audit_entry={})

        audit_entry = mocked_context['audit']

        # 1.a Test  - no previous 'action detail'

        msg = "no token found!"
        finish_tokens.create_audit_entry(action_detail=audit_entry.get(
            'action_detail', msg),
                                         tokens=[])

        self.assertTrue('action_detail' in mocked_context['audit'])
        self.assertTrue(msg in mocked_context['audit']['action_detail'])

        # 1.b Test  - previous 'action detail' is default

        msg = "Failcounter exceeded!"
        finish_tokens.create_audit_entry(action_detail=msg, tokens=[])

        self.assertTrue('action_detail' in mocked_context['audit'])
        self.assertTrue(msg in mocked_context['audit']['action_detail'])

        # 2. Test  - previous 'action detail' is default

        audit_entry['action_detail'] = "no token found!"
        msg = "no sun, no fun"
        finish_tokens.create_audit_entry(msg, tokens=[])

        self.assertTrue('action_detail' in mocked_context['audit'])
        self.assertTrue(msg in mocked_context['audit']['action_detail'])

        # 3. Test  - previous 'action detail' is default

        audit_entry['action_detail'] = "no sun, no fun"
        finish_tokens.create_audit_entry(audit_entry['action_detail'],
                                         tokens=[])

        self.assertTrue('action_detail' in mocked_context['audit'])
        self.assertTrue(
            "no sun, no fun" in mocked_context['audit']['action_detail'])

        # 4. Test  - no parameter, falling back to 'no token found!'

        audit_entry['action_detail'] = "no sun, no fun"
        msg = "no token found!"
        finish_tokens.create_audit_entry(tokens=[])

        self.assertTrue('action_detail' in mocked_context['audit'])
        self.assertTrue(msg in mocked_context['audit']['action_detail'])

        return
Пример #2
0
    def test_create_audit_entry(self):
        g.audit = {}

        finish_tokens = FinishTokens(
            valid_tokens=[],
            challenge_tokens=[],
            pin_matching_tokens=[],
            invalid_tokens=[],
            validation_results={},
            user=None,
            options=None,
            audit_entry={},
        )

        audit_entry = {}

        # 1.a Test  - no previous 'action detail'

        msg = "no token found!"
        finish_tokens.create_audit_entry(action_detail=audit_entry.get(
            "action_detail", msg),
                                         tokens=[])

        assert "action_detail" in g.audit
        assert msg in g.audit["action_detail"]

        # 1.b Test  - previous 'action detail' is default

        msg = "Failcounter exceeded!"
        finish_tokens.create_audit_entry(action_detail=msg, tokens=[])

        assert "action_detail" in g.audit
        assert msg in g.audit["action_detail"]

        # 2. Test  - previous 'action detail' is default

        audit_entry["action_detail"] = "no token found!"
        msg = "no sun, no fun"
        finish_tokens.create_audit_entry(msg, tokens=[])

        assert "action_detail" in g.audit
        assert msg in g.audit["action_detail"]

        # 3. Test  - previous 'action detail' is default

        audit_entry["action_detail"] = "no sun, no fun"
        finish_tokens.create_audit_entry(audit_entry["action_detail"],
                                         tokens=[])

        assert "action_detail" in g.audit
        assert "no sun, no fun" in g.audit["action_detail"]

        # 4. Test  - no parameter, falling back to 'no token found!'

        audit_entry["action_detail"] = "no sun, no fun"
        msg = "no token found!"
        finish_tokens.create_audit_entry(tokens=[])

        assert "action_detail" in g.audit
        assert msg in g.audit["action_detail"]

        return
Пример #3
0
    def test_create_audit_entry(self):

        finish_tokens = FinishTokens(
                              valid_tokens=[],
                              challenge_tokens=[],
                              pin_matching_tokens=[],
                              invalid_tokens=[],
                              validation_results={},
                              user=None, options=None,
                              audit_entry={})

        audit_entry = mocked_context['audit']

        # 1.a Test  - no previous 'action detail'

        msg = "no token found!"
        finish_tokens.create_audit_entry(
            action_detail=audit_entry.get('action_detail', msg),
            tokens=[])

        self.assertTrue('action_detail' in mocked_context['audit'])
        self.assertTrue(msg in mocked_context['audit']['action_detail'])

        # 1.b Test  - previous 'action detail' is default

        msg = "Failcounter exceeded!"
        finish_tokens.create_audit_entry(action_detail=msg, tokens=[])

        self.assertTrue('action_detail' in mocked_context['audit'])
        self.assertTrue(msg in mocked_context['audit']['action_detail'])

        # 2. Test  - previous 'action detail' is default

        audit_entry['action_detail'] = "no token found!"
        msg = "no sun, no fun"
        finish_tokens.create_audit_entry(msg, tokens=[])

        self.assertTrue('action_detail' in mocked_context['audit'])
        self.assertTrue(msg in mocked_context['audit']['action_detail'])

        # 3. Test  - previous 'action detail' is default

        audit_entry['action_detail'] = "no sun, no fun"
        finish_tokens.create_audit_entry(audit_entry['action_detail'],
                                         tokens=[])

        self.assertTrue('action_detail' in mocked_context['audit'])
        self.assertTrue("no sun, no fun" in
                        mocked_context['audit']['action_detail'])

        # 4. Test  - no parameter, falling back to 'no token found!'

        audit_entry['action_detail'] = "no sun, no fun"
        msg = "no token found!"
        finish_tokens.create_audit_entry(tokens=[])

        self.assertTrue('action_detail' in mocked_context['audit'])
        self.assertTrue(msg in
                        mocked_context['audit']['action_detail'])

        return