Skip to content

Commit 0cfc196

Browse files
lucafavatellaSkyLothar
authored andcommitted
Review CI (#59)
* Delete leftover .dockerignore file ... following Dockerfile deletion of Dockerfile in fc34168. * Ensure tests failure are reported by CI ... by ensuring that `luarocks ... && prove ...` exit code is propagated to CI. Remove `docker-compose` in order to reduce levels of indirections. Also: * Test local codebase rather than hardcoded remote master branch - in order to enable more flexible testing e.g. local develoment testing or GiHub PR testing or GitHub branch testing; * Split CI logic in separate script in order to enable local development testing. * Do not restrict tests to master branch * Update leftover reference to docker-compose * Fix TESTs 83 and 77 errors First error addressed: ``` # Failed test 'TEST 83: Validator.contains_any_of - status code ok' # at /usr/local/share/perl/5.18.2/Test/Nginx/Socket.pm line 891. # got: '500' # expected: '200' # Failed test 'TEST 83: Validator.contains_any_of - response_body - response is expected (req 0)' # at /usr/local/share/perl/5.18.2/Test/Nginx/Socket.pm line 1277. # @@ -1,4 +1,7 @@ # -true # +<html> # -true # +<head><title>500 Internal Server Error</title></head> # -Cannot create validator for non-table roles. # +<body bgcolor="white"> # -false # +<center><h1>500 Internal Server Error</h1></center> # +<hr><center>openresty/1.9.7.4</center> # +</body> # +</html> # Failed test 'TEST 83: Validator.contains_any_of - pattern "[error]" should not match any line in error.log but matches line "2017/03/21 17:34:37 [error] 2091\#0: *1 failed to load inlined Lua code: content_by_lua(nginx.conf:91):7: unexpected symbol near '[', client: 127.0.0.1, server: localhost, request: \"GET /t HTTP/1.1\", host: \"localhost\"" (req 0)' # at /usr/local/share/perl/5.18.2/Test/Nginx/Socket.pm line 1157. ```
1 parent ec55be9 commit 0cfc196

File tree

7 files changed

+31
-29
lines changed

7 files changed

+31
-29
lines changed

.dockerignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.travis.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ services:
44
- docker
55

66
before_install:
7-
- docker pull skylothar/openresty-testsuite:latest
7+
- ./ci before_install
88

99
script:
10-
- docker-compose up
11-
12-
branches:
13-
only:
14-
- master
10+
- ./ci script

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ Testing With Docker
433433
===================
434434

435435
```
436-
docker-compose up
436+
./ci script
437437
```
438438

439439
[Back to TOC](#table-of-contents)

ci

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -ev # Ref https://docs.travis-ci.com/user/customizing-the-build/#Implementing-Complex-Build-Steps
4+
5+
case "${1:?}" in
6+
before_install)
7+
docker pull skylothar/openresty-testsuite:latest
8+
;;
9+
script)
10+
docker run \
11+
-a stdin -a stdout -a stderr -i \
12+
--rm \
13+
--entrypoint="" \
14+
-v "$(pwd)":/lua-resty-jwt -w /lua-resty-jwt \
15+
--name lua-resty-jwt-tests \
16+
skylothar/openresty-testsuite:latest \
17+
/bin/sh -c 'luarocks make lua-resty-jwt-dev-0.rockspec && prove -r t'
18+
;;
19+
esac

docker-compose.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

lua-resty-jwt-dev-0.rockspec

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package = 'lua-resty-jwt'
22
version = 'dev-0'
33
source = {
4-
url = 'git://github.com/SkyLothar/lua-resty-jwt',
5-
branch = 'master'
4+
url = 'file://.'
65
}
76
description = {
87
summary = 'JWT for ngx_lua and LuaJIT.',

t/validators.t

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,19 +1966,19 @@ GET /t
19661966
local tval = validators.opt_contains_any_of({ "roleFoo", "roleBar" }, "roles")
19671967
local obj1 = {
19681968
header = { type="JWT", alg="HS256" },
1969-
payload = { foo="bar", baz="boo", num=42, roles=[ "roleFoo", "roleBaz" ] }
1969+
payload = { foo="bar", baz="boo", num=42, roles={ "roleFoo", "roleBaz" } }
19701970
}
19711971
local obj2 = {
19721972
header = { type="JWT", alg="HS256" },
1973-
payload = { foo="bar", baz="boo", num=42, roles=[ "roleBar", "roleBaz" ] }
1973+
payload = { foo="bar", baz="boo", num=42, roles={ "roleBar", "roleBaz" } }
19741974
}
19751975
local obj3 = {
19761976
header = { type="JWT", alg="HS256" },
19771977
payload = { foo="bar", baz="boo", num=42, roles="roleFoo" }
19781978
}
19791979
local obj4 = {
19801980
header = { type="JWT", alg="HS256" },
1981-
payload = { foo="bar", baz="boo", num=42, roles=[ "roleBoo", "roleBaz" ] }
1981+
payload = { foo="bar", baz="boo", num=42, roles={ "roleBoo", "roleBaz" } }
19821982
}
19831983
__testValidator(tval, "roles", obj1)
19841984
__testValidator(tval, "roles", obj2)
@@ -1991,7 +1991,7 @@ GET /t
19911991
--- response_body
19921992
true
19931993
true
1994-
Cannot create validator for non-table roles.
1994+
'roles' is malformed. Expected to be a table.
19951995
false
19961996
--- no_error_log
19971997
[error]
@@ -2096,19 +2096,19 @@ Cannot create validator for non-string table table-claim.
20962096
local tval = validators.contains_any_of({ "roleFoo", "roleBar" }, "roles")
20972097
local obj1 = {
20982098
header = { type="JWT", alg="HS256" },
2099-
payload = { foo="bar", baz="boo", num=42, roles=[ "roleFoo", "roleBaz" ] }
2099+
payload = { foo="bar", baz="boo", num=42, roles={ "roleFoo", "roleBaz" } }
21002100
}
21012101
local obj2 = {
21022102
header = { type="JWT", alg="HS256" },
2103-
payload = { foo="bar", baz="boo", num=42, roles=[ "roleBar", "roleBaz" ] }
2103+
payload = { foo="bar", baz="boo", num=42, roles={ "roleBar", "roleBaz" } }
21042104
}
21052105
local obj3 = {
21062106
header = { type="JWT", alg="HS256" },
21072107
payload = { foo="bar", baz="boo", num=42, roles="roleFoo" }
21082108
}
21092109
local obj4 = {
21102110
header = { type="JWT", alg="HS256" },
2111-
payload = { foo="bar", baz="boo", num=42, roles=[ "roleBaz", "roleBoo" ] }
2111+
payload = { foo="bar", baz="boo", num=42, roles={ "roleBaz", "roleBoo" } }
21122112
}
21132113
__testValidator(tval, "roles", obj1)
21142114
__testValidator(tval, "roles", obj2)
@@ -2121,7 +2121,7 @@ GET /t
21212121
--- response_body
21222122
true
21232123
true
2124-
Cannot create validator for non-table roles.
2124+
'roles' is malformed. Expected to be a table.
21252125
false
21262126
--- no_error_log
21272127
[error]

0 commit comments

Comments
 (0)