Skip to content

Commit

Permalink
added tests for cookie parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
gregoryyoung2 committed Oct 18, 2020
1 parent 2ae7fa7 commit cc2218e
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Tests/VaporTests/HTTPHeaderTests.swift
Expand Up @@ -185,6 +185,27 @@ final class HTTPHeaderTests: XCTestCase {
XCTAssertEqual(headers.cookie?["cookie_one"]?.string, "1")
XCTAssertEqual(headers.cookie?["cookie.two"]?.string, "2")
}

func testCookie_percentParsing() throws {
let headers = HTTPHeaders([
("cookie", "cookie_one=1;cookie%40cookieCom=2;cookie_3=three")
])

XCTAssertEqual(headers.cookie?["cookie_one"]?.string, "1")
XCTAssertEqual(headers.cookie?["cookie%40cookieCom"]?.string, "2")
XCTAssertEqual(headers.cookie?["cookie_3"]?.string, "three")
}

func testCookie_invalidCookie() throws {
let headers = HTTPHeaders([
("cookie", "cookie_one=1;cookie\ntwo=2;cookie_three=3")
])

XCTAssertEqual(headers.cookie?.all.count, 2)
XCTAssertEqual(headers.cookie?["cookie_one"]?.string, "1")
XCTAssertNil(headers.cookie?["cookie\ntwo"])
XCTAssertEqual(headers.cookie?["cookie_three"]?.string, "3")
}

func testMediaTypeMainTypeCaseInsensitive() throws {
let lower = HTTPMediaType(type: "foo", subType: "")
Expand Down

0 comments on commit cc2218e

Please sign in to comment.