// // DPoPJWTGeneratorTests.swift // CoreATProtocol // // Created by Claude on 2026-01-02. // import Testing import Foundation import JWTKit @testable import CoreATProtocol @Suite("DPoP JWT Generator Tests", .serialized) struct DPoPJWTGeneratorTests { @Test("DPoP JWT Generator can be created with ES256 key") func testGeneratorCreation() async throws { let privateKey = ES256PrivateKey() let generator = try await DPoPJWTGenerator(privateKey: privateKey) // Verify we can get a JWT generator function _ = await generator.jwtGenerator() // If we get here without throwing, the test passes } @Test("DPoPKeyMaterialError cases exist") func testKeyMaterialErrors() { // Test error cases exist and are equatable let error1 = DPoPKeyMaterialError.publicKeyUnavailable let error2 = DPoPKeyMaterialError.invalidCoordinate #expect(error1 != error2) #expect(error1 == DPoPKeyMaterialError.publicKeyUnavailable) } @Test("Resource server nonce can be updated") func testResourceServerNonce() async { // Clear state first await updateResourceDPoPNonce(nil) // Set nonce using the public function await updateResourceDPoPNonce("test-nonce-value") let nonce = await APEnvironment.current.resourceServerNonce #expect(nonce == "test-nonce-value") // Clear it await updateResourceDPoPNonce(nil) let clearedNonce = await APEnvironment.current.resourceServerNonce #expect(clearedNonce == nil) } }