Skip to content

Commit

Permalink
Added test for pattern matching JWTError (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-Lees11 committed Mar 18, 2019
1 parent e7b5111 commit 4136f6e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Tests/SwiftJWTTests/TestJWT.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ class TestJWT: XCTestCase {
("testMicroProfile", testMicroProfile),
("testValidateClaims", testValidateClaims),
("testValidateClaimsLeeway", testValidateClaimsLeeway),
]
("testErrorPattenMatching", testErrorPattenMatching),
]
}

func testSignAndVerify() {
Expand Down Expand Up @@ -539,6 +540,16 @@ class TestJWT: XCTestCase {
jwt.claims.nbf = Date(timeIntervalSinceNow: 10)
XCTAssertEqual(jwt.validateClaims(leeway: 20), .success, "Validation failed")
}

func testErrorPattenMatching() {
do {
let _ = try JWT<TestClaims>(jwtString: "InvalidString", verifier: .rs256(publicKey: rsaPublicKey))
} catch JWTError.invalidJWTString {
// Caught correct error
} catch {
XCTFail("Incorrect error thrown: \(error)")
}
}
}

func read(fileName: String) -> Data {
Expand Down

0 comments on commit 4136f6e

Please sign in to comment.