Skip to content

Commit

Permalink
tests(basic-auth): fix flaky on invalidations spec (#13890)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oyami-Srk authored Nov 19, 2024
1 parent 3140f81 commit 7c17e3b
Showing 1 changed file with 39 additions and 30 deletions.
69 changes: 39 additions & 30 deletions spec/03-plugins/10-basic-auth/04-invalidations_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,19 @@ for _, strategy in helpers.each_strategy() do
end)

it("#invalidates credentials when the Consumer is deleted", function()
-- populate cache
local res = assert(proxy_client:send {
method = "GET",
path = "/",
headers = {
["Authorization"] = "Basic Ym9iOmtvbmc=",
["Host"] = "basic-auth.test"
}
})
assert.res_status(200, res)
local res
helpers.pwait_until(function()
-- populate cache
res = assert(proxy_client:send {
method = "GET",
path = "/",
headers = {
["Authorization"] = "Basic Ym9iOmtvbmc=",
["Host"] = "basic-auth.test"
}
})
assert.res_status(200, res)
end)

-- ensure cache is populated
local cache_key = db.basicauth_credentials:cache_key("bob")
Expand Down Expand Up @@ -115,16 +118,19 @@ for _, strategy in helpers.each_strategy() do
end)

it("invalidates credentials from cache when deleted", function()
-- populate cache
local res = assert(proxy_client:send {
method = "GET",
path = "/",
headers = {
["Authorization"] = "Basic Ym9iOmtvbmc=",
["Host"] = "basic-auth.test"
}
})
assert.res_status(200, res)
local res
helpers.pwait_until(function()
-- populate cache
res = assert(proxy_client:send {
method = "GET",
path = "/",
headers = {
["Authorization"] = "Basic Ym9iOmtvbmc=",
["Host"] = "basic-auth.test"
}
})
assert.res_status(200, res)
end)

-- ensure cache is populated
local cache_key = db.basicauth_credentials:cache_key("bob")
Expand Down Expand Up @@ -158,16 +164,19 @@ for _, strategy in helpers.each_strategy() do
end)

it("invalidated credentials from cache when updated", function()
-- populate cache
local res = assert(proxy_client:send {
method = "GET",
path = "/",
headers = {
["Authorization"] = "Basic Ym9iOmtvbmc=",
["Host"] = "basic-auth.test"
}
})
assert.res_status(200, res)
local res
helpers.pwait_until(function()
-- populate cache
res = assert(proxy_client:send {
method = "GET",
path = "/",
headers = {
["Authorization"] = "Basic Ym9iOmtvbmc=",
["Host"] = "basic-auth.test"
}
})
assert.res_status(200, res)
end)

-- ensure cache is populated
local cache_key = db.basicauth_credentials:cache_key("bob")
Expand Down

1 comment on commit 7c17e3b

@github-actions
Copy link
Contributor

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:7c17e3be47d6f78ffa361f3f79d71e3c5bab4517
Artifacts available https://github.com/Kong/kong/actions/runs/11913348359

Please sign in to comment.