Skip to content
Open
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
5 changes: 1 addition & 4 deletions server/app/interfaces/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,7 @@ def _get_shells(self, request: Request) -> Tuple[Iterator[model.AssetAdministrat
for specific_asset_id in specific_asset_ids
)
)
and (
len(global_asset_ids) <= 1
and (not global_asset_ids or shell.asset_information.global_asset_id in global_asset_ids)
)
and (not global_asset_ids or shell.asset_information.global_asset_id in global_asset_ids)
),
aas,
)
Expand Down
44 changes: 44 additions & 0 deletions server/test/interfaces/test_shells_asset_ids.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright (c) 2026 the Eclipse BaSyx Authors
#
# This program and the accompanying materials are made available under the terms of the MIT License, available in
# the LICENSE file of this project.
#
# SPDX-License-Identifier: MIT

import base64
import json
import unittest

from basyx.aas import model
from basyx.aas.adapter.aasx import DictSupplementaryFileContainer
from basyx.aas.examples.data.example_aas import create_full_example
from werkzeug.test import Client

from app.interfaces.repository import WSGIApp

BASE_PATH = "/api/v3.1"


def _encode_asset_id(name: str, value: str) -> str:
payload = json.dumps({"name": name, "value": value})
return base64.urlsafe_b64encode(payload.encode()).decode()


class ShellsAssetIdsTest(unittest.TestCase):
def setUp(self) -> None:
self.example_data = create_full_example()
app = WSGIApp(self.example_data, DictSupplementaryFileContainer())
self.client = Client(app)

def test_multiple_global_asset_ids_returns_matching_results(self) -> None:
aas_list = [obj for obj in self.example_data if isinstance(obj, model.AssetAdministrationShell)]
known_id = aas_list[0].asset_information.global_asset_id
assert known_id is not None
unknown_id = "http://example.org/nonexistent_asset"
id1 = _encode_asset_id("globalAssetId", known_id)
id2 = _encode_asset_id("globalAssetId", unknown_id)
response = self.client.get(f"{BASE_PATH}/shells?assetIds={id1}&assetIds={id2}")
self.assertEqual(200, response.status_code)
result = json.loads(response.data)
returned_ids = [r["id"] for r in result]
self.assertIn(aas_list[0].id, returned_ids)
Loading