Skip to content

Commit 3f7d887

Browse files
author
ramk
committed
RANGER-5653: Trim GDS from 2.9 backport tests and README
GDS Python client is not on ranger-2.9; remove GDS tests, README sections, and cursor-rule references so unit tests run on 2.9.
1 parent b607475 commit 3f7d887

3 files changed

Lines changed: 7 additions & 112 deletions

File tree

.cursor/rules/ranger-python.mdc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,18 @@ Run from `intg/`:
7171
PYTHONPATH=src/main/python python -B src/test/python/test_ranger_client.py
7272
```
7373

74-
Split tests **by client** — one `unittest.TestCase` per area (`TestRangerClient`, `TestGDSClient`, `TestPDPClient`).
74+
Split tests **by client** — one `unittest.TestCase` per area (`TestRangerClient`, `TestPDPClient`).
7575

7676
Fixtures: shared data as **class-level constants** (`URL`, `AUTH`, `AUTHZ_REQUEST`); single-use data inline in the test method.
7777

7878
Assertions and mocking:
7979

8080
- Prefer `assertRaises`, `assertIsNone`, `assertIsInstance` over bare `try/except`.
8181
- Assert **current** client behavior — not obsolete error text or exceptions.
82-
- Mock at the boundary: `Session` for Admin HTTP, `client_http.call_api` for GDS/PDP.
82+
- Mock at the boundary: `Session` for Admin HTTP, `client_http.call_api` for PDP.
8383
- Only add tests for real coercion, exports, or API wiring.
8484

8585
## References
8686

8787
- `intg/src/main/python/README.md` — published API surface and quickstarts
88-
- `ranger-examples/sample-client/src/main/python/` — Admin, GDS, PDP, KMS usage examples
88+
- `ranger-examples/sample-client/src/main/python/` — Admin, PDP, KMS usage examples

intg/src/main/python/README.md

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ under the License.
2121

2222
`apache-ranger` is the official Python client package for Apache Ranger.
2323
It provides typed helpers for Ranger Admin, user/group management, KMS,
24-
Governed Data Sharing (GDS), and Policy Decision Point (PDP) APIs.
24+
and Policy Decision Point (PDP) APIs.
2525

2626
## Requirements
2727

@@ -54,8 +54,6 @@ python -m pip show apache-ranger
5454
roles, security zones, plugin information, and policy delta maintenance.
5555
- `RangerUserMgmtClient`: user, group, and user-group management APIs.
5656
- `RangerKMSClient`: Ranger KMS key management APIs.
57-
- `RangerGdsClient`: Governed Data Sharing APIs for datasets, projects,
58-
datashares, shared resources, and GDS policies.
5957
- `RangerPDPClient`: PDP authorization APIs for single authorization, batch
6058
authorization, and effective resource permissions.
6159

@@ -99,19 +97,6 @@ kms = RangerKMSClient("http://localhost:9292", HadoopSimpleAuth("keyadmin"))
9997
print(kms.kms_status())
10098
```
10199

102-
### Governed Data Sharing
103-
104-
```python
105-
from apache_ranger.client.ranger_client import RangerClient
106-
from apache_ranger.client.ranger_gds_client import RangerGdsClient
107-
108-
ranger = RangerClient("http://localhost:6080", ("admin", "rangerR0cks!"))
109-
gds = RangerGdsClient(ranger)
110-
111-
datasets = gds.find_datasets()
112-
print(f"{len(datasets.list)} datasets found")
113-
```
114-
115100
### Policy Decision Point
116101

