Skip to content

Commit 24a5b87

Browse files
committed
spec/http_spec: Add test for HPKP
1 parent 6e1ae03 commit 24a5b87

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

spec/http_spec.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,4 +211,13 @@ describe("http patterns", function()
211211
assert.same({["max-age"] = "0"; includesubdomains = true}, sts_patt:match("max-age=0;includeSubdomains"))
212212
assert.same({["max-age"] = "0"; includesubdomains = true}, sts_patt:match("max-age=0 ; includeSubdomains"))
213213
end)
214+
it("Parses a HPKP header", function()
215+
-- Example from RFC 7469 2.1.5
216+
local pkp_patt = lpeg.Cf(lpeg.Ct(true) * http.Public_Key_Pins, function(t, k, v) table.insert(t, {k,v}) return t end) * EOF
217+
assert.same({
218+
{ "max-age", "3000" };
219+
{ "pin-sha256", "d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM=" };
220+
{ "pin-sha256", "E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=" };
221+
}, pkp_patt:match([[max-age=3000; pin-sha256="d6qzRu9zOECb90Uez27xWltNsj0e1Md7GkYYkVoZWmM="; pin-sha256="E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g="]]))
222+
end)
214223
end)

0 commit comments

Comments
 (0)