Coverage for manila/policies/share_access.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2026-02-18 22:19 +0000

1# Copyright 2018 Huawei Corporation. 

2# All Rights Reserved. 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); you may 

5# not use this file except in compliance with the License. You may obtain 

6# a copy of the License at 

7# 

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

9# 

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

11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 

12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 

13# License for the specific language governing permissions and limitations 

14# under the License. 

15 

16from oslo_log import versionutils 

17from oslo_policy import policy 

18 

19from manila.policies import base 

20 

21 

22BASE_POLICY_NAME = 'share_access_rule:%s' 

23 

24DEPRECATED_REASON = """ 

25The share access rule API now supports scope and default roles. 

26""" 

27 

28deprecated_access_rule_get = policy.DeprecatedRule( 

29 name=BASE_POLICY_NAME % 'get', 

30 check_str=base.RULE_DEFAULT, 

31 deprecated_reason=DEPRECATED_REASON, 

32 deprecated_since=versionutils.deprecated.WALLABY 

33) 

34deprecated_access_rule_index = policy.DeprecatedRule( 

35 name=BASE_POLICY_NAME % 'index', 

36 check_str=base.RULE_DEFAULT, 

37 deprecated_reason=DEPRECATED_REASON, 

38 deprecated_since=versionutils.deprecated.WALLABY 

39) 

40deprecated_access_rule_update = policy.DeprecatedRule( 

41 name=BASE_POLICY_NAME % 'update', 

42 check_str=base.RULE_DEFAULT, 

43 deprecated_reason=DEPRECATED_REASON, 

44 deprecated_since='2025.1/Epoxy' 

45) 

46 

47 

48share_access_rule_policies = [ 

49 policy.DocumentedRuleDefault( 

50 name=BASE_POLICY_NAME % 'get', 

51 check_str=base.ADMIN_OR_PROJECT_READER, 

52 scope_types=['project'], 

53 description="Get details of a share access rule.", 

54 operations=[ 

55 { 

56 'method': 'GET', 

57 'path': '/share-access-rules/{share_access_id}' 

58 } 

59 ], 

60 deprecated_rule=deprecated_access_rule_get 

61 ), 

62 policy.DocumentedRuleDefault( 

63 name=BASE_POLICY_NAME % 'index', 

64 check_str=base.ADMIN_OR_PROJECT_READER, 

65 scope_types=['project'], 

66 description="List access rules of a given share.", 

67 operations=[ 

68 { 

69 'method': 'GET', 

70 'path': ('/share-access-rules?share_id={share_id}' 

71 '&key1=value1&key2=value2') 

72 } 

73 ], 

74 deprecated_rule=deprecated_access_rule_index 

75 ), 

76 policy.DocumentedRuleDefault( 

77 name=BASE_POLICY_NAME % 'update', 

78 check_str=base.ADMIN_OR_PROJECT_MEMBER, 

79 scope_types=['project'], 

80 description="Update access rules of a given share.", 

81 operations=[ 

82 { 

83 'method': 'PUT', 

84 'path': '/share-access-rules/{share_access_id}' 

85 } 

86 ], 

87 deprecated_rule=deprecated_access_rule_update 

88 ), 

89] 

90 

91 

92def list_rules(): 

93 return share_access_rule_policies