Skip to content

Commit

Permalink
emdpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
rakshith91 committed Jul 16, 2021
1 parent cb12665 commit e7f9405
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions sdk/eventgrid/azure-eventgrid/tests/eventgrid_preparer.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ class EventGridTest(AzureMgmtTestCase):
def __init__(self, method_name):
super(EventGridTest, self).__init__(method_name)

def get_oauth_endpoint(self):
return os.getenv("EG_TOPIC_HOSTNAME")

def generate_oauth_token(self):
if self.is_live:
from azure.identity import ClientSecretCredential
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,12 @@ def test_send_throws_with_bad_credential(self):
with pytest.raises(ValueError, match="The provided credential should be an instance of a TokenCredential, AzureSasCredential or AzureKeyCredential"):
client = EventGridPublisherClient("eventgrid_endpoint", bad_credential)

@pytest.mark.live_test_only
@CachedResourceGroupPreparer(name_prefix='eventgridtest')
@CachedEventGridTopicPreparer(name_prefix='eventgridtest')
def test_send_token_credential(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint):
credential = self.generate_oauth_token()
client = EventGridPublisherClient(eventgrid_topic_endpoint, credential)
client = EventGridPublisherClient(self.get_oauth_endpoint(), credential)
eg_event = EventGridEvent(
subject="sample",
data={"sample": "eventgridevent"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,12 +332,13 @@ def test_send_NONE_credential_async(self, resource_group, eventgrid_topic, event
with pytest.raises(ValueError, match="Parameter 'self._credential' must not be None."):
client = EventGridPublisherClient(eventgrid_topic_endpoint, None)

@pytest.mark.live_test_only
@CachedResourceGroupPreparer(name_prefix='eventgridtest')
@CachedEventGridTopicPreparer(name_prefix='eventgridtest')
@pytest.mark.asyncio
async def test_send_token_credential(self, resource_group, eventgrid_topic, eventgrid_topic_primary_key, eventgrid_topic_endpoint):
credential = self.generate_oauth_token()
client = EventGridPublisherClient(eventgrid_topic_endpoint, credential)
client = EventGridPublisherClient(self.get_oauth_endpoint(), credential)
eg_event = EventGridEvent(
subject="sample",
data={"sample": "eventgridevent"},
Expand Down

0 comments on commit e7f9405

Please sign in to comment.