From 01385109366e5aa35be082cbe576ed48fe69b83d Mon Sep 17 00:00:00 2001 From: Aaron Tan Date: Fri, 7 Jul 2017 11:44:56 -0400 Subject: [PATCH] Strengthen attribute check for Tower configuration validations --- awx/main/conf.py | 4 +++- awx/sso/conf.py | 4 +++- docs/tower_configuration.md | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/awx/main/conf.py b/awx/main/conf.py index 4e8e637eab..3f9a25a599 100644 --- a/awx/main/conf.py +++ b/awx/main/conf.py @@ -446,7 +446,9 @@ register( def logging_validate(serializer, attrs): - if not serializer.instance: + if not serializer.instance or \ + not hasattr(serializer.instance, 'LOG_AGGREGATOR_HOST') or \ + not hasattr(serializer.instance, 'LOG_AGGREGATOR_TYPE'): return attrs errors = [] if attrs.get('LOG_AGGREGATOR_ENABLED', False): diff --git a/awx/sso/conf.py b/awx/sso/conf.py index f717869e7e..97648668f8 100644 --- a/awx/sso/conf.py +++ b/awx/sso/conf.py @@ -1089,7 +1089,9 @@ register( def tacacs_validate(serializer, attrs): - if not serializer.instance: + if not serializer.instance or \ + not hasattr(serializer.instance, 'TACACSPLUS_HOST') or \ + not hasattr(serializer.instance, 'TACACSPLUS_SECRET'): return attrs errors = [] host = serializer.instance.TACACSPLUS_HOST diff --git a/docs/tower_configuration.md b/docs/tower_configuration.md index 268527a9aa..ca5fdfee8c 100644 --- a/docs/tower_configuration.md +++ b/docs/tower_configuration.md @@ -108,3 +108,5 @@ register_validate("category_a", validate_a) register_validate("category_b", validate_b) ... ``` + +It should be noted that each validation function will be invoked in two places: when updating the category it's responsible for and when updating the general category `all`. Always keep this fact in mind and test both situations when developing new validation functions.