Skip to content

Commit ba6a289

Browse files
committed
chore: add basic test for oasf claims
Signed-off-by: copasseron <cpassero@cisco.com>
1 parent 7fbdef1 commit ba6a289

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

sdk/python/tests/unit/badge/test_claims.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import base64
66
import json
7-
from unittest.mock import AsyncMock, patch
7+
from unittest.mock import AsyncMock, patch, mock_open
88

99
import pytest
1010

@@ -59,6 +59,24 @@ async def test_create_claims_for_a2a_agent():
5959
assert "a2a" in claims
6060
assert claims["a2a"]["schema_base64"] == expected_schema
6161

62+
@pytest.mark.asyncio
63+
async def test_create_claims_for_oasf_agent():
64+
"""Test create_claims for OASF agent."""
65+
# Arrange
66+
service_url = "/path/to/oasf.json"
67+
service_type = AppType.APP_TYPE_AGENT_OASF
68+
oasf_schema = json.dumps({"version": "1.0.0", "name": "Test OASF Agent"})
69+
expected_schema = base64.b64encode(oasf_schema.encode("utf-8"))
70+
71+
# Act
72+
m = mock_open(read_data=oasf_schema)
73+
with patch("builtins.open", m):
74+
claims = await create_claims(service_url, "", service_type)
75+
76+
# Assert
77+
m.assert_called_once_with(service_url, "r", encoding="utf-8")
78+
assert "oasf" in claims
79+
assert claims["oasf"]["schema_base64"] == expected_schema
6280

6381
@pytest.mark.asyncio
6482
async def test_create_claims_for_unsupported_service_type():

0 commit comments

Comments
 (0)