Skip to content

Commit

Permalink
fix(tests): Account for differences in JSON serialization
Browse files Browse the repository at this point in the history
This fixes testing on iOS 8 and Linux.

Closes kylef#22
  • Loading branch information
kylef committed Dec 2, 2016
1 parent d945892 commit 7e0c9a4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Tests/JWTTests/JWTTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,16 @@ class EncodeTests: XCTestCase {
func testEncodingJWT() {
let payload = ["name": "Kyle"] as Payload
let jwt = JWT.encode(payload, algorithm: .hs256("secret".data(using: .utf8)!))
let fixture = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiS3lsZSJ9.zxm7xcp1eZtZhp4t-nlw09ATQnnFKIiSN83uG8u6cAg"
XCTAssertEqual(jwt, fixture)

let expected = [
// { "alg": "HS256", "typ": "JWT" }
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiS3lsZSJ9.zxm7xcp1eZtZhp4t-nlw09ATQnnFKIiSN83uG8u6cAg",

// { "typ": "JWT", "alg": "HS256" }
"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJuYW1lIjoiS3lsZSJ9.4tCpoxfyfjbUyLjm9_zu-r52Vxn6bFq9kp6Rt9xMs4A",
]

XCTAssertTrue(expected.contains(jwt))
}

func testEncodingWithBuilder() {
Expand Down

0 comments on commit 7e0c9a4

Please sign in to comment.