Coverage for mlos_bench/mlos_bench/tests/services/remote/mock/mock_auth_service.py: 85%
13 statements
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-06 00:35 +0000
« prev ^ index » next coverage.py v7.5.1, created at 2024-05-06 00:35 +0000
1#
2# Copyright (c) Microsoft Corporation.
3# Licensed under the MIT License.
4#
5"""
6A collection Service functions for mocking authentication.
7"""
9import logging
10from typing import Any, Callable, Dict, List, Optional, Union
12from mlos_bench.services.base_service import Service
13from mlos_bench.services.types.authenticator_type import SupportsAuth
15_LOG = logging.getLogger(__name__)
18class MockAuthService(Service, SupportsAuth):
19 """
20 A collection Service functions for mocking authentication ops.
21 """
23 def __init__(self, config: Optional[Dict[str, Any]] = None,
24 global_config: Optional[Dict[str, Any]] = None,
25 parent: Optional[Service] = None,
26 methods: Union[Dict[str, Callable], List[Callable], None] = None):
27 super().__init__(
28 config, global_config, parent,
29 self.merge_methods(methods, [
30 self.get_access_token,
31 self.get_auth_headers,
32 ])
33 )
35 def get_access_token(self) -> str:
36 return "TOKEN"
38 def get_auth_headers(self) -> dict:
39 return {"Authorization": "Bearer " + self.get_access_token()}