Skip to content

Commit

Permalink
Workaround Authentication for now
Browse files Browse the repository at this point in the history
  • Loading branch information
lmazuel committed Oct 19, 2017
1 parent 6e5b1fc commit e64dd3a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# --------------------------------------------------------------------------

from azure.cognitiveservices.language.textanalytics import TextAnalyticsAPI
from msrest.authentication import CognitiveServicesAuthentication
#from msrest.authentication import CognitiveServicesAuthentication

from azure_devtools.scenario_tests import ReplayableTest, AzureTestError

Expand Down
29 changes: 28 additions & 1 deletion azure-cognitiveservices-search/tests/test_entity_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,34 @@
# --------------------------------------------------------------------------

from azure.cognitiveservices.search.entitysearch import EntitySearchAPI
from msrest.authentication import CognitiveServicesAuthentication
#from msrest.authentication import CognitiveServicesAuthentication
# Workaround to get CI to work
from msrest.authentication import Authentication
class CognitiveServicesAuthentication(Authentication):
"""Cognitive Services authentication.
:param str subscription_key: The CS subscription key
"""

_subscription_key_header = 'Ocp-Apim-Subscription-Key'

def __init__(self, subscription_key):
if not subscription_key:
raise ValueError("Subscription key cannot be None")
self.subscription_key = subscription_key

def signed_session(self):
"""Create requests session with any required auth headers
applied.
:rtype: requests.Session.
"""

session = super(CognitiveServicesAuthentication, self).signed_session()
session.headers.update({
self._subscription_key_header: self.subscription_key,
'X-BingApis-SDK-Client': 'Python-SDK'
})
return session
# end of workaround

from azure_devtools.scenario_tests import ReplayableTest, AzureTestError

Expand Down
2 changes: 1 addition & 1 deletion azure-cognitiveservices-vision/tests/test_face.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from os.path import dirname, join, realpath

from azure.cognitiveservices.vision.face import FaceAPI
from msrest.authentication import CognitiveServicesAuthentication
#from msrest.authentication import CognitiveServicesAuthentication

from azure_devtools.scenario_tests import ReplayableTest, AzureTestError

Expand Down

0 comments on commit e64dd3a

Please sign in to comment.