117102
```python
@@ -193,8 +178,8 @@ returns `403 FORBIDDEN`.
193178
## Examples and Code References
194179

195180
The quick starts above cover the basics. For day-to-day API usage — creating
196-
services and policies, managing users, calling KMS or PDP, or working with GDS
197-
— use the runnable samples and client sources below.
181+
services and policies, managing users, or calling KMS or PDP — use the runnable
182+
samples and client sources below.
198183

199184
### Running sample scripts
200185

@@ -224,7 +209,6 @@ of each sample before running it against your environment.
224209
| User and group management | [`user_mgmt.py`](https://github.com/apache/ranger/blob/master/ranger-examples/sample-client/src/main/python/user_mgmt.py) | List/create/delete users and groups, group-user mappings |
225210
| Ranger KMS | [`sample_kms_client.py`](https://github.com/apache/ranger/blob/master/ranger-examples/sample-client/src/main/python/sample_kms_client.py) | Key lifecycle, encrypt/decrypt/reencrypt, metadata and status |
226211
| PDP AuthZ | [`sample_pdp_client.py`](https://github.com/apache/ranger/blob/master/ranger-examples/sample-client/src/main/python/sample_pdp_client.py) | Authz/MultiAuthz calls to PDP Server |
227-
| Governed Data Sharing (GDS) | [`sample_gds_client.py`](https://github.com/apache/ranger/blob/master/ranger-examples/sample-client/src/main/python/sample_gds_client.py) | Projects, datasets, datashares, shared resources, GDS policies |
228212
| Security zones (v2) | [`security_zone_v2.py`](https://github.com/apache/ranger/blob/master/ranger-examples/sample-client/src/main/python/security_zone_v2.py) | Create/update security zones and zone resources |
229213

230214
All samples live under
@@ -240,7 +224,6 @@ Each public client is implemented under
240224
| `RangerClient` | [`ranger_client.py`](https://github.com/apache/ranger/blob/master/intg/src/main/python/apache_ranger/client/ranger_client.py) | `service/public/v2/api` |
241225
| `RangerUserMgmtClient` | [`ranger_user_mgmt_client.py`](https://github.com/apache/ranger/blob/master/intg/src/main/python/apache_ranger/client/ranger_user_mgmt_client.py) | user/group APIs on Ranger Admin |
242226
| `RangerKMSClient` | [`ranger_kms_client.py`](https://github.com/apache/ranger/blob/master/intg/src/main/python/apache_ranger/client/ranger_kms_client.py) | KMS REST APIs |
243-
| `RangerGdsClient` | [`ranger_gds_client.py`](https://github.com/apache/ranger/blob/master/intg/src/main/python/apache_ranger/client/ranger_gds_client.py) | GDS APIs on Ranger Admin |
244227
| `RangerPDPClient` | [`ranger_pdp_client.py`](https://github.com/apache/ranger/blob/master/intg/src/main/python/apache_ranger/client/ranger_pdp_client.py) | `/authz/v1` |
245228

246229
Request and response models are under
@@ -249,7 +232,7 @@ Request and response models are under
249232
### Unit tests
250233

251234
[`intg/src/test/python/test_ranger_client.py`](https://github.com/apache/ranger/blob/master/intg/src/test/python/test_ranger_client.py)
252-
contains mocked examples for Admin, GDS, and PDP client wiring. Run from
235+
contains mocked examples for Admin and PDP client wiring. Run from
253236
`intg/`:
254237

255238
```bash
@@ -272,8 +255,6 @@ PYTHONPATH=src/main/python python -B src/test/python/test_ranger_client.py
272255
## Release 0.0.13 Highlights
273256

274257
- Python 3.13+ support.
275-
- New GDS client coverage for datasets, projects, datashares, shared resources,
276-
and GDS policy APIs.
277258
- New PDP client coverage for Ranger authorization APIs.
278259
- New authorization request and response models.
279260
- User/group management, KMS, Ranger Admin, and model updates.

intg/src/test/python/test_ranger_client.py

Lines changed: 0 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,11 @@
2828
import apache_ranger.model as ranger_model_package
2929

3030
from apache_ranger.client.ranger_client import API, HttpMethod, HTTPStatus, RangerClient
31-
from apache_ranger.client.ranger_gds_client import RangerGdsClient
3231
from apache_ranger.client.ranger_pdp_client import RangerPDPClient
3332
from apache_ranger.model.ranger_authz import (
3433
RangerAccessContext, RangerAccessInfo, RangerAuthzRequest, RangerAuthzResult,
3534
RangerPermissionResult, RangerResourceInfo, RangerResultInfo, RangerUserInfo,
3635
)
37-
from apache_ranger.model.ranger_gds import (
38-
DatasetSummary, GdsPermission, GdsShareStatus, RangerDataset,
39-
RangerGdsMaskInfo, RangerGdsObjectACL,
40-
)
41-
from apache_ranger.model.ranger_principal import PrincipalType
4236
except ModuleNotFoundError: # requests not installed
4337
exit() # skipping unit tests
4438

@@ -109,86 +103,6 @@ def test_url_invalid_format(self):
109103
API("{}test{}path{}", HttpMethod.GET, HTTPStatus.OK).format_path({'1', '2'})
110104

111105

112-
class TestGDSClient(unittest.TestCase):
113-
def test_package_export(self):
114-
self.assertIs(ranger_client_package.RangerGdsClient, RangerGdsClient)
115-
self.assertIn("RangerGdsClient", ranger_client_package.__all__)
116-
117-
def test_dataset_type_coercion(self):
118-
dataset = RangerDataset({
119-
"name": "sales",
120-
"acl": {
121-
"public": {
122-
"users": {
123-
"alice": "VIEW",
124-
},
125-
"groups": {
126-
"analytics": "POLICY_ADMIN",
127-
},
128-
},
129-
},
130-
})
131-
132-
dataset.type_coerce_attrs()
133-
134-
acl = dataset.acl["public"]
135-
self.assertIsInstance(acl, RangerGdsObjectACL)
136-
self.assertEqual(GdsPermission.VIEW, acl.users["alice"])
137-
self.assertEqual(GdsPermission.POLICY_ADMIN, acl.groups["analytics"])
138-
139-
def test_dataset_summary_type_coercion(self):
140-
summary = DatasetSummary({
141-
"name": "sales",
142-
"permissionForCaller": "VIEW",
143-
"principalsCount": {
144-
"USER": 2,
145-
"GROUP": 1,
146-
},
147-
"dataShares": [{
148-
"name": "sales-share",
149-
"shareStatus": "ACTIVE",
150-
}],
151-
})
152-
153-
summary.type_coerce_attrs()
154-
155-
self.assertEqual(GdsPermission.VIEW, summary.permissionForCaller)
156-
self.assertEqual(2, summary.principalsCount[PrincipalType.USER])
157-
self.assertEqual(GdsShareStatus.ACTIVE, summary.dataShares[0].shareStatus)
158-
159-
def test_mask_info_type_coercion(self):
160-
mask_info = RangerGdsMaskInfo({
161-
"values": ["email"],
162-
"maskInfo": {
163-
"dataMaskType": "MASK_HASH",
164-
"valueExpr": "hash(email)",
165-
},
166-
})
167-
168-
mask_info.type_coerce_attrs()
169-
170-
self.assertEqual(["email"], mask_info.values)
171-
self.assertEqual("MASK_HASH", mask_info.maskInfo.dataMaskType)
172-
173-
def test_find_datasets_calls_expected_api(self):
174-
ranger_client = Mock()
175-
ranger_client.client_http.call_api.return_value = {
176-
"list": [{
177-
"id": 1,
178-
"name": "sales",
179-
}],
180-
}
181-
182-
result = RangerGdsClient(ranger_client).find_datasets({"name": "sales"})
183-
184-
ranger_client.client_http.call_api.assert_called_once_with(
185-
RangerGdsClient.FIND_DATASETS,
186-
{"name": "sales"},
187-
)
188-
self.assertEqual(1, len(result.list))
189-
self.assertIsInstance(result.list[0], RangerDataset)
190-
191-
192106
class TestPDPClient(unittest.TestCase):
193107
PDP_URL = "http://localhost:6500"
194108
AUTHZ_REQUEST = {

0 commit comments

Comments
 (0)