Parse authentication credentials.
(
username: str, password: str, database: Optional[str], options: Mapping[str, Any]
)
| 45 | |
| 46 | |
| 47 | def _parse_credentials( |
| 48 | username: str, password: str, database: Optional[str], options: Mapping[str, Any] |
| 49 | ) -> Optional[MongoCredential]: |
| 50 | """Parse authentication credentials.""" |
| 51 | mechanism = options.get("authmechanism", "DEFAULT" if username else None) |
| 52 | source = options.get("authsource") |
| 53 | if username or mechanism: |
| 54 | from pymongo.auth_shared import _build_credentials_tuple |
| 55 | |
| 56 | return _build_credentials_tuple(mechanism, source, username, password, options, database) |
| 57 | return None |
| 58 | |
| 59 | |
| 60 | def _parse_read_preference(options: Mapping[str, Any]) -> _ServerMode: |
no test coverage detected