fix more tests and clang tidy build

This commit is contained in:
Sergei Trifonov 2022-09-08 17:43:09 +02:00
parent 35524d0175
commit 62541ab764
4 changed files with 17 additions and 17 deletions

View File

@ -50,11 +50,14 @@ void SettingsProfileElement::init(const ASTSettingsProfileElement & ast, const A
{
setting_name = ast.setting_name;
/// Optionally check if a setting with that name is allowed.
if (access_control)
{
/// Check if a setting with that name is allowed.
if (setting_name != ALLOW_BACKUP_SETTING_NAME)
access_control->checkSettingNameIsAllowed(setting_name);
/// Check if a CHANGEABLE_IN_READONLY is allowed.
if (ast.type == SettingConstraintType::CHANGEABLE_IN_READONLY && !access_control->doesSettingsConstraintsReplacePrevious())
throw Exception("CHANGEABLE_IN_READONLY for " + setting_name + " is not allowed unless settings_constraints_replace_previous is enabled", ErrorCodes::NOT_IMPLEMENTED);
}
value = ast.value;
@ -62,9 +65,6 @@ void SettingsProfileElement::init(const ASTSettingsProfileElement & ast, const A
max_value = ast.max_value;
type = ast.type;
if (type == SettingConstraintType::CHANGEABLE_IN_READONLY && !access_control->doesSettingsConstraintsReplacePrevious())
throw Exception("CHANGEABLE_IN_READONLY for " + setting_name + " is not allowed unless settings_constraints_replace_previous is enabled", ErrorCodes::NOT_IMPLEMENTED);
if (!value.isNull())
value = Settings::castValueUtil(setting_name, value);
if (!min_value.isNull())

View File

@ -1,7 +1,5 @@
#pragma once
#include <Core/Field.h>
namespace DB
{

View File

@ -102,6 +102,7 @@ def test_smoke():
110000000,
"\\N",
"\\N",
"\\N",
]
]
@ -148,7 +149,7 @@ def test_smoke():
)
)
assert system_settings_profile_elements(user_name="robin") == [
["\\N", "robin", "\\N", 0, "\\N", "\\N", "\\N", "\\N", "\\N", "xyz"]
["\\N", "robin", "\\N", 0, "\\N", "\\N", "\\N", "\\N", "\\N", "\\N", "xyz"]
]
instance.query("ALTER USER robin SETTINGS NONE")
@ -215,11 +216,12 @@ def test_settings_from_granted_role():
110000000,
"\\N",
"\\N",
"\\N",
],
["xyz", "\\N", "\\N", 1, "max_ast_depth", 2000, "\\N", "\\N", "\\N", "\\N"],
["xyz", "\\N", "\\N", 1, "max_ast_depth", 2000, "\\N", "\\N", "\\N", "\\N", "\\N"],
]
assert system_settings_profile_elements(role_name="worker") == [
["\\N", "\\N", "worker", 0, "\\N", "\\N", "\\N", "\\N", "\\N", "xyz"]
["\\N", "\\N", "worker", 0, "\\N", "\\N", "\\N", "\\N", "\\N", "\\N", "xyz"]
]
instance.query("REVOKE worker FROM robin")
@ -315,13 +317,13 @@ def test_inheritance():
["xyz", "local directory", 1, 0, "[]", "[]"]
]
assert system_settings_profile_elements(profile_name="xyz") == [
["xyz", "\\N", "\\N", 0, "max_memory_usage", 100000002, "\\N", "\\N", 1, "\\N"]
["xyz", "\\N", "\\N", 0, "max_memory_usage", 100000002, "\\N", "\\N", 1, "\\N", "\\N"]
]
assert system_settings_profile("alpha") == [
["alpha", "local directory", 1, 0, "['robin']", "[]"]
]
assert system_settings_profile_elements(profile_name="alpha") == [
["alpha", "\\N", "\\N", 0, "\\N", "\\N", "\\N", "\\N", "\\N", "xyz"]
["alpha", "\\N", "\\N", 0, "\\N", "\\N", "\\N", "\\N", "\\N", "\\N", "xyz"]
]
assert system_settings_profile_elements(user_name="robin") == []

View File

@ -109,9 +109,9 @@ u2_01292 local directory no_password {} [] [] [] ['%.%.myhost.com'] 0 [] []
u3_01292 local directory sha256_password {} ['192.169.1.1','192.168.0.0/16'] ['localhost'] [] [] 0 ['r1_01292'] []
u4_01292 local directory double_sha1_password {} ['::/0'] [] [] [] 1 [] ['r1_01292']
-- system.settings_profile_elements
\N u1_01292 \N 0 readonly 1 \N \N \N \N
\N u2_01292 \N 0 \N \N \N \N \N default
\N u3_01292 \N 0 max_memory_usage 5000000 4000000 6000000 0 \N
\N u4_01292 \N 0 \N \N \N \N \N default
\N u4_01292 \N 1 max_memory_usage 5000000 \N \N \N \N
\N u4_01292 \N 2 readonly 1 \N \N \N \N
\N u1_01292 \N 0 readonly 1 \N \N \N \N \N
\N u2_01292 \N 0 \N \N \N \N \N \N default
\N u3_01292 \N 0 max_memory_usage 5000000 4000000 6000000 0 \N \N
\N u4_01292 \N 0 \N \N \N \N \N \N default
\N u4_01292 \N 1 max_memory_usage 5000000 \N \N \N \N \N
\N u4_01292 \N 2 readonly 1 \N \N \N \N \N