示例#1
0
    async def test_channel_authentication_disabled_service_url_should_not_be_trusted(self):
        activity = Activity(service_url = 'https://webchat.botframework.com/')
        header = ''
        credentials = SimpleCredentialProvider('', '')

        await JwtTokenValidation.authenticate_request(activity, header, credentials)

        assert not MicrosoftAppCredentials.is_trusted_service('https://webchat.botframework.com/')
示例#2
0
    async def test_channel_msa_header_Valid_service_url_should_be_trusted(self):
        activity = Activity(service_url = 'https://smba.trafficmanager.net/amer-client-ss.msg/')
        header = 'Bearer ' + MicrosoftAppCredentials('2cd87869-38a0-4182-9251-d056e8f0ac24', '2.30Vs3VQLKt974F').get_access_token()
        credentials = SimpleCredentialProvider('2cd87869-38a0-4182-9251-d056e8f0ac24', '')

        await JwtTokenValidation.authenticate_request(activity, header, credentials)

        assert MicrosoftAppCredentials.is_trusted_service('https://smba.trafficmanager.net/amer-client-ss.msg/')
示例#3
0
    async def test_channel_msa_header_invalid_service_url_should_not_be_trusted(self):
        activity = Activity(service_url = 'https://webchat.botframework.com/')
        header = 'Bearer ' + MicrosoftAppCredentials('2cd87869-38a0-4182-9251-d056e8f0ac24', '2.30Vs3VQLKt974F').get_access_token()
        credentials = SimpleCredentialProvider('7f74513e-6f96-4dbc-be9d-9a81fea22b88', '')

        with pytest.raises(Exception) as excinfo:
            await JwtTokenValidation.authenticate_request(activity, header, credentials)
        assert 'Unauthorized' in str(excinfo.value)
        
        assert not MicrosoftAppCredentials.is_trusted_service('https://webchat.botframework.com/')