diff --git a/aos/utils.py b/aos/utils.py index 3dd3d96..f747f17 100644 --- a/aos/utils.py +++ b/aos/utils.py @@ -8,7 +8,7 @@ def redacted(d): - if d is None: + if d is None or d == '': return d h = d.copy() diff --git a/setup.py b/setup.py index c96da54..972e2b0 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ NAME = "aos-api-client" -VERSION = '0.1.9' +VERSION = '0.1.10' REQUIRES = (["requests==2.24.0"],) diff --git a/tests/test_utils.py b/tests/test_utils.py new file mode 100644 index 0000000..0558de4 --- /dev/null +++ b/tests/test_utils.py @@ -0,0 +1,28 @@ + +# Copyright 2020-present, Apstra, Inc. All rights reserved. +# +# This source code is licensed under End User License Agreement found in the +# LICENSE file at http://www.apstra.com/eula +# pylint: disable=redefined-outer-name + +from aos.utils import redacted + + +def test_redacted_null(): + assert redacted(None) is None + + +def test_redacted_empty(): + assert redacted('') == '' + + +def test_redacted_sensitive(): + for sensitive in ["password", "token", "AuthToken"]: + d = { + 'usual': 'usual data', + sensitive: '{sensitive} data', + } + assert redacted(d) == { + 'usual': 'usual data', + sensitive: '', + }