Skip to content

Commit 22317a4

Browse files
committed
[#11094] fix(client-python): address review feedback for Group auth
- Remove test_builder_no_audit_raises to match relaxed GroupDTO builder - Add unit test for GroupAddRequest - Add serviceAdmins config in group integration test
1 parent 13eba3e commit 22317a4

3 files changed

Lines changed: 49 additions & 11 deletions

File tree

clients/client-python/tests/integration/test_group_management.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ class TestGroupManagement(IntegrationTestEnv):
3838
def setUpClass(cls):
3939
cls._get_gravitino_home()
4040
conf_path = os.path.join(cls.gravitino_home, "conf", "gravitino.conf")
41-
cls._reset_conf(
42-
{"gravitino.authorization.enable": "true"}, conf_path
43-
)
44-
cls._append_conf(
45-
{"gravitino.authorization.enable": "true"}, conf_path
46-
)
41+
auth_confs = {
42+
"gravitino.authorization.enable": "true",
43+
"gravitino.authorization.serviceAdmins": "anonymous",
44+
}
45+
cls._reset_conf(auth_confs, conf_path)
46+
cls._append_conf(auth_confs, conf_path)
4747
if (
4848
os.environ.get("START_EXTERNAL_GRAVITINO") is not None
4949
and os.environ.get("START_EXTERNAL_GRAVITINO").lower() == "true"
@@ -59,7 +59,11 @@ def setUpClass(cls):
5959
def tearDownClass(cls):
6060
conf_path = os.path.join(cls.gravitino_home, "conf", "gravitino.conf")
6161
cls._reset_conf(
62-
{"gravitino.authorization.enable": "false"}, conf_path
62+
{
63+
"gravitino.authorization.enable": "false",
64+
"gravitino.authorization.serviceAdmins": "",
65+
},
66+
conf_path,
6367
)
6468
if (
6569
os.environ.get("START_EXTERNAL_GRAVITINO") is not None
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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.
17+
from __future__ import annotations
18+
19+
import json as _json
20+
import unittest
21+
22+
from gravitino.dto.requests.group_add_request import GroupAddRequest
23+
24+
25+
class TestGroupAddRequest(unittest.TestCase):
26+
def test_group_add_request_serde(self) -> None:
27+
group_add_request = GroupAddRequest(_name="group1")
28+
ser_json = _json.dumps(group_add_request.to_dict())
29+
deser_dict = _json.loads(ser_json)
30+
31+
self.assertEqual("group1", deser_dict["name"])
32+
33+
def test_group_add_request_validate(self) -> None:
34+
group_add_request = GroupAddRequest(_name="group1")
35+
group_add_request.validate()
36+
37+
with self.assertRaises(ValueError):
38+
GroupAddRequest(_name="").validate()

clients/client-python/tests/unittests/dto/test_group_dto.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@ def test_builder_empty_name_raises(self):
7474
AuditDTO(_creator="test", _create_time="2024-01-01T00:00:00Z")
7575
).build()
7676

77-
def test_builder_no_audit_raises(self):
78-
with self.assertRaises(ValueError):
79-
GroupDTO.builder().with_name("test_group").build()
80-
8177
def test_equality_and_hash(self):
8278
audit = AuditDTO(_creator="test", _create_time="2024-01-01T00:00:00Z")
8379

0 commit comments

Comments
 (0)