8000 [WiP] Add a setting for specifying the IDM backend to be used by fdelavega · Pull Request #421 · Wirecloud/wirecloud · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[WiP] Add a setting for specifying the IDM backend to be used #421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def read(fname):
'Django>=1.10,<1.12',
'lxml>=2.3',
'django-appconf>=1.0.1,<2.0',
'django_compressor>=2.0,<3.0',
'django_compressor>=2.0,<2.3',
'rdflib>=3.2.0',
'requests>=2.1.0',
'selenium>=3.4',
Expand Down
7 changes: 6 additions & 1 deletion src/wirecloud/fiware/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
from social_django.utils import BACKENDS, get_backend, load_strategy
FIWARE_SOCIAL_AUTH_BACKEND = get_backend(BACKENDS, 'fiware')(load_strategy())

IDM_SUPPORT_ENABLED = 'wirecloud.fiware' in settings.INSTALLED_APPS and 'social_django' in settings.INSTALLED_APPS
IDM_SUPPORT_ENABLED = 'wirecloud.fiware' in settings.INSTALLED_APPS and 'social_django' in settings.INSTALLED_APPS \
and getattr(settings, 'SOCIAL_AUTH_FIWARE_KEY', None) is not None and getattr(settings, 'SOCIAL_AUTH_FIWARE_SECRET', None) is not None

except:
IDM_SUPPORT_ENABLED = False

Expand Down Expand Up @@ -185,6 +187,9 @@ def get_operator_api_extensions(self, view, features):
return files

def get_proxy_processors(self):
if not IDM_SUPPORT_ENABLED:
return ()

return ('wirecloud.fiware.proxy.IDMTokenProcessor',)

def get_django_template_context_processors(self):
Expand Down
18 changes: 16 additions & 2 deletions src/wirecloud/fiware/tests/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@

import json
import time
from importlib import import_module
from unittest.mock import MagicMock, Mock, patch
from urllib.parse import parse_qsl

from django.conf import settings
from django.contrib.auth.models import AnonymousUser
from django.core.urlresolvers import reverse
from django.test import TestCase
from django.test import TestCase, override_settings

from wirecloud.commons.utils.testcases import WirecloudTestCase
from wirecloud.proxy.views import proxy_request
Expand All @@ -48,7 +49,6 @@ class ProxyTestCase(WirecloudTestCase, TestCase):

@classmethod
def setUpClass(cls):

super(ProxyTestCase, cls).setUpClass()

def echo_headers_response(method, url, *args, **kwargs):
Expand Down Expand Up @@ -81,12 +81,26 @@ def setUp(self):
self.normuser_mock = Mock()
self.normuser_mock.social_auth.get.side_effect = Exception

from wirecloud.proxy.views import get_request_proxy_processors
proc_list = list(get_request_proxy_processors())

mod = import_module('wirecloud.fiware.proxy')
token_proc = getattr(mod, 'IDMTokenProcessor')()
proc_list.append(token_proc)

proxy_processors = MagicMock(
return_value=tuple(proc_list)
)
self.patcher = patch('wirecloud.fiware.proxy.IDM_SUPPORT_ENABLED', new=True)
self.patcher.start()

self.patcher_proc = patch('wirecloud.proxy.views.get_request_proxy_processors', new=proxy_processors)
self.patcher_proc.start()
super(ProxyTestCase, self).setUp()

def tearDown(self):
self.patcher.stop()
self.patcher_proc.stop()
super(ProxyTestCase, self).tearDown()

def read_response(self, response):
Expand Down
0