Skip to content

Commit fdaa2f3

Browse files
committed
improve error messages
Signed-off-by: hwassman <[email protected]>
1 parent 2765002 commit fdaa2f3

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

source/confParser.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def checkTLSsettings(args):
4242
args.get('tlsKeyFile') or not
4343
args.get('tlsCertFile')
4444
):
45-
return False, MSG['MissingParm']
45+
return False, MSG['MissingSSLCert']
4646
elif args.get('protocol') == "https" and not os.path.exists(args.get('tlsKeyPath')):
4747
return False, MSG['KeyPathError']
4848
elif args.get('protocol') == "https":
@@ -58,16 +58,16 @@ def checkBasicAuthsettings(args):
5858
if args.get('enabled') and (not args.get('username') or not
5959
args.get('password')
6060
):
61-
return False, MSG['MissingParm']
61+
return False, MSG['MissingBasicAuthSettings']
6262
elif args.get('enabled') and ("/" in str(args.get('password')) and not
6363
os.path.isfile(args.get('password'))
6464
):
65-
return False, MSG['PathNotFound'].format("basic auth settings")
65+
return False, MSG['PathNotFound'].format("basic authentication settings")
6666
elif args.get('enabled') and "/" not in str(args.get('password')):
6767
try:
6868
base64.b64decode(args.get('password'), validate=True)
6969
except binascii.Error:
70-
return False, MSG['WrongFormat'].format("basic auth password")
70+
return False, MSG['WrongFormat'].format("basic authentication settings")
7171
return True, ''
7272

7373

@@ -79,9 +79,9 @@ def checkApplicationPort(args):
7979

8080
def checkAPIsettings(args):
8181
if not args.get('apiKeyName') or not args.get('apiKeyValue'):
82-
return False, MSG['MissingParm']
82+
return False, MSG['MissingApiKeySettings']
8383
elif "/" in str(args.get('apiKeyValue')) and not os.path.isfile(args.get('apiKeyValue')):
84-
return False, MSG['PathNotFound'].format("api key settings")
84+
return False, MSG['PathNotFound'].format("ApiKey settings")
8585
return True, ''
8686

8787

source/confgenerator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ def generate_config(self):
100100
self.attr.get('username', False)
101101
and self.attr.get('password', False)
102102
):
103-
self.logger.error(MSG['MissingParm'])
104-
return MSG['MissingParm']
103+
self.logger.error(MSG['MissingBasicAuthSettings'])
104+
return MSG['MissingBasicAuthSettings']
105105
basic_auth = {"username": self.attr.get('username')}
106106
if os.path.isfile(self.attr.get('password')):
107107
pw = {"password_file": self.attr.get('password')}

source/messages.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@
2828
MSG = {'IntError': 'Server internal error occurred. Reason: {}',
2929
'sysStart': 'Initial cherryPy server engine start have been invoked. Python version: {}, cherryPy version: {}.',
3030
'MissingParm': 'Missing mandatory parameters, quitting',
31+
'MissingApiKeySettings': 'Missing mandatory ApiKey settings, quitting',
3132
'MissingPortParam': 'Missing applications port configuration, quitting',
32-
'MissingSSLCert': 'Missing ssl configuration, quitting',
33+
'MissingSSLCert': 'Missing ssl configuration settings, quitting',
34+
'MissingBasicAuthSettings': 'Missing basic authentication settings, quitting',
3335
'KeyPathError': 'KeyPath directory not found, quitting',
3436
'MissingFileFromPathError': 'Missing certificates in the specified keyPath directory, quitting',
3537
'CollectorErr': 'Failed to initialize connection to pmcollector: {}, quitting',
@@ -85,5 +87,5 @@
8587
'MetricNotInResults': 'Metric {} is not in Collector.metrcs',
8688
'ConnApplications': 'Registered applications: \n {}',
8789
'WrongFormat': 'The {} specified in wrong format.',
88-
'AuthValidationError': 'Basic auth data not valid'
90+
'AuthValidationError': 'Basic authentication data not valid'
8991
}

0 commit comments

Comments
 (0)