PasswordAuthenticator instance.
(self,
username, # type: str
password, # type: str
cert_path=None, # type: Optional[str]
**kwargs # type: Dict[str, Any]
)
| 38 | """ |
| 39 | |
| 40 | def __init__(self, |
| 41 | username, # type: str |
| 42 | password, # type: str |
| 43 | cert_path=None, # type: Optional[str] |
| 44 | **kwargs # type: Dict[str, Any] |
| 45 | ): |
| 46 | """PasswordAuthenticator instance.""" |
| 47 | if not isinstance(username, str): |
| 48 | msg = 'The username must be a str.' |
| 49 | raise InvalidArgumentException(msg) |
| 50 | |
| 51 | if not isinstance(password, str): |
| 52 | msg = 'The password must be a str.' |
| 53 | raise InvalidArgumentException(msg) |
| 54 | |
| 55 | if cert_path is not None and not isinstance(cert_path, str): |
| 56 | msg = 'The cert_path must be a str representing the path to the certificate trust store.' |
| 57 | raise InvalidArgumentException(msg) |
| 58 | |
| 59 | allowed_sasl_mechanisms = kwargs.pop('allowed_sasl_mechanisms', None) |
| 60 | if allowed_sasl_mechanisms is not None: |
| 61 | msg = None |
| 62 | if isinstance(allowed_sasl_mechanisms, str): |
| 63 | allowed_sasl_mechanisms = allowed_sasl_mechanisms.split(',') |
| 64 | if isinstance(allowed_sasl_mechanisms, list): |
| 65 | if not all(map(lambda x: isinstance(x, str), allowed_sasl_mechanisms)): |
| 66 | msg = 'The allowed_sasl_mechanisms must be a list of str SASL mechanisms.' |
| 67 | else: |
| 68 | msg = ('The allowed_sasl_mechanisms must be a list of str SASL mechanisms ' |
| 69 | ' or a comma separated str of SASL mechanisms.') |
| 70 | if msg: |
| 71 | raise InvalidArgumentException(msg) |
| 72 | |
| 73 | self._username = username |
| 74 | self._password = password |
| 75 | self._cert_path = cert_path |
| 76 | self._allowed_sasl_mechanisms = allowed_sasl_mechanisms |
| 77 | |
| 78 | super().__init__(**self.as_dict()) |
| 79 | |
| 80 | def valid_keys(self): |
| 81 | return ['username', 'password', 'cert_path', 'sasl_mech_force', 'allowed_sasl_mechanisms'] |
nothing calls this directly
no test coverage detected