Conformance Test Suite
A conforming RCAN implementation MUST pass all tests in this section.
1. RURI Validation Tests
| Test ID | Input | Expected | Description |
|---|---|---|---|
| RURI-001 | rcan://continuon.cloud/continuon/companion-v1/d3a4b5c6 | ✅ VALID | Standard RURI |
| RURI-002 | rcan://local.rcan/unitree/go2/a1b2c3d4:9000/teleop | ✅ VALID | With port and capability |
| RURI-003 | rcan://my-server.lan/acme/bot-x1/12345678-1234-1234-1234-123456789abc | ✅ VALID | Full UUID |
| RURI-004 | https://example.com/robot | ❌ INVALID | Wrong scheme |
| RURI-005 | rcan://UPPERCASE/test/test/12345678 | ❌ INVALID | Uppercase not allowed |
| RURI-006 | rcan://a/b/c/1234567 | ❌ INVALID | Device ID too short |
| RURI-007 | rcan://continuon.cloud/continuon/companion-v1/d3a4b5c6/Arm | ❌ INVALID | Capability must be lowercase |
| RURI-008 | rcan:// | ❌ INVALID | Empty components |
2. Role Hierarchy Tests
| Test ID | Role | Required | Expected | Description |
|---|---|---|---|---|
| ROLE-001 | OWNER | GUEST | ✅ ALLOW | Higher role can access lower |
| ROLE-002 | USER | OWNER | ❌ DENY | Lower role cannot access higher |
| ROLE-003 | LEASEE | LEASEE | ✅ ALLOW | Same role can access |
| ROLE-004 | CREATOR | OWNER | ✅ ALLOW | Creator can access all |
| ROLE-005 | GUEST | USER | ❌ DENY | Guest has minimal access |
3. Authentication Tests
| Test ID | Scenario | Expected | Description |
|---|---|---|---|
| AUTH-001 | Valid credential, available role | ✅ GRANTED | Normal auth flow |
| AUTH-002 | Invalid credential | ❌ DENIED (INVALID_CREDENTIALS) | Bad password |
| AUTH-003 | Valid credential, robot busy | ❌ DENIED (ROBOT_BUSY) | Another controller active |
| AUTH-004 | Request CREATOR, max role OWNER | ✅ GRANTED as OWNER | Role downgrade |
| AUTH-005 | Expired JWT | ❌ DENIED (TOKEN_EXPIRED) | Token validation |
| AUTH-006 | Offline mode, cached token valid | ✅ GRANTED (OFFLINE) | Resilience test |
4. Safety Invariant Tests
| Test ID | Scenario | Expected | Description |
|---|---|---|---|
| SAFE-001 | SAFETY priority message | Response < 100ms | Priority processing |
| SAFE-002 | Network partition during command | Safe-stop triggered | Graceful degradation |
| SAFE-003 | Remote command bypasses local limit | ❌ REJECTED | Local safety wins |
| SAFE-004 | Any command execution | Audit log entry created | Logging required |
5. Error Codes
| Code | Name | Description |
|---|---|---|
| 1001 | INVALID_RURI | Malformed RURI string |
| 1002 | UNKNOWN_ROBOT | Robot not found in registry |
| 1003 | ROBOT_OFFLINE | Robot unreachable |
| 2001 | INVALID_CREDENTIALS | Auth credentials rejected |
| 2002 | INSUFFICIENT_PRIVILEGES | Role too low for operation |
| 2003 | TOKEN_EXPIRED | JWT has expired |
| 2004 | TOKEN_REVOKED | JWT was revoked |
| 2005 | RATE_LIMITED | Too many requests |
| 3001 | ROBOT_BUSY | Robot controlled by another user |
| 3002 | COMMAND_TIMEOUT | Command execution timed out |
| 3003 | COMMAND_REJECTED | Command failed safety check |
| 3004 | CAPABILITY_UNAVAILABLE | Requested capability not present |
| 4001 | SAFETY_VIOLATION | Action would violate safety constraints |
| 4002 | EMERGENCY_STOP | Robot in emergency stop state |
6. Python Test Runner
Run the conformance tests with pytest:
"""RCAN Conformance Test Suite"""
import pytest
from rcan import RURI, Role
class TestRURIValidation:
@pytest.mark.parametrize("ruri,expected", [
("rcan://continuon.cloud/continuon/companion-v1/d3a4b5c6", True),
("rcan://local.rcan/unitree/go2/a1b2c3d4:9000/teleop", True),
("https://example.com/robot", False),
("rcan://UPPERCASE/test/test/12345678", False),
("rcan://a/b/c/1234567", False),
])
def test_ruri_validation(self, ruri: str, expected: bool):
assert RURI.is_valid(ruri) == expected
class TestRoleHierarchy:
@pytest.mark.parametrize("role,required,expected", [
(Role.OWNER, Role.GUEST, True),
(Role.USER, Role.OWNER, False),
(Role.CREATOR, Role.OWNER, True),
])
def test_role_access(self, role: Role, required: Role, expected: bool):
assert role.can_access(required) == expected
if __name__ == "__main__":
pytest.main([__file__, "-v"]) pip install pytest
python -m pytest test_rcan_conformance.py -v