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 406EF267C3 for ; Fri, 22 Jun 2018 17:43:59 -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 1FD-yn2ch33r for ; Fri, 22 Jun 2018 17:43:59 -0400 (EDT) Received: from smtp36.i.mail.ru (smtp36.i.mail.ru [94.100.177.96]) (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 7720B210A0 for ; Fri, 22 Jun 2018 17:43:58 -0400 (EDT) From: AKhatskevich Subject: [tarantool-patches] [PATCH 1/3] Do not force login/pass in URI Date: Sat, 23 Jun 2018 00:43:33 +0300 Message-Id: In-Reply-To: References: In-Reply-To: References: 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, v.shpilevoy@tarantool.org 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.*') +--- +- 'Invalid URI: invalid uri' +... +lcfg.check_uri('127.0.0.1') +--- +... +lcfg.check_uri('user:password@localhost') +--- +... diff --git a/test/unit/config.test.lua b/test/unit/config.test.lua index 0f549d3..af1dd7d 100644 --- a/test/unit/config.test.lua +++ b/test/unit/config.test.lua @@ -206,3 +206,9 @@ _ = lcfg.check(cfg) replica.name = nil _ = lcfg.check(cfg) replica.name = 'storage' + +-- gh-47: Check uri +_, err = pcall(lcfg.check_uri, 'invalid uri') +err:match('Invalid URI.*') +lcfg.check_uri('127.0.0.1') +lcfg.check_uri('user:password@localhost') 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) end local function check_master(master, ctx) @@ -251,5 +249,6 @@ end return { check = cfg_check, + check_uri = check_uri, remove_non_box_options = remove_non_box_options, } -- 2.14.1