Skip to content

Commit

Permalink
tests(jwt-parser): fix flakiness with token expiration test (#10988)
Browse files Browse the repository at this point in the history
Ensure accurate token expiration check in unit test by updating the Nginx
time before verification. Without this update, the test may fail due to
outdated cached time.
  • Loading branch information
samugi authored Jun 5, 2023
1 parent b0559cd commit 750ba97
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions spec/03-plugins/16-jwt/01-jwt_parser_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ describe("Plugin: jwt (parser)", function()
local token = jwt_parser.encode({exp = os.time() - 10}, "secret")
local jwt = assert(jwt_parser:new(token))

ngx.update_time()
local ok, errors = jwt:verify_registered_claims({"exp"})
assert.False(ok)
assert.same({exp = "token expired"}, errors)
Expand Down

1 comment on commit 750ba97

@khcp-gha-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bazel Build

Docker image available kong/kong:750ba978b5ba9234d2ae6d84ac9806904c6cd9bc
Artifacts available https://github.com/Kong/kong/actions/runs/5175763435

Please sign in to comment.