Skip to content
This repository was archived by the owner on Aug 15, 2019. It is now read-only.

Commit

Permalink
Correct misspelled method name for validateExpiry(leeway:), retain ol…
Browse files Browse the repository at this point in the history
…d method name as a deprecated method
  • Loading branch information
jonblatho committed Jul 24, 2018
1 parent 14ddad4 commit 2ab9490
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
9 changes: 7 additions & 2 deletions Sources/JWT/ClaimSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ extension ClaimSet {
try validateAudience(audience)
}

try validateExpiary(leeway: leeway)
try validateExpiry(leeway: leeway)
try validateNotBefore(leeway: leeway)
try validateIssuedAt(leeway: leeway)
}
Expand Down Expand Up @@ -132,8 +132,13 @@ extension ClaimSet {
throw InvalidToken.invalidIssuer
}
}


@available(*, deprecated, message: "This method's name is misspelled. Please instead use validateExpiry(leeway:).")
public func validateExpiary(leeway: TimeInterval = 0) throws {
try validateExpiry(leeway: leeway)
}

public func validateExpiry(leeway: TimeInterval = 0) throws {
try validateDate(claims, key: "exp", comparison: .orderedAscending, leeway: (-1 * leeway), failure: .expiredSignature, decodeError: "Expiration time claim (exp) must be an integer")
}

Expand Down
4 changes: 2 additions & 2 deletions Tests/JWTTests/ClaimSetTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class ValidationTests: XCTestCase {
claims.expiration = Date().addingTimeInterval(-1)

do {
try claims.validateExpiary()
try claims.validateExpiry()
XCTFail("InvalidToken.expiredSignature error should have been thrown.")
} catch InvalidToken.expiredSignature {
// Correct error thrown
Expand All @@ -21,7 +21,7 @@ class ValidationTests: XCTestCase {
claims.expiration = Date().addingTimeInterval(-1)

do {
try claims.validateExpiary(leeway: 2)
try claims.validateExpiry(leeway: 2)
} catch {
XCTFail("Unexpected error while validating exp claim that should be valid with leeway.")
}
Expand Down

0 comments on commit 2ab9490

Please sign in to comment.