Skip to content

Commit

Permalink
fix(tests): add more detail for connection refused
Browse files Browse the repository at this point in the history
  • Loading branch information
wklken committed Nov 14, 2024
1 parent e30db9d commit aa89f24
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/apisix/editions/ee/plugins/bk-cache/access-token.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ function _M.get_access_token(access_token)
"key=", key, " result=", core.json.delay_encode(result))
return result.token, nil
end

err = "get_access_token failed, error: " .. err
end

return nil, err
Expand Down
2 changes: 2 additions & 0 deletions src/apisix/editions/ee/plugins/bk-cache/bk-token.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ function _M.get_username_by_bk_token(bk_token)
"key=", key, " result=", core.json.delay_encode(result))
return result.username, result.error_message
end

err = "get_username_by_bk_token failed, error: " .. err
end

return nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ describe(
local access_token = uuid.generate_v4()
local result, err = access_token_cache.get_access_token(access_token)
assert.is_nil(result)
assert.is_equal(err, "connection refused")
assert.is_equal(err, "get_access_token failed, error: connection refused")
assert.stub(ssm_component.verify_access_token).was_called_with(access_token)
end
)
Expand Down
2 changes: 1 addition & 1 deletion src/apisix/editions/ee/tests/bk-cache/test-bk-token.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe(
local bk_token = uuid.generate_v4()
local result, err = bk_token_cache.get_username_by_bk_token(bk_token)
assert.is_nil(result)
assert.is_equal(err, "connection refused")
assert.is_equal(err, "get_username_by_bk_token failed, error: connection refused")
assert.stub(bklogin_component.get_username_by_bk_token).was_called_with(bk_token)
end
)
Expand Down
2 changes: 2 additions & 0 deletions src/apisix/plugins/bk-cache/app-account.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ function _M.verify_app_secret(app_code, app_secret)
-- else
-- core.log.error("the bkauth down, but also miss in fallback cache, error: ", err, " key=", key)
end

err = "verify_app_secret failed, error: " .. err
end

return nil, err
Expand Down
2 changes: 1 addition & 1 deletion src/apisix/tests/bk-cache/test-app-account.lua
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ describe(
local app_code = uuid.generate_v4()
local result, err = app_account_cache.verify_app_secret(app_code, 'fake-app-secret')
assert.is_nil(result)
assert.is_equal(err, 'connection refused')
assert.is_equal(err, 'verify_app_secret failed, error: connection refused')
assert.stub(bkauth_component.verify_app_secret).was_called_with(app_code, 'fake-app-secret')
end
)
Expand Down

0 comments on commit aa89f24

Please sign in to comment.