1- local helpers = require " spec.helpers"
2- local conf_loader = require " kong.conf_loader"
1+ local helpers = require ( " spec.helpers" )
2+ local conf_loader = require ( " kong.conf_loader" )
33
44describe (" basic-auth: (vault integration)" , function ()
55 local get
@@ -9,15 +9,15 @@ describe("basic-auth: (vault integration)", function()
99 vaults = " bundled" ,
1010 }))
1111
12- local kong_global = require " kong.global"
12+ local kong_global = require ( " kong.global" )
1313 _G .kong = kong_global .new ()
1414 kong_global .init_pdk (kong , conf )
1515
1616 get = _G .kong .vault .get
1717 end )
1818
1919 describe (" vault reference resolution" , function ()
20- it (" should handle all variations of variable name" , function ()
20+ it (" should handle all variations of variable name" , function ()
2121 local env_name = " MY_VAR_NAME"
2222 local env_value = " complex_value_789"
2323
@@ -67,7 +67,7 @@ describe("basic-auth: (vault integration)", function()
6767
6868 it (" should fail gracefully when environment variable does not exist" , function ()
6969 helpers .unsetenv (" NON_EXISTENT_VAR" )
70-
70+
7171 local res , err = get (" {vault://env/non_existent_var}" )
7272 assert .matches (" could not get value from external vault" , err )
7373 assert .is_nil (res )
@@ -115,7 +115,7 @@ describe("basic-auth: (vault integration)", function()
115115
116116 local username_res , username_err = get (" {vault://env/auth_username}" )
117117 local password_res , password_err = get (" {vault://env/auth_password}" )
118-
118+
119119 assert .is_nil (username_err )
120120 assert .is_nil (password_err )
121121 assert .equal (" vault_user_both" , username_res )
@@ -148,10 +148,12 @@ describe("basic-auth: (vault integration)", function()
148148
149149 it (" should preserve non-vault values unchanged" , function ()
150150 local regular_value = " regular_password"
151-
151+
152152 local res , err = get (regular_value )
153153 if res then
154154 assert .equal (regular_value , res )
155+ else
156+ assert .is_nil (err )
155157 end
156158 end )
157159
@@ -173,10 +175,10 @@ describe("basic-auth: (vault integration)", function()
173175 end )
174176
175177 describe (" integration with basic-auth plugin" , function ()
176- it (" should demonstrate vault usage in basic-auth context" , function ()
178+ it (" should demonstrate vault usage in basic-auth context" , function ()
177179 local password_env = " BASIC_AUTH_PASSWORD"
178180 local username_env = " BASIC_AUTH_USERNAME"
179-
181+
180182 finally (function ()
181183 helpers .unsetenv (password_env )
182184 helpers .unsetenv (username_env )
@@ -195,4 +197,5 @@ describe("basic-auth: (vault integration)", function()
195197 assert .equal (" secure_username" , resolved_username )
196198 end )
197199 end )
198- end )
200+ end )
201+
0 commit comments