Skip to content

Added AAS Registry Middleware#17

Merged
hofermo merged 2 commits into
devfrom
feat-aas-registry-middleware
Jun 1, 2026
Merged

Added AAS Registry Middleware#17
hofermo merged 2 commits into
devfrom
feat-aas-registry-middleware

Conversation

@artacho-xitaso

@artacho-xitaso artacho-xitaso commented May 29, 2026

Copy link
Copy Markdown

MR Overview: AAS Registry Middleware

Summary

This MR adds AasRegistryServiceMiddleware so repository writes to /repo are mirrored to the AAS Registry. When an AssetAdministrationShell is created, updated, or deleted through the repository, the middleware creates, updates, or removes the corresponding shell descriptor in the registry without blocking the proxied repository request.


Files Added

mnestix-proxy/Configuration/RegistryServiceOptions.cs

Configuration binding class for the AAS Registry cluster address. Reads from ReverseProxy:Clusters:aasRegistryCluster:Destinations:destination1.

mnestix-proxy/Services/Clients/IRegistryClient.cs

Interface for the registry client exposing:

  • RegisterOrUpdateShellDescriptor(aasId, shellDescriptorJson)
  • DeleteShellDescriptor(aasIdentifier)

mnestix-proxy/Services/Clients/RegistryClient.cs

RestSharp-based implementation of the AAS Registry Part 2 calls:

  • Register/Update: POST /shell-descriptors with the full descriptor JSON. On 409 Conflict, falls back to PUT /shell-descriptors/{base64Id}.
  • Delete: DELETE /shell-descriptors/{base64Id}

mnestix-proxy/Middleware/AasRegistryServiceMiddleware.cs

Middleware registered in the YARP pipeline when Features:AasRegistryMiddleware is enabled.

  • POST/PUT to /repo: reads and rewinds the request body before the proxy continues, checks for modelType == "AssetAdministrationShell", converts the repository body into a registry AssetAdministrationShellDescriptor, and fires a non-blocking registry call.
  • DELETE to /repo/shells/{base64AasId}: extracts the shell id from the URL and fires a non-blocking delete against the registry.
  • Registry failures are logged as warnings/errors and do not fail the repository request.

mnestix-proxy.Tests/TestMockService/RegistryMockService.cs

In-process Kestrel mock used by integration tests. Records all received requests and supports overriding the response status code via ForcedStatusCode to simulate registry failures.

mnestix-proxy.Tests/MiddlewareTests/AasRegistryServiceMiddlewareTests.cs

12 integration tests covering both invocation and payload behavior:

Test Verifies
Should_Call_Registry_When_POST_To_Repo_With_AAS_Body Registry receives a POST for repository shell creation
Should_Call_Registry_When_PUT_To_Repo_With_AAS_Body Registry receives a POST/PUT flow for repository shell update
Should_Call_Registry_When_DELETE_To_Repo Registry receives a delete for repository shell deletion
Should_Not_Call_Registry_When_POST_To_Repo_With_Non_AAS_Body Non-AAS payloads are ignored
Should_Not_Call_Registry_When_Feature_Flag_Is_Disabled Feature flag disables middleware behavior
Should_POST_Full_Descriptor_With_All_Fields_Mapped_Correctly Full AAS payload is converted to the expected shell descriptor shape
Should_POST_Descriptor_With_Only_Required_Fields_When_AAS_Body_Is_Minimal Minimal AAS payload produces only the expected minimal descriptor fields
Should_Not_Call_Registry_When_AAS_Body_Is_Missing_Id Missing shell id skips registry registration
Should_Not_Call_Registry_When_AAS_Body_Is_Missing_AssetInformation Missing assetInformation skips registry registration
Should_Not_Call_Registry_When_AAS_Body_Is_Missing_GlobalAssetId Missing globalAssetId skips registry registration
Should_Not_Call_Registry_When_Body_Is_Not_Valid_Json Invalid JSON bodies do not trigger registry calls
Proxy_Should_Return_Success_When_Registry_Returns_Server_Error Registry failures do not break the proxied repository response

Tests use polling to account for the fire-and-forget side calls and now assert both payload content and resilience behavior.


Files Modified

mnestix-proxy/Program.cs

  • Registers IRegistryClient / RegistryClient
  • Binds RegistryServiceOptions
  • Adds AasRegistryServiceMiddleware to the YARP pipeline behind Features:AasRegistryMiddleware

mnestix-proxy/appsettings.json

  • Adds "AasRegistryMiddleware": "true" under Features

mnestix-proxy.Tests/IntegrationTestBase.cs

  • Disables discovery and registry middleware by default in tests
  • Adds aasRegistryCluster destination used by registry middleware tests

Descriptor Mapping

BuildShellDescriptor converts the repository AssetAdministrationShell payload into an AAS Registry shell descriptor:

  • id -> id
  • assetInformation.globalAssetId -> globalAssetId
  • idShort, description, displayName, administration -> copied through when present
  • assetInformation.assetKind, assetType, specificAssetIds -> flattened to descriptor top-level
  • modelType -> intentionally omitted
  • assetInformation -> not copied as a nested object
  • endpoints -> generated to point back to this proxy at /repo/shells/{base64AasId}

Design Notes

  • Fire-and-forget by design: registry synchronization must not block or fail repository traffic.
  • Body handling is synchronous before proxying: the middleware must read and rewind the request body before YARP forwards it.
  • DELETE uses the URL path: shell deletion is derived from /repo/shells/{base64AasId} instead of a request body.

@artacho-xitaso artacho-xitaso changed the base branch from main to dev May 29, 2026 09:00
@artacho-xitaso artacho-xitaso changed the title AAS Registry Middleware Added AAS Registry Middleware May 29, 2026
@artacho-xitaso artacho-xitaso marked this pull request as ready for review May 29, 2026 10:14
@hofermo hofermo merged commit 6f3b179 into dev Jun 1, 2026
6 checks passed
@hofermo hofermo deleted the feat-aas-registry-middleware branch June 1, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants