From ce3d565fc67660959e613ab3a4199c805bfeef40 Mon Sep 17 00:00:00 2001
From: "Dmitry E. Oboukhov" <unera@debian.org>
Date: Wed, 1 Oct 2014 14:29:30 +0400
Subject: [PATCH] net.box requires define password AND user. closes #545

---
 src/lua/box_net_box.lua       | 11 +++++++++++
 test/box/box.net.box.result   |  9 +++++++++
 test/box/box.net.box.test.lua |  6 ++++++
 3 files changed, 26 insertions(+)

diff --git a/src/lua/box_net_box.lua b/src/lua/box_net_box.lua
index 8ad1dbc1a1..d1dfc63282 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 c4f8a3adf0..a5386968a6 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 b3de500c8a..d7a5770695 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' })
+
-- 
GitLab