From 2ef9d6552593ab5ffefda60e73b88372d02b6b70 Mon Sep 17 00:00:00 2001 From: ganglv <88995770+ganglyu@users.noreply.github.com> Date: Mon, 7 Mar 2022 13:05:46 +0800 Subject: [PATCH] [yang]: AAA login pattern (#9805) Signed-off-by: Gang Lv ganglv@microsoft.com #### Why I did it end2end test is blocked by Yang model for AAA login pattern. #### How I did it Add pattern to AAA yang models. #### How to verify it Run UT for sonc-yang-models. #### Which release branch to backport (provide reason below if selected) - [ ] 201811 - [ ] 201911 - [ ] 202006 - [ ] 202012 - [ ] 202106 #### Description for the changelog Fix #9713 #### A picture of a cute animal (not mandatory but encouraged) --- .../tests/yang_model_tests/tests/aaa.json | 4 ++++ .../tests/yang_model_tests/tests_config/aaa.json | 10 ++++++++++ .../yang-models/sonic-system-aaa.yang | 8 ++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests/aaa.json b/src/sonic-yang-models/tests/yang_model_tests/tests/aaa.json index dc3a60a24d..972b404b88 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests/aaa.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests/aaa.json @@ -6,6 +6,10 @@ "desc": "Configure a wrong type in AAA table.", "eStrKey": "InvalidValue" }, + "AAA_TEST_WRONG_LOGIN": { + "desc": "Configure a wrong type in AAA table.", + "eStr": ["Invalid login choice"] + }, "AAA_TEST_WRONG_FAILTHROUGH": { "desc": "Configure a wrong failthrough in AAA table.", "eStrKey": "Pattern", diff --git a/src/sonic-yang-models/tests/yang_model_tests/tests_config/aaa.json b/src/sonic-yang-models/tests/yang_model_tests/tests_config/aaa.json index 5b05fc3330..fbf63f994c 100644 --- a/src/sonic-yang-models/tests/yang_model_tests/tests_config/aaa.json +++ b/src/sonic-yang-models/tests/yang_model_tests/tests_config/aaa.json @@ -24,6 +24,16 @@ } }, + "AAA_TEST_WRONG_LOGIN": { + "sonic-system-aaa:sonic-system-aaa": { + "sonic-system-aaa:AAA": { + "AAA_LIST": [{ + "login": "locallll" + }] + } + } + }, + "AAA_TEST_WRONG_FAILTHROUGH": { "sonic-system-aaa:sonic-system-aaa": { "sonic-system-aaa:AAA": { diff --git a/src/sonic-yang-models/yang-models/sonic-system-aaa.yang b/src/sonic-yang-models/yang-models/sonic-system-aaa.yang index 5df05d475d..c3a4421269 100644 --- a/src/sonic-yang-models/yang-models/sonic-system-aaa.yang +++ b/src/sonic-yang-models/yang-models/sonic-system-aaa.yang @@ -30,8 +30,12 @@ module sonic-system-aaa { } leaf login { - type string; - description "AAA authentication/authorization/accounting methods - local/tacacs+/disable"; + type string { + pattern '((tacacs\+|local|radius|default),)*(tacacs\+|local|radius|default)' { + error-message "Invalid login choice"; + } + } + description "AAA authentication/authorization/accounting methods - radius/tacacs+/local/default"; default "local"; }