-
Notifications
You must be signed in to change notification settings - Fork 170
/
Copy pathhttp_proxy_spec.lua
52 lines (43 loc) · 1.26 KB
/
http_proxy_spec.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
describe('http_proxy', function()
describe('.request', function()
local function stub_ngx_request()
ngx.var = { }
stub(ngx, 'exit')
stub(ngx.req, 'get_headers', function() return { } end)
stub(ngx.req, 'get_method', function() return 'GET' end)
end
local function stub_resty_http_proxy()
local httpc = {
}
local response = {}
stub(httpc, 'request', function() return response end)
stub(httpc, 'proxy_response')
stub(httpc, 'set_keepalive')
local resty_http_proxy = require 'resty.http.proxy'
stub(resty_http_proxy, 'new', function() return httpc end)
end
before_each(function()
stub_ngx_request()
stub_resty_http_proxy()
end)
describe('on https backend', function()
local upstream = {
uri = {
scheme = 'https'
},
request_unbuffered = false,
skip_https_connect = false
}
local proxy_uri = {
}
before_each(function()
stub(upstream, 'rewrite_request')
end)
it('terminates phase', function()
local http_proxy = require('apicast.http_proxy')
http_proxy.request(upstream, proxy_uri)
assert.spy(ngx.exit).was_called_with(ngx.OK)
end)
end)
end)
end)