From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id 79C2121A96 for ; Fri, 22 Jun 2018 18:11:57 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iZbmYQ4pkbRm for ; Fri, 22 Jun 2018 18:11:57 -0400 (EDT) Received: from smtp57.i.mail.ru (smtp57.i.mail.ru [217.69.128.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 2CA3B21A8D for ; Fri, 22 Jun 2018 18:11:57 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH 1/3] Do not force login/pass in URI References: From: Vladislav Shpilevoy Message-ID: Date: Sat, 23 Jun 2018 01:11:54 +0300 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-subscribe: List-owner: List-post: List-archive: To: tarantool-patches@freelists.org, AKhatskevich Hello. Thanks for the patch! See 3 comments below. On 23/06/2018 00:43, AKhatskevich wrote: > All access rights would be checked explicitly by Tarantool. > > Closes #47 > --- > test/unit/config.result | 14 ++++++++++++++ > test/unit/config.test.lua | 6 ++++++ > vshard/cfg.lua | 7 +++---- > 3 files changed, 23 insertions(+), 4 deletions(-) > > diff --git a/test/unit/config.result b/test/unit/config.result > index 6b4f87b..847536c 100644 > --- a/test/unit/config.result > +++ b/test/unit/config.result > @@ -506,3 +506,17 @@ _ = lcfg.check(cfg) > replica.name = 'storage' > --- > ... > +-- gh-47: Check uri > +_, err = pcall(lcfg.check_uri, 'invalid uri') > +--- > +... > +err:match('Invalid URI.*') 1. Please, use util.check_error instead of pcall + match as I told you earlier. > diff --git a/vshard/cfg.lua b/vshard/cfg.lua > index f5db4c0..5644d2c 100644 > --- a/vshard/cfg.lua > +++ b/vshard/cfg.lua > @@ -5,10 +5,8 @@ local luri = require('uri') > local consts = require('vshard.consts') > > local function check_uri(uri) > - uri = luri.parse(uri) > - if uri.login == nil or uri.password == nil then > - error('URI must contain login and password') > - end > + local parsed = luri.parse(uri) > + assert(parsed, 'Invalid URI: ' .. uri) 2. Please, do not assertions for regular errors. Use 'error()'. > end > > local function check_master(master, ctx) > @@ -251,5 +249,6 @@ end > > return { > check = cfg_check, > + check_uri = check_uri, 3. Do not expose this one-line function for testing only. Just use cfg.check for this corrupting an uri of a replica in cfg. And restore back after the test. > remove_non_box_options = remove_non_box_options, > } >