Capture invalid response from the jira server
parent
1c569edd96
commit
e3b390087a
|
@ -22,5 +22,8 @@ class InvalidRequest(Exception):
|
|||
class InvalidAuthResult(Exception):
|
||||
pass
|
||||
|
||||
class InvalidServiceConfiguration(Exception):
|
||||
pass
|
||||
|
||||
class FailedRequest(Exception):
|
||||
pass
|
||||
|
|
|
@ -25,6 +25,7 @@ from taiga.users.services import get_user_photo_url
|
|||
from taiga.users.gravatar import get_user_gravatar_id
|
||||
|
||||
from taiga.importers import permissions
|
||||
from taiga.importers import exceptions
|
||||
from taiga.importers.services import resolve_users_bindings
|
||||
from .normal import JiraNormalImporter
|
||||
from .agile import JiraAgileImporter
|
||||
|
@ -178,12 +179,15 @@ class JiraImporterViewSet(viewsets.ViewSet):
|
|||
if not jira_url:
|
||||
raise exc.WrongArguments(_("The url param is needed"))
|
||||
|
||||
try:
|
||||
(oauth_token, oauth_secret, url) = JiraNormalImporter.get_auth_url(
|
||||
jira_url,
|
||||
settings.IMPORTERS.get('jira', {}).get('consumer_key', None),
|
||||
settings.IMPORTERS.get('jira', {}).get('cert', None),
|
||||
True
|
||||
)
|
||||
except exceptions.InvalidServiceConfiguration:
|
||||
raise exc.BadRequest(_("Invalid Jira server configuration."))
|
||||
|
||||
(auth_data, created) = AuthData.objects.get_or_create(
|
||||
user=request.user,
|
||||
|
|
|
@ -45,6 +45,7 @@ from taiga.projects.custom_attributes.models import (UserStoryCustomAttribute,
|
|||
from taiga.projects.history.models import HistoryEntry
|
||||
from taiga.projects.history.choices import HistoryType
|
||||
from taiga.mdrender.service import render as mdrender
|
||||
from taiga.importers import exceptions
|
||||
|
||||
EPIC_COLORS = {
|
||||
"ghx-label-0": "#ffffff",
|
||||
|
@ -737,6 +738,8 @@ class JiraImporterCommon:
|
|||
oauth = OAuth1(consumer_key, signature_method=SIGNATURE_RSA, rsa_key=key_cert_data)
|
||||
r = requests.post(
|
||||
server + '/plugins/servlet/oauth/request-token', verify=verify, auth=oauth)
|
||||
if r.status_code != 200:
|
||||
raise exceptions.InvalidServiceConfiguration()
|
||||
request = dict(parse_qsl(r.text))
|
||||
request_token = request['oauth_token']
|
||||
request_token_secret = request['oauth_token_secret']
|
||||
|
|
Loading…
Reference in New Issue