[tarantool-patches] Re: [PATCH 1/3] Do not force login/pass in URI

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Sat Jun 23 01:11:54 MSK 2018


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,
>   }
> 




More information about the Tarantool-patches mailing list