fix conf authenticate all

This commit is contained in:
Kay0u 2020-01-02 12:31:08 +08:00
parent 94ccd9b05c
commit ce5d7ddaf0
No known key found for this signature in database
GPG key ID: 7FF262C033518333
2 changed files with 9 additions and 6 deletions

View file

@ -245,8 +245,11 @@ class BaseActionsMapParser(object):
elif ifaces is False:
conf["authenticate"] = False
elif isinstance(ifaces, list):
# Store only if authentication is needed
conf["authenticate"] = True if self.interface in ifaces else False
if "all" in ifaces:
conf["authenticate"] = "all"
else:
# Store only if authentication is needed
conf["authenticate"] = True if self.interface in ifaces else False
else:
logger.error(
"expecting 'all', 'False' or a list for "

View file

@ -221,7 +221,7 @@ def test_actions_map_api():
amap = ActionsMap(ActionsMapParser, use_cache=False)
assert amap.parser.global_conf['authenticate'] == False
assert amap.parser.global_conf['authenticate'] == "all"
assert 'default' in amap.parser.global_conf['authenticator']
assert 'yoloswag' in amap.parser.global_conf['authenticator']
assert ('GET', '/test-auth/default') in amap.parser.routes
@ -231,7 +231,7 @@ def test_actions_map_api():
amap = ActionsMap(ActionsMapParser, use_cache=True)
assert amap.parser.global_conf['authenticate'] == False
assert amap.parser.global_conf['authenticate'] == "all"
assert 'default' in amap.parser.global_conf['authenticator']
assert 'yoloswag' in amap.parser.global_conf['authenticator']
assert ('GET', '/test-auth/default') in amap.parser.routes
@ -266,7 +266,7 @@ def test_actions_map_cli():
)
amap = ActionsMap(ActionsMapParser, use_cache=False, parser_kwargs={'top_parser': parser})
assert amap.parser.global_conf['authenticate'] == False
assert amap.parser.global_conf['authenticate'] == "all"
assert 'default' in amap.parser.global_conf['authenticator']
assert 'yoloswag' in amap.parser.global_conf['authenticator']
assert 'testauth' in amap.parser._subparsers.choices
@ -278,7 +278,7 @@ def test_actions_map_cli():
amap = ActionsMap(ActionsMapParser, use_cache=True, parser_kwargs={'top_parser': parser})
assert amap.parser.global_conf['authenticate'] == False
assert amap.parser.global_conf['authenticate'] == "all"
assert 'default' in amap.parser.global_conf['authenticator']
assert 'yoloswag' in amap.parser.global_conf['authenticator']
assert 'testauth' in amap.parser._subparsers.choices