Hello!
On Thu, Mar 27, 2014 at 7:46 AM, James Marlowe wrote:
> The error was from trying to proxy to an internal location which wasn't
> working out.
>
You have bugs in your test cases (and maybe also your library being
tested). By applying the following patch to your lua-resty-hmac
master,
diff --git a/t/sanity.t b/t/sanity.t
index 2033b7b..0208ed4 100644
--- a/t/sanity.t
+++ b/t/sanity.t
@@ -98,7 +98,7 @@ signature matches
--- request
GET /t
--- response_body_like chop
-^\S+, \d+ \S+ \d+ \d+:\d+:\d+ \+0000 AWS
AccessKeyId\:Jk9\+HAezinRE9cTmGVpdzcmA1WU\=$
+^\S+, \d+ \S+ \d+ \d+:\d+:\d+ \+0000\nAWS
AccessKeyId\:Jk9\+HAezinRE9cTmGVpdzcmA1WU\=$
--- no_error_log
[error]
@@ -117,7 +117,7 @@ GET /t
if ok then
ngx.say("authentication complete")
else
- ngx.say("authentication failed")
+ ngx.say("authentication failed: ", err)
end
';
}
@@ -129,7 +129,7 @@ GET /t
proxy_set_header Authorization $auth;
proxy_pass_request_headers off;
- proxy_pass http://localhost/v;
+ proxy_pass http://127.0.0.1:$server_port/v;
}
location /t {
content_by_lua '
TEST 3 now passes and TEST 4 shows an error returned by your
check_headers() function:
t/sanity.t .. 9/24
# Failed test 'TEST 4: generate a request and check the auth headers
- response_body - response is expected'
# at /home/agentzh/git/lua-resty-hmac/../test-nginx/lib/Test/Nginx/Socket.pm
line 1150.
# got: 'authentication failed: missing headers
#
# '
# expected: 'authentication complete
# '
# Failed test 'TEST 4: generate a request and check the auth headers
- response_body - response is expected'
# at /home/agentzh/git/lua-resty-hmac/../test-nginx/lib/Test/Nginx/Socket.pm
line 1150.
# got: 'authentication failed: missing headers
#
# '
# expected: 'authentication complete
# '
# Looks like you failed 2 tests of 24.
t/sanity.t .. Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/24 subtests
Test Summary Report
-------------------
t/sanity.t (Wstat: 512 Tests: 24 Failed: 2)
Failed tests: 20, 23
Non-zero exit status: 2
Files=1, Tests=24, 1 wallclock secs ( 0.03 usr 0.00 sys + 0.23 cusr
0.09 csys = 0.35 CPU)
Result: FAIL
I think you should fix your test case and/or your check_headers()
function yourself. The check_headers() function looks very wrong in
that it tests against uninitialized global Lua variables "method" and
"uri" for header checking. Also it checks the response headers while
your test case is actually sending request headers.
Regards,
-agentzh