Skip to content

Commit ae91ce5

Browse files
test_sample_user file
1 parent 12380f9 commit ae91ce5

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# src/tests/backend/auth/test_sample_user.py
2+
3+
import base64
4+
import json
5+
import pytest
6+
import importlib
7+
8+
# Import the module under test so it runs at least once
9+
import backend.auth.sample_user as su
10+
11+
def test_sample_user_is_dict_and_has_lowercase_keys():
12+
d = su.sample_user
13+
assert isinstance(d, dict)
14+
# The sample_user dict uses lowercase header keys
15+
for key in ("x-ms-client-principal", "x-ms-client-principal-id", "x-ms-client-principal-name"):
16+
assert key in d
17+
18+
def test_principal_b64_is_non_empty_string():
19+
b64 = su.sample_user["x-ms-client-principal"]
20+
assert isinstance(b64, str)
21+
assert b64.strip() != ""
22+
23+
def test_get_tenantid_valid_and_invalid():
24+
from backend.auth.auth_utils import get_tenantid
25+
# valid payload -> should extract tid
26+
good = base64.b64encode(json.dumps({"tid": "tenant123"}).encode()).decode()
27+
assert get_tenantid(good) == "tenant123"
28+
# invalid payload -> should return empty
29+
assert get_tenantid("not-base64!!") == ""
30+
31+
def test_reload_module_counts_for_coverage():
32+
# reloading the module to touch it again
33+
m = importlib.reload(su)
34+
assert hasattr(m, "sample_user")

src/tests/backend/test_otlp_tracing.py

Whitespace-only changes.

0 commit comments

Comments
 (0)