Coverage for /home/airflow/.local/lib/python3.12/site-packages/airflow/api_fastapi/auth/managers/simple/user.py: 68%

17 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 14:22 +0000

1# Licensed to the Apache Software Foundation (ASF) under one 

2# or more contributor license agreements. See the NOTICE file 

3# distributed with this work for additional information 

4# regarding copyright ownership. The ASF licenses this file 

5# to you under the Apache License, Version 2.0 (the 

6# "License"); you may not use this file except in compliance 

7# with the License. You may obtain a copy of the License at 

8# 

9# http://www.apache.org/licenses/LICENSE-2.0 

10# 

11# Unless required by applicable law or agreed to in writing, 

12# software distributed under the License is distributed on an 

13# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 

14# KIND, either express or implied. See the License for the 

15# specific language governing permissions and limitations 

16# under the License. 

17from __future__ import annotations 

18 

19from airflow.api_fastapi.auth.managers.models.base_user import BaseUser 

20 

21 

22class SimpleAuthManagerUser(BaseUser): 

23 """ 

24 User model for users managed by the simple auth manager. 

25 

26 :param username: The username 

27 :param role: The role associated to the user. If not provided, the user has no permission 

28 :param teams: The list of teams associated to the user 

29 """ 

30 

31 def __init__(self, *, username: str, role: str | None, teams: list[str] | None = None) -> None: 

32 self.username = username 

33 self.role = role 

34 self.teams = teams or [] 

35 

36 def get_id(self) -> str: 

37 return self.username 

38 

39 def get_name(self) -> str: 

40 return self.username 

41 

42 def __eq__(self, other): 

43 if not isinstance(other, SimpleAuthManagerUser): 

44 return False 

45 return self.username == other.username and self.role == other.role and self.teams == other.teams 

46 

47 def __hash__(self): 

48 return hash(self.username)