Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import base64
import inspect
from pickle import TRUE
from typing import Any, Optional, Union
from urllib.parse import urlparse

Expand Down Expand Up @@ -85,7 +84,7 @@ async def get_authorization_token(
span.record_exception(exc)
raise exc

span.set_attribute(self.IS_VALID_URL, TRUE)
span.set_attribute(self.IS_VALID_URL, True)

decoded_claim = None
if all(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import pytest
from kiota_abstractions.authentication import AllowedHostsValidator
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import SimpleSpanProcessor
from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter

from kiota_authentication_azure.azure_identity_access_token_provider import (
AzureIdentityAccessTokenProvider,
Expand Down Expand Up @@ -109,6 +112,21 @@ async def test_get_authorization_token_sync():
assert token == "This is a dummy token"


@pytest.mark.asyncio
async def test_get_authorization_token_marks_valid_url_span_attribute_true(monkeypatch):
exporter = InMemorySpanExporter()
provider = TracerProvider()
provider.add_span_processor(SimpleSpanProcessor(exporter))
monkeypatch.setattr(
"kiota_authentication_azure.azure_identity_access_token_provider.tracer",
provider.get_tracer(__name__)
)
token_provider = AzureIdentityAccessTokenProvider(DummySyncAzureTokenCredential(), None)
await token_provider.get_authorization_token('https://graph.microsoft.com')
[span] = exporter.get_finished_spans()
assert span.attributes[AzureIdentityAccessTokenProvider.IS_VALID_URL] is True


@pytest.mark.asyncio
async def test_get_authorization_token_invalid_url():

Expand Down
Loading