Skip to content

Commit

Permalink
Update fiware plugin tests to support new IDM validation
Browse files Browse the repository at this point in the history
  • Loading branch information
fdelavega committed May 31, 2019
1 parent b99f684 commit 10a91eb
Showing 1 changed file with 16 additions and 2 deletions.
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 comments on commit 10a91eb

Please sign in to comment.