Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Get product configuration with view permission #4375

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion web/server/codechecker_server/api/product_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def __require_permission(self, required, args=None):
with DBSession(self.__session) as session:
if args is None:
args = dict(self.__permission_args)

if 'config_db_session' not in args:
args['config_db_session'] = session

# Anonymous access is only allowed if authentication is
Expand Down Expand Up @@ -254,7 +256,9 @@ def getProductConfiguration(self, product_id):
Get the product configuration --- WITHOUT THE DB PASSWORD --- of the
given product.
"""
self.__require_permission([permissions.PRODUCT_VIEW])
self.__require_permission([permissions.PRODUCT_VIEW], {
'productID': product_id
})

with DBSession(self.__session) as session:
product = session.query(Product).get(product_id)
Expand Down
1 change: 1 addition & 0 deletions web/tests/functional/products/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def setup_class_common(workspace_name):

# Export the test configuration to the workspace.
env.export_test_cfg(TEST_WORKSPACE, test_config)
env.enable_auth(TEST_WORKSPACE)


def teardown_class_common():
Expand Down
13 changes: 13 additions & 0 deletions web/tests/functional/products/test_products.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,19 @@ def test_get_product_data(self):
Confidentiality.CONFIDENTIAL,
"Default Confidentiality was not Confidential")

def test_get_product_config_auth_server(self):
"""
Test if product configuration can be retrieved from an authenticated
server.
"""
pr_client = env.setup_product_client(
self.test_workspace, product=self.product_name)
product_id = pr_client.getCurrentProduct().id

pr_client = env.setup_product_client(self.test_workspace)
pr_config = pr_client.getProductConfiguration(product_id)
self.assertIsNotNone(pr_config)

def test_editing(self):
"""
Test editing the product details (without reconnecting it).
Expand Down
Loading