diff --git a/src/lua/box_net_box.lua b/src/lua/box_net_box.lua index 8ad1dbc1a182d90eb12bc2abd720f247eef30ea7..d1dfc63282a9d897816d215ad27e9e02b61bd0f2 100644 --- a/src/lua/box_net_box.lua +++ b/src/lua/box_net_box.lua @@ -351,10 +351,21 @@ local remote_methods = { self.host = host self.port = port self.opts = opts + if self.opts == nil then self.opts = {} end + if self.opts.user ~= nil and self.opts.password == nil then + box.error(box.error.PROC_LUA, + "net.box: password is not defined") + end + if self.opts.user == nil and self.opts.password ~= nil then + box.error(box.error.PROC_LUA, + "net.box: user is not defined") + end + + if self.host == nil then self.host = 'localhost' end diff --git a/test/box/box.net.box.result b/test/box/box.net.box.result index c4f8a3adf0a2a2eceaf4c4382050764898a4f021..a5386968a643a84387b428e083c46197eade9fbd 100644 --- a/test/box/box.net.box.result +++ b/test/box/box.net.box.result @@ -573,3 +573,12 @@ cnc:call('123') --- - error: '[string "123()"]:1: unexpected symbol near ''123''' ... +-- #545 user or password is not defined +remote:new(LISTEN.host, LISTEN.service, { user = 'test' }) +--- +- error: 'net.box: password is not defined' +... +remote:new(LISTEN.host, LISTEN.service, { password = 'test' }) +--- +- error: 'net.box: user is not defined' +... diff --git a/test/box/box.net.box.test.lua b/test/box/box.net.box.test.lua index b3de500c8ae0d20e4321df1ffea5dd588ed00e3e..d7a57706955cdd751f84a816d480bb3ce7673864 100644 --- a/test/box/box.net.box.test.lua +++ b/test/box/box.net.box.test.lua @@ -223,3 +223,9 @@ cnc:call('console_unpack_test', 1) cn:call('123') cnc:call('123') + + +-- #545 user or password is not defined +remote:new(LISTEN.host, LISTEN.service, { user = 'test' }) +remote:new(LISTEN.host, LISTEN.service, { password = 'test' }) +