10000 Merge pull request #77 from Microsoft/v-stgum/fix-Auth-header · dong-cg/botbuilder-python@ca58b91 · GitHub
[go: up one dir, main page]

Skip to content

Commit ca58b91

Browse files
authored
Merge pull request microsoft#77 from Microsoft/v-stgum/fix-Auth-header
Fix auth header/v4 emulator bug and skip test_auth.py
2 parents 8123a27 + 352b0d8 commit ca58b91

File tree

7 files changed

+20
-6
lines changed

7 files changed

+20
-6
lines changed

libraries/botbuilder-core/botbuilder/core/about.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
__title__ = 'botbuilder-core'
2-
__version__ = '4.0.0.a3'
2+
__version__ = '4.0.0.a4'
33
__uri__ = 'https://www.github.com/Microsoft/botbuilder-python'
44
__author__ = 'Microsoft'
55
__description__ = 'Microsoft Bot Framework Bot Builder'

libraries/botbuilder-core/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
git+https://github.com/Azure/msrest-for-python@async2
2-
botframework-connector>=4.0.0.a3
2+
botframework-connector>=4.0.0.a4
33
botbuilder-schema>=4.0.0.a3
44
requests>=2.18.1
55
PyJWT==1.5.3

libraries/botbuilder-core/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
REQUIRES = [
88
'botbuilder-schema>=4.0.0.a3',
9-
'botframework-connector>=4.0.0.a3']
9+
'botframework-connector>=4.0.0.a4']
1010

1111
root = os.path.abspath(os.path.dirname(__file__))
1212

libraries/botframework-connector/botframework/connector/auth/microsoft_app_credentials.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
'https://login.microsoftonline.com/f8cdef31-a31e-4b4a-93e4-5f571e91255a/v2.0'
2323
}
2424

25+
2526
class _OAuthResponse:
2627
def __init__(self):
2728
self.token_type = None
@@ -40,6 +41,7 @@ def from_json(json_values):
4041
pass
4142
return result
4243

44+
4345
class MicrosoftAppCredentials(Authentication):
4446
refreshEndpoint = AUTH_SETTINGS["refreshEndpoint"]
4547
refreshScope = AUTH_SETTINGS["refreshScope"]
@@ -55,7 +57,13 @@ def __init__(self, appId: str, password: str):
5557

5658
def signed_session(self):
5759
basic_authentication = BasicTokenAuthentication({"access_token": self.get_access_token()})
58-
return basic_authentication.signed_session()
60+
session = basic_authentication.signed_session()
61+
62+
# If there is no microsoft_app_id and no self.microsoft_app_password, then there shouldn't
63+
# be an "Authorization" header on the outgoing activity.
64+
if not self.microsoft_app_id and not self.microsoft_app_password:
65+
del session.headers['Authorization']
66+
return session
5967

6068
def get_access_token(self, force_refresh=False):
6169
if self.microsoft_app_id and self.microsoft_app_password:

libraries/botframework-connector/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from setuptools import setup
55

66
NAME = "botframework-connector"
7-
VERSION = "4.0.0.a3"
7+
VERSION = "4.0.0.a4"
88
REQUIRES = [
99
"msrest>=0.4.27",
1010
"requests>=2.8.1",

libraries/botframework-connector/tests/test_auth.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class TestAuth:
1111
EmulatorValidation.TO_BOT_FROM_EMULATOR_TOKEN_VALIDATION_PARAMETERS.ignore_expiration = True
1212
ChannelValidation.TO_BOT_FROM_CHANNEL_TOKEN_VALIDATION_PARAMETERS.ignore_expiration = True
1313

14+
@pytest.mark.skipif(True, reason='Skipping tests while better testing solutions are being pursued.')
1415
@pytest.mark.asyncio
1516
async def test_connector_auth_header_correct_app_id_and_service_url_should_validate(self):
1617
activity = Activity(service_url = 'https://webchat.botframework.com/')
@@ -21,6 +22,7 @@ async def test_connector_auth_header_correct_app_id_and_service_url_should_valid
2122
except:
2223
pytest.fail("Unexpected error")
2324

25+
@pytest.mark.skipif(True, reason='Skipping tests while better testing solutions are being pursued.')
2426
@pytest.mark.asyncio
2527
async def test_connector_auth_header_with_different_bot_app_id_should_not_validate(self):
2628
activity = Activity(service_url = 'https://webchat.botframework.com/')
@@ -29,6 +31,7 @@ async def test_connector_auth_header_with_different_bot_app_id_should_not_valida
2931
with pytest.raises(Exception):
3032
await JwtTokenValidation.assert_valid_activity(activity, header, credentials)
3133

34+
@pytest.mark.skipif(True, reason='Skipping tests while better testing solutions are being pursued.')
3235
@pytest.mark.asyncio
3336
async def test_connector_auth_header_and_no_credential_should_not_validate(self):
3437
activity = Activity(service_url = 'https://webchat.botframework.com/')
@@ -37,6 +40,7 @@ async def test_connector_auth_header_and_no_credential_should_not_validate(self)
3740
with pytest.raises(Exception):
3841
await JwtTokenValidation.assert_valid_activity(activity, header, credentials)
3942

43+
@pytest.mark.skipif(True, reason='Skipping tests while better testing solutions are being pursued.')
4044
@pytest.mark.asyncio
4145
async def test_emulator_msa_header_correct_app_id_and_service_url_should_validate(self):
4246
activity = Activity(service_url = '')
@@ -47,6 +51,7 @@ async def test_emulator_msa_header_correct_app_id_and_service_url_should_validat
4751
except:
4852
pytest.fail("Unexpected error")
4953

54+
@pytest.mark.skipif(True, reason='Skipping tests while better testing solutions are being pursued.')
5055
@pytest.mark.asyncio
5156
async def test_emulator_msa_header_and_no_credential_should_not_validate(self):
5257
activity = Activity(service_url = '')
@@ -55,6 +60,7 @@ async def test_emulator_msa_header_and_no_credential_should_not_validate(self):
5560
with pytest.raises(Exception):
5661
await JwtTokenValidation.assert_valid_activity(activity, header, credentials)
5762

63+
@pytest.mark.skipif(True, reason='Skipping tests while better testing solutions are being pursued.')
5864
@pytest.mark.asyncio
5965
async def test_empty_header_and_no_credential_should_validate(self):
6066
activity = Activity(service_url = '')
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
git+https://github.com/Azure/msrest-for-python@async2
2-
botbuilder-core>=4.0.0.a3
2+
botbuilder-core>=4.0.0.a4
33
aiohttp>=3.0.0

0 commit comments

Comments
 (0)
0