this repo has no description
1//
2// DPoPJWTGeneratorTests.swift
3// CoreATProtocol
4//
5// Created by Claude on 2026-01-02.
6//
7
8import Testing
9import Foundation
10import JWTKit
11@testable import CoreATProtocol
12
13@Suite("DPoP JWT Generator Tests", .serialized)
14struct DPoPJWTGeneratorTests {
15
16 @Test("DPoP JWT Generator can be created with ES256 key")
17 func testGeneratorCreation() async throws {
18 let privateKey = ES256PrivateKey()
19 let generator = try await DPoPJWTGenerator(privateKey: privateKey)
20
21 // Verify we can get a JWT generator function
22 _ = await generator.jwtGenerator()
23 // If we get here without throwing, the test passes
24 }
25
26 @Test("DPoPKeyMaterialError cases exist")
27 func testKeyMaterialErrors() {
28 // Test error cases exist and are equatable
29 let error1 = DPoPKeyMaterialError.publicKeyUnavailable
30 let error2 = DPoPKeyMaterialError.invalidCoordinate
31
32 #expect(error1 != error2)
33 #expect(error1 == DPoPKeyMaterialError.publicKeyUnavailable)
34 }
35
36 @Test("Resource server nonce can be updated")
37 func testResourceServerNonce() async {
38 // Clear state first
39 await updateResourceDPoPNonce(nil)
40
41 // Set nonce using the public function
42 await updateResourceDPoPNonce("test-nonce-value")
43 let nonce = await APEnvironment.current.resourceServerNonce
44 #expect(nonce == "test-nonce-value")
45
46 // Clear it
47 await updateResourceDPoPNonce(nil)
48 let clearedNonce = await APEnvironment.current.resourceServerNonce
49 #expect(clearedNonce == nil)
50 }
51}