def test_refresh_certificate_myproxyclient(self, mock_discover):
        self.user.auth.type = 'myproxyclient'

        self.user.auth.cert = 'some cert'

        with self.assertRaises(tasks.CertificateError):
            cert = tasks.refresh_certificate(self.user)
    def test_refresh_certificate_missing_token(self, mock_discover):
        mock_services = mock.MagicMock()

        mock_discover.return_value = ('url', mock_services)

        self.user.auth.extra = '{}'

        self.user.auth.cert = 'some cert'

        with self.assertRaises(tasks.WPSError):
            cert = tasks.refresh_certificate(self.user)
    def test_refresh_certificate_error_loading_extra(self, mock_discover):
        mock_services = mock.MagicMock()

        mock_discover.return_value = ('url', mock_services)

        self.user.auth.extra = 'some invalid content'

        self.user.auth.cert = 'some cert'

        with self.assertRaises(tasks.WPSError):
            cert = tasks.refresh_certificate(self.user)
示例#4
0
    def test_refresh_certificate(self, mock_discover, mock_find, mock_get):
        mock_get.return_value = ('cert value', 'key value', 'new token value')

        mock_services = mock.MagicMock()

        mock_discover.return_value = ('url', mock_services)

        self.user.auth.extra = '{"token": "token value"}'

        self.user.auth.cert = 'some cert'

        cert = tasks.refresh_certificate(self.user)

        self.assertEqual(cert, 'cert valuekey value')
        self.assertEqual(self.user.auth.cert, 'cert valuekey value')
        self.assertEqual(self.user.auth.extra, '{"token": "new token value"}')