Software /
code /
prosody
Annotate
spec/net_http_parser_spec.lua @ 12642:9061f9621330
Switch to a new role-based authorization framework, removing is_admin()
We began moving away from simple "is this user an admin?" permission checks
before 0.12, with the introduction of mod_authz_internal and the ability to
dynamically change the roles of individual users.
The approach in 0.12 still had various limitations however, and apart from
the introduction of roles other than "admin" and the ability to pull that info
from storage, not much actually changed.
This new framework shakes things up a lot, though aims to maintain the same
functionality and behaviour on the surface for a default Prosody
configuration. That is, if you don't take advantage of any of the new
features, you shouldn't notice any change.
The biggest change visible to developers is that usermanager.is_admin() (and
the auth provider is_admin() method) have been removed. Gone. Completely.
Permission checks should now be performed using a new module API method:
module:may(action_name, context)
This method accepts an action name, followed by either a JID (string) or
(preferably) a table containing 'origin'/'session' and 'stanza' fields (e.g.
the standard object passed to most events). It will return true if the action
should be permitted, or false/nil otherwise.
Modules should no longer perform permission checks based on the role name.
E.g. a lot of code previously checked if the user's role was prosody:admin
before permitting some action. Since many roles might now exist with similar
permissions, and the permissions of prosody:admin may be redefined
dynamically, it is no longer suitable to use this method for permission
checks. Use module:may().
If you start an action name with ':' (recommended) then the current module's
name will automatically be used as a prefix.
To define a new permission, use the new module API:
module:default_permission(role_name, action_name)
module:default_permissions(role_name, { action_name[, action_name...] })
This grants the specified role permission to execute the named action(s) by
default. This may be overridden via other mechanisms external to your module.
The built-in roles that developers should use are:
- prosody:user (normal user)
- prosody:admin (host admin)
- prosody:operator (global admin)
The new prosody:operator role is intended for server-wide actions (such as
shutting down Prosody).
Finally, all usage of is_admin() in modules has been fixed by this commit.
Some of these changes were trickier than others, but no change is expected to
break existing deployments.
EXCEPT: mod_auth_ldap no longer supports the ldap_admin_filter option. It's
very possible nobody is using this, but if someone is then we can later update
it to pull roles from LDAP somehow.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 15 Jun 2022 12:15:01 +0100 |
parent | 11033:cb5555443852 |
child | 12882:9ed628635dc6 |
rev | line source |
---|---|
10497
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
1 local http_parser = require "net.http.parser"; |
11030
388f599f66d1
net.http.parser: Add failing test for (large?) chunk-encoded responses
Matthew Wild <mwild1@gmail.com>
parents:
11021
diff
changeset
|
2 local sha1 = require "util.hashes".sha1; |
10497
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
3 |
11033
cb5555443852
net.http.parser: Allow configuration of the chunk size fed to the parser
Matthew Wild <mwild1@gmail.com>
parents:
11032
diff
changeset
|
4 local parser_input_bytes = 3; |
cb5555443852
net.http.parser: Allow configuration of the chunk size fed to the parser
Matthew Wild <mwild1@gmail.com>
parents:
11032
diff
changeset
|
5 |
11032
28de68414750
net.http.parser: Switch tests so that CRLF conversion of input data is optional
Matthew Wild <mwild1@gmail.com>
parents:
11031
diff
changeset
|
6 local function CRLF(s) |
28de68414750
net.http.parser: Switch tests so that CRLF conversion of input data is optional
Matthew Wild <mwild1@gmail.com>
parents:
11031
diff
changeset
|
7 return (s:gsub("\n", "\r\n")); |
28de68414750
net.http.parser: Switch tests so that CRLF conversion of input data is optional
Matthew Wild <mwild1@gmail.com>
parents:
11031
diff
changeset
|
8 end |
28de68414750
net.http.parser: Switch tests so that CRLF conversion of input data is optional
Matthew Wild <mwild1@gmail.com>
parents:
11031
diff
changeset
|
9 |
10497
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
10 local function test_stream(stream, expect) |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
11 local success_cb = spy.new(function (packet) |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
12 assert.is_table(packet); |
11021
9673c95895fb
net.http.parser: Allow specifying sink for large request bodies
Kim Alvefur <zash@zash.se>
parents:
10497
diff
changeset
|
13 if packet.body ~= false then |
9673c95895fb
net.http.parser: Allow specifying sink for large request bodies
Kim Alvefur <zash@zash.se>
parents:
10497
diff
changeset
|
14 assert.is_equal(expect.body, packet.body); |
9673c95895fb
net.http.parser: Allow specifying sink for large request bodies
Kim Alvefur <zash@zash.se>
parents:
10497
diff
changeset
|
15 end |
10497
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
16 end); |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
17 |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
18 local parser = http_parser.new(success_cb, error, stream:sub(1,4) == "HTTP" and "client" or "server") |
11033
cb5555443852
net.http.parser: Allow configuration of the chunk size fed to the parser
Matthew Wild <mwild1@gmail.com>
parents:
11032
diff
changeset
|
19 for chunk in stream:gmatch("."..string.rep(".?", parser_input_bytes-1)) do |
10497
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
20 parser:feed(chunk); |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
21 end |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
22 |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
23 assert.spy(success_cb).was_called(expect.count or 1); |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
24 end |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
25 |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
26 |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
27 describe("net.http.parser", function() |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
28 describe("parser", function() |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
29 it("should handle requests with no content-length or body", function () |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
30 test_stream( |
11032
28de68414750
net.http.parser: Switch tests so that CRLF conversion of input data is optional
Matthew Wild <mwild1@gmail.com>
parents:
11031
diff
changeset
|
31 CRLF[[ |
8236
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
32 GET / HTTP/1.1 |
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
33 Host: example.com |
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
34 |
10497
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
35 ]], |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
36 { |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
37 body = ""; |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
38 } |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
39 ); |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
40 end); |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
41 |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
42 it("should handle responses with empty body", function () |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
43 test_stream( |
11032
28de68414750
net.http.parser: Switch tests so that CRLF conversion of input data is optional
Matthew Wild <mwild1@gmail.com>
parents:
11031
diff
changeset
|
44 CRLF[[ |
8236
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
45 HTTP/1.1 200 OK |
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
46 Content-Length: 0 |
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
47 |
10497
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
48 ]], |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
49 { |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
50 body = ""; |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
51 } |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
52 ); |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
53 end); |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
54 |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
55 it("should handle simple responses", function () |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
56 test_stream( |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
57 |
11032
28de68414750
net.http.parser: Switch tests so that CRLF conversion of input data is optional
Matthew Wild <mwild1@gmail.com>
parents:
11031
diff
changeset
|
58 CRLF[[ |
8236
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
59 HTTP/1.1 200 OK |
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
60 Content-Length: 7 |
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
61 |
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
62 Hello |
10497
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
63 ]], |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
64 { |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
65 body = "Hello\r\n", count = 1; |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
66 } |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
67 ); |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
68 end); |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
69 |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
70 it("should handle chunked encoding in responses", function () |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
71 test_stream( |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
72 |
11032
28de68414750
net.http.parser: Switch tests so that CRLF conversion of input data is optional
Matthew Wild <mwild1@gmail.com>
parents:
11031
diff
changeset
|
73 CRLF[[ |
10497
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
74 HTTP/1.1 200 OK |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
75 Transfer-Encoding: chunked |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
76 |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
77 1 |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
78 H |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
79 1 |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
80 e |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
81 2 |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
82 ll |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
83 1 |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
84 o |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
85 0 |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
86 |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
87 |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
88 ]], |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
89 { |
11021
9673c95895fb
net.http.parser: Allow specifying sink for large request bodies
Kim Alvefur <zash@zash.se>
parents:
10497
diff
changeset
|
90 body = "Hello", count = 2; |
10497
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
91 } |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
92 ); |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
93 end); |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
94 |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
95 it("should handle a stream of responses", function () |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
96 test_stream( |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
97 |
11032
28de68414750
net.http.parser: Switch tests so that CRLF conversion of input data is optional
Matthew Wild <mwild1@gmail.com>
parents:
11031
diff
changeset
|
98 CRLF[[ |
10497
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
99 HTTP/1.1 200 OK |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
100 Content-Length: 5 |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
101 |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
102 Hello |
8236
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
103 HTTP/1.1 200 OK |
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
104 Transfer-Encoding: chunked |
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
105 |
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
106 1 |
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
107 H |
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
108 1 |
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
109 e |
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
110 2 |
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
111 ll |
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
112 1 |
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
113 o |
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
114 0 |
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
115 |
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
116 |
10497
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
117 ]], |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
118 { |
11021
9673c95895fb
net.http.parser: Allow specifying sink for large request bodies
Kim Alvefur <zash@zash.se>
parents:
10497
diff
changeset
|
119 body = "Hello", count = 3; |
10497
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
120 } |
a9fb553b6dbb
net.http.parser tests: Expand tests to include validation of results
Matthew Wild <mwild1@gmail.com>
parents:
8236
diff
changeset
|
121 ); |
8236
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
122 end); |
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
123 end); |
11030
388f599f66d1
net.http.parser: Add failing test for (large?) chunk-encoded responses
Matthew Wild <mwild1@gmail.com>
parents:
11021
diff
changeset
|
124 |
11032
28de68414750
net.http.parser: Switch tests so that CRLF conversion of input data is optional
Matthew Wild <mwild1@gmail.com>
parents:
11031
diff
changeset
|
125 it("should handle large chunked responses", function () |
11031
57739c591a8c
net.http.parser: Fix incorrect path in test
Matthew Wild <mwild1@gmail.com>
parents:
11030
diff
changeset
|
126 local data = io.open("spec/inputs/http/httpstream-chunked-test.txt", "rb"):read("*a"); |
11030
388f599f66d1
net.http.parser: Add failing test for (large?) chunk-encoded responses
Matthew Wild <mwild1@gmail.com>
parents:
11021
diff
changeset
|
127 |
388f599f66d1
net.http.parser: Add failing test for (large?) chunk-encoded responses
Matthew Wild <mwild1@gmail.com>
parents:
11021
diff
changeset
|
128 -- Just a sanity check... text editors and things may mess with line endings, etc. |
388f599f66d1
net.http.parser: Add failing test for (large?) chunk-encoded responses
Matthew Wild <mwild1@gmail.com>
parents:
11021
diff
changeset
|
129 assert.equal("25930f021785ae14053a322c2dbc1897c3769720", sha1(data, true), "test data malformed"); |
388f599f66d1
net.http.parser: Add failing test for (large?) chunk-encoded responses
Matthew Wild <mwild1@gmail.com>
parents:
11021
diff
changeset
|
130 |
388f599f66d1
net.http.parser: Add failing test for (large?) chunk-encoded responses
Matthew Wild <mwild1@gmail.com>
parents:
11021
diff
changeset
|
131 test_stream(data, { |
388f599f66d1
net.http.parser: Add failing test for (large?) chunk-encoded responses
Matthew Wild <mwild1@gmail.com>
parents:
11021
diff
changeset
|
132 body = string.rep("~", 11085), count = 2; |
388f599f66d1
net.http.parser: Add failing test for (large?) chunk-encoded responses
Matthew Wild <mwild1@gmail.com>
parents:
11021
diff
changeset
|
133 }); |
388f599f66d1
net.http.parser: Add failing test for (large?) chunk-encoded responses
Matthew Wild <mwild1@gmail.com>
parents:
11021
diff
changeset
|
134 end); |
8236
4878e4159e12
Port tests to the `busted` test runner
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
135 end); |