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 0C7BE24A6A for ; Mon, 25 Jun 2018 17:56:48 -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 ZJPg44qHU4LM for ; Mon, 25 Jun 2018 17:56:47 -0400 (EDT) Received: from smtp5.mail.ru (smtp5.mail.ru [94.100.179.24]) (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 BF83924A1C for ; Mon, 25 Jun 2018 17:56:47 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH 1/3] Do not force login/pass in URI References: From: Alex Khatskevich Message-ID: <4eece5c8-c487-c2b8-bcfb-0a3116559631@tarantool.org> Date: Tue, 26 Jun 2018 00:56:40 +0300 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 8bit Content-Language: en-US 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: Vladislav Shpilevoy , tarantool-patches@freelists.org >> >> 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. > done >> 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()'. done > >>   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. done