Software / code / prosody
Annotate
spec/util_http_spec.lua @ 13801:a5d5fefb8b68 13.0
mod_tls: Enable Prosody's certificate checking for incoming s2s connections (fixes #1916) (thanks Damian, Zash)
Various options in Prosody allow control over the behaviour of the certificate
verification process For example, some deployments choose to allow falling
back to traditional "dialback" authentication (XEP-0220), while others verify
via DANE, hard-coded fingerprints, or other custom plugins.
Implementing this flexibility requires us to override OpenSSL's default
certificate verification, to allow Prosody to verify the certificate itself,
apply custom policies and make decisions based on the outcome.
To enable our custom logic, we have to suppress OpenSSL's default behaviour of
aborting the connection with a TLS alert message. With LuaSec, this can be
achieved by using the verifyext "lsec_continue" flag.
We also need to use the lsec_ignore_purpose flag, because XMPP s2s uses server
certificates as "client" certificates (for mutual TLS verification in outgoing
s2s connections).
Commit 99d2100d2918 moved these settings out of the defaults and into mod_s2s,
because we only really need these changes for s2s, and they should be opt-in,
rather than automatically applied to all TLS services we offer.
That commit was incomplete, because it only added the flags for incoming
direct TLS connections. StartTLS connections are handled by mod_tls, which was
not applying the lsec_* flags. It previously worked because they were already
in the defaults.
This resulted in incoming s2s connections with "invalid" certificates being
aborted early by OpenSSL, even if settings such as `s2s_secure_auth = false`
or DANE were present in the config.
Outgoing s2s connections inherit verify "none" from the defaults, which means
OpenSSL will receive the cert but will not terminate the connection when it is
deemed invalid. This means we don't need lsec_continue there, and we also
don't need lsec_ignore_purpose (because the remote peer is a "server").
Wondering why we can't just use verify "none" for incoming s2s? It's because
in that mode, OpenSSL won't request a certificate from the peer for incoming
connections. Setting verify "peer" is how you ask OpenSSL to request a
certificate from the client, but also what triggers its built-in verification.
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 01 Apr 2025 17:26:56 +0100 |
| parent | 13401:626ab0af83af |
| rev | line source |
|---|---|
|
8236
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
1 |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
2 local http = require "util.http"; |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
3 |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
4 describe("util.http", function() |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
5 describe("#urlencode()", function() |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
6 it("should not change normal characters", function() |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
7 assert.are.equal(http.urlencode("helloworld123"), "helloworld123"); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
8 end); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
9 |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
10 it("should escape spaces", function() |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
11 assert.are.equal(http.urlencode("hello world"), "hello%20world"); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
12 end); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
13 |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
14 it("should escape important URL characters", function() |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
15 assert.are.equal(http.urlencode("This & that = something"), "This%20%26%20that%20%3d%20something"); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
16 end); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
17 end); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
18 |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
19 describe("#urldecode()", function() |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
20 it("should not change normal characters", function() |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
21 assert.are.equal("helloworld123", http.urldecode("helloworld123"), "Normal characters not escaped"); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
22 end); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
23 |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
24 it("should decode spaces", function() |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
25 assert.are.equal("hello world", http.urldecode("hello%20world"), "Spaces escaped"); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
26 end); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
27 |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
28 it("should decode important URL characters", function() |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
29 assert.are.equal("This & that = something", http.urldecode("This%20%26%20that%20%3d%20something"), "Important URL chars escaped"); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
30 end); |
|
9785
ff88b03c343f
util.http: Fix decoding of uppercase URL encoded chars
Kim Alvefur <zash@zash.se>
parents:
9505
diff
changeset
|
31 |
|
ff88b03c343f
util.http: Fix decoding of uppercase URL encoded chars
Kim Alvefur <zash@zash.se>
parents:
9505
diff
changeset
|
32 it("should decode both lower and uppercase", function () |
|
ff88b03c343f
util.http: Fix decoding of uppercase URL encoded chars
Kim Alvefur <zash@zash.se>
parents:
9505
diff
changeset
|
33 assert.are.equal("This & that = {something}.", http.urldecode("This%20%26%20that%20%3D%20%7Bsomething%7D%2E"), "Important URL chars escaped"); |
|
ff88b03c343f
util.http: Fix decoding of uppercase URL encoded chars
Kim Alvefur <zash@zash.se>
parents:
9505
diff
changeset
|
34 end); |
|
ff88b03c343f
util.http: Fix decoding of uppercase URL encoded chars
Kim Alvefur <zash@zash.se>
parents:
9505
diff
changeset
|
35 |
|
8236
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
36 end); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
37 |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
38 describe("#formencode()", function() |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
39 it("should encode basic data", function() |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
40 assert.are.equal(http.formencode({ { name = "one", value = "1"}, { name = "two", value = "2" } }), "one=1&two=2", "Form encoded"); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
41 end); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
42 |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
43 it("should encode special characters with escaping", function() |
|
13401
626ab0af83af
util.http: Silence strict luacheck warning in tests
Kim Alvefur <zash@zash.se>
parents:
13124
diff
changeset
|
44 -- luacheck: ignore 631 |
|
8236
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
45 assert.are.equal(http.formencode({ { name = "one two", value = "1"}, { name = "two one&", value = "2" } }), "one+two=1&two+one%26=2", "Form encoded"); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
46 end); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
47 end); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
48 |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
49 describe("#formdecode()", function() |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
50 it("should decode basic data", function() |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
51 local t = http.formdecode("one=1&two=2"); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
52 assert.are.same(t, { |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
53 { name = "one", value = "1" }; |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
54 { name = "two", value = "2" }; |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
55 one = "1"; |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
56 two = "2"; |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
57 }); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
58 end); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
59 |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
60 it("should decode special characters", function() |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
61 local t = http.formdecode("one+two=1&two+one%26=2"); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
62 assert.are.same(t, { |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
63 { name = "one two", value = "1" }; |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
64 { name = "two one&", value = "2" }; |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
65 ["one two"] = "1"; |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
66 ["two one&"] = "2"; |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
67 }); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
68 end); |
|
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
69 end); |
|
9505
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
70 |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
71 describe("normalize_path", function () |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
72 it("root path is always '/'", function () |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
73 assert.equal("/", http.normalize_path("/")); |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
74 assert.equal("/", http.normalize_path("")); |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
75 assert.equal("/", http.normalize_path("/", true)); |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
76 assert.equal("/", http.normalize_path("", true)); |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
77 end); |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
78 |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
79 it("works", function () |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
80 assert.equal("/foo", http.normalize_path("foo")); |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
81 assert.equal("/foo", http.normalize_path("/foo")); |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
82 assert.equal("/foo", http.normalize_path("foo/")); |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
83 assert.equal("/foo", http.normalize_path("/foo/")); |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
84 end); |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
85 |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
86 it("is_dir works", function () |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
87 assert.equal("/foo/", http.normalize_path("foo", true)); |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
88 assert.equal("/foo/", http.normalize_path("/foo", true)); |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
89 assert.equal("/foo/", http.normalize_path("foo/", true)); |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
90 assert.equal("/foo/", http.normalize_path("/foo/", true)); |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
91 end); |
|
5203b6fd34d4
util.http: Add tests for normalize_path
Kim Alvefur <zash@zash.se>
parents:
8236
diff
changeset
|
92 end); |
|
10711
d2e4584ba7b3
spec: Add test cases for util.http.contains_token
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
9785
diff
changeset
|
93 |
|
d2e4584ba7b3
spec: Add test cases for util.http.contains_token
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
9785
diff
changeset
|
94 describe("contains_token", function () |
|
d2e4584ba7b3
spec: Add test cases for util.http.contains_token
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
9785
diff
changeset
|
95 it("is present in field", function () |
|
d2e4584ba7b3
spec: Add test cases for util.http.contains_token
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
9785
diff
changeset
|
96 assert.is_true(http.contains_token("foo", "foo")); |
|
d2e4584ba7b3
spec: Add test cases for util.http.contains_token
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
9785
diff
changeset
|
97 assert.is_true(http.contains_token("foo, bar", "foo")); |
|
d2e4584ba7b3
spec: Add test cases for util.http.contains_token
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
9785
diff
changeset
|
98 assert.is_true(http.contains_token("foo,bar", "foo")); |
|
d2e4584ba7b3
spec: Add test cases for util.http.contains_token
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
9785
diff
changeset
|
99 assert.is_true(http.contains_token("bar, foo,baz", "foo")); |
|
d2e4584ba7b3
spec: Add test cases for util.http.contains_token
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
9785
diff
changeset
|
100 end); |
|
d2e4584ba7b3
spec: Add test cases for util.http.contains_token
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
9785
diff
changeset
|
101 |
|
d2e4584ba7b3
spec: Add test cases for util.http.contains_token
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
9785
diff
changeset
|
102 it("is absent from field", function () |
|
d2e4584ba7b3
spec: Add test cases for util.http.contains_token
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
9785
diff
changeset
|
103 assert.is_false(http.contains_token("bar", "foo")); |
|
d2e4584ba7b3
spec: Add test cases for util.http.contains_token
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
9785
diff
changeset
|
104 assert.is_false(http.contains_token("fooo", "foo")); |
|
d2e4584ba7b3
spec: Add test cases for util.http.contains_token
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
9785
diff
changeset
|
105 assert.is_false(http.contains_token("foo o,bar", "foo")); |
|
d2e4584ba7b3
spec: Add test cases for util.http.contains_token
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
9785
diff
changeset
|
106 end); |
|
d2e4584ba7b3
spec: Add test cases for util.http.contains_token
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
9785
diff
changeset
|
107 |
|
d2e4584ba7b3
spec: Add test cases for util.http.contains_token
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
9785
diff
changeset
|
108 it("is weird", function () |
|
d2e4584ba7b3
spec: Add test cases for util.http.contains_token
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
9785
diff
changeset
|
109 assert.is_(http.contains_token("fo o", "foo")); |
|
d2e4584ba7b3
spec: Add test cases for util.http.contains_token
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
9785
diff
changeset
|
110 end); |
|
d2e4584ba7b3
spec: Add test cases for util.http.contains_token
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
9785
diff
changeset
|
111 end); |
|
13124
f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Kim Alvefur <zash@zash.se>
parents:
10711
diff
changeset
|
112 |
|
f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Kim Alvefur <zash@zash.se>
parents:
10711
diff
changeset
|
113 do |
|
f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Kim Alvefur <zash@zash.se>
parents:
10711
diff
changeset
|
114 describe("parse_forwarded", function() |
|
f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Kim Alvefur <zash@zash.se>
parents:
10711
diff
changeset
|
115 it("works", function() |
|
f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Kim Alvefur <zash@zash.se>
parents:
10711
diff
changeset
|
116 assert.same({ { ["for"] = "[2001:db8:cafe::17]:4711" } }, http.parse_forwarded('For="[2001:db8:cafe::17]:4711"'), "case insensitive"); |
|
f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Kim Alvefur <zash@zash.se>
parents:
10711
diff
changeset
|
117 |
|
f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Kim Alvefur <zash@zash.se>
parents:
10711
diff
changeset
|
118 assert.same({ { ["for"] = "192.0.2.60"; proto = "http"; by = "203.0.113.43" } }, http.parse_forwarded('for=192.0.2.60;proto=http;by=203.0.113.43'), |
|
f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Kim Alvefur <zash@zash.se>
parents:
10711
diff
changeset
|
119 "separated by semicolon"); |
|
f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Kim Alvefur <zash@zash.se>
parents:
10711
diff
changeset
|
120 |
|
f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Kim Alvefur <zash@zash.se>
parents:
10711
diff
changeset
|
121 assert.same({ { ["for"] = "192.0.2.43" }; { ["for"] = "198.51.100.17" } }, http.parse_forwarded('for=192.0.2.43, for=198.51.100.17'), |
|
f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Kim Alvefur <zash@zash.se>
parents:
10711
diff
changeset
|
122 "Values from multiple proxy servers can be appended using a comma"); |
|
f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Kim Alvefur <zash@zash.se>
parents:
10711
diff
changeset
|
123 |
|
f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Kim Alvefur <zash@zash.se>
parents:
10711
diff
changeset
|
124 end) |
|
f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Kim Alvefur <zash@zash.se>
parents:
10711
diff
changeset
|
125 it("rejects quoted quotes", function () |
|
f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Kim Alvefur <zash@zash.se>
parents:
10711
diff
changeset
|
126 assert.falsy(http.parse_forwarded('foo="bar\"bar'), "quoted quotes"); |
|
f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Kim Alvefur <zash@zash.se>
parents:
10711
diff
changeset
|
127 end) |
|
f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Kim Alvefur <zash@zash.se>
parents:
10711
diff
changeset
|
128 pending("deals with quoted quotes", function () |
|
f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Kim Alvefur <zash@zash.se>
parents:
10711
diff
changeset
|
129 assert.same({ { foo = 'bar"baz' } }, http.parse_forwarded('foo="bar\"bar'), "quoted quotes"); |
|
f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Kim Alvefur <zash@zash.se>
parents:
10711
diff
changeset
|
130 end) |
|
f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Kim Alvefur <zash@zash.se>
parents:
10711
diff
changeset
|
131 end) |
|
f15e23840780
util.http: Implement parser for RFC 7239 Forwarded header
Kim Alvefur <zash@zash.se>
parents:
10711
diff
changeset
|
132 end |
|
8236
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
133 end); |