-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spec/http_proxy_spec.lua: very basic unittest
- Loading branch information
Showing
1 changed file
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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) |