Skip to content

Commit

Permalink
Fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
ptoffy committed Oct 2, 2024
1 parent 0f46b40 commit abe4f2c
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions Tests/JWTKitTests/RSATests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import JWTKit
import XCTest
import _CryptoExtras

final class RSATests: XCTestCase {
final class RSATests: XCTestCase, @unchecked Sendable {
func testRSADocs() async throws {
await XCTAssertNoThrowAsync(
try await JWTKeyCollection().add(
Expand Down Expand Up @@ -52,15 +52,10 @@ final class RSATests: XCTestCase {
}

func testSigning() async throws {
let keyCollection = try await JWTKeyCollection()
.add(
rsa: Insecure.RSA.PrivateKey(pem: self.privateKey), digestAlgorithm: .sha256,
kid: "private"
)
.add(
rsa: Insecure.RSA.PublicKey(pem: self.publicKey), digestAlgorithm: .sha256,
kid: "public"
)
let keyCollection = try await JWTKeyCollection().add(
rsa: Insecure.RSA.PrivateKey(pem: self.privateKey), digestAlgorithm: .sha256,
kid: "private"
)

let payload = TestPayload(
sub: "vapor",
Expand Down Expand Up @@ -162,19 +157,17 @@ final class RSATests: XCTestCase {
admin: true,
exp: .init(value: .distantFuture)
)
let signerCollection = try await JWTKeyCollection()
.add(
rsa: Insecure.RSA.PrivateKey(pem: self.certPrivateKey), digestAlgorithm: .sha256,
kid: "private"
)
let signerCollection = try await JWTKeyCollection().add(
rsa: Insecure.RSA.PrivateKey(pem: self.certPrivateKey), digestAlgorithm: .sha256,
kid: "private"
)

let jwt = try await signerCollection.sign(test, kid: "private")

let verifierCollection = try await JWTKeyCollection()
.add(
rsa: Insecure.RSA.PublicKey(certificatePEM: self.cert), digestAlgorithm: .sha256,
kid: "cert"
)
let verifierCollection = try await JWTKeyCollection().add(
rsa: Insecure.RSA.PublicKey(certificatePEM: self.cert), digestAlgorithm: .sha256,
kid: "cert"
)

let payload = try await verifierCollection.verify(jwt, as: TestPayload.self)
XCTAssertEqual(payload, test)
Expand Down Expand Up @@ -231,7 +224,8 @@ final class RSATests: XCTestCase {
func testExportKeyAsPEMWhenRawBuilt() async throws {
let key = try Insecure.RSA.PrivateKey(
modulus: self.modulus, exponent: self.publicExponent,
privateExponent: self.privateExponent)
privateExponent: self.privateExponent
)
let key2 = try Insecure.RSA.PrivateKey(pem: key.pemRepresentation)
XCTAssertEqual(key, key2)
}
Expand Down

0 comments on commit abe4f2c

Please sign in to comment.