Agent: Extract _get_*() functions from get_auth_options()

This commit is contained in:
Mike Salvatore 2021-09-17 11:35:29 -04:00
parent 444fb90f93
commit 79aacf3dcb
1 changed files with 16 additions and 4 deletions

View File

@ -16,9 +16,21 @@ class AuthOptions:
def get_auth_options(credentials: Credentials, use_ssl: bool) -> AuthOptions:
# Passwordless login only works with SSL false, AUTH_BASIC and ENCRYPTION_NEVER
ssl = False if credentials.secret == "" else use_ssl
auth_type = AUTH_BASIC if credentials.secret == "" else AUTH_NEGOTIATE
encryption = ENCRYPTION_NEVER if credentials.secret == "" else ENCRYPTION_AUTO
ssl = _get_ssl(credentials, use_ssl)
auth_type = _get_auth_type(credentials)
encryption = _get_encryption(credentials)
return AuthOptions(auth_type, encryption, ssl)
def _get_ssl(credentials: Credentials, use_ssl):
# Passwordless login only works with SSL false, AUTH_BASIC and ENCRYPTION_NEVER
return False if credentials.secret == "" else use_ssl
def _get_auth_type(credentials: Credentials):
return AUTH_BASIC if credentials.secret == "" else AUTH_NEGOTIATE
def _get_encryption(credentials: Credentials):
return ENCRYPTION_NEVER if credentials.secret == "" else ENCRYPTION_AUTO