Beispiel #1
0
 def test_make_session_with_access(self):
     pmr_info = PMR()
     tool = PMRTool(pmr_info)
     info = PMR()
     info.update_token('test', 'token')
     session = tool.make_session()
     self.assertTrue(isinstance(session, OAuth1Session))
     info.update_token('', '')
Beispiel #2
0
    def test_requestTemporaryPassword(self):
        # Available with access
        info = PMR()
        info.update_token('test', 'token')

        result = self._tool.requestTemporaryPassword('http://example.com/w/1')
        self.assertEqual(result['user'], 'tester')
        self.assertEqual(result['key'], 'secret')

        info.update_token('', '')
        result = self._tool.requestTemporaryPassword('http://example.com/w/1')
        self.assertTrue(result is None)
Beispiel #3
0
    def test_hasAccess(self):
        # update tokens using another instance
        info = PMR()
        t = PMRTool(info)

        # Fresh token should have no access
        self.assertFalse(t.hasAccess())

        info.update_token('test', 'token')
        # Now it's true
        self.assertTrue(t.hasAccess())

        # revoke access again.
        info.update_token('', '')
        # Now it's false again.
        self.assertFalse(t.hasAccess())
    def _register(self):
        pmr_info = PMR()

        verifier = self._ui.tokenLineEdit.text()
        self._helper.set_verifier(verifier)

        try:
            token_credentials = self._helper.get_token_credentials()
        except ValueError:
            logger.info('Invalid Verifier: Failed to retrieve token access with verification code.')
            QtWidgets.QMessageBox.information(self, 'Invalid Verifier',
                'Failed to retrieve token access with verification code.')
            return False

        logger.debug('token: %r', token_credentials)

        pmr_info.update_token(**token_credentials)

        return True