Aggregation: Improve prefix fixup matching
Utilize the new array of top level collection URIs to determine if a
given URI in the response needs to have the aggregation prefix added.
This removes the need to check for specific collections like
/redfish/v1/UpdateService/FirmwareInventory which do not fit the
generic format of /redfish/v1/<collection>.
Future patches will use this same approach to improve the logic for
initially determining if and how a request should be aggregated.
This patch also adds a series of unit tests for the function
responsible for adding a prefix to a given URI. Cases covered include
valid URIs that involve a selection of aggregated resources, top level
collection URIs, other invalid URIs, and URIs with a trailing "/".
Tested:
Unit tests pass.
Signed-off-by: Carson Labrado <clabrado@google.com>
Change-Id: I676983d3c77ae3126c04e9f57ad8698c51df2675
diff --git a/redfish-core/include/aggregation_utils.hpp b/redfish-core/include/aggregation_utils.hpp
index bb1782f..673b568 100644
--- a/redfish-core/include/aggregation_utils.hpp
+++ b/redfish-core/include/aggregation_utils.hpp
@@ -15,52 +15,52 @@
namespace redfish
{
-// Note that each URI actually begins with "/redfish/v1/"
+// Note that each URI actually begins with "/redfish/v1"
// They've been omitted to save space and reduce search time
constexpr std::array<std::string_view, 44> topCollections{
- "AggregationService/Aggregates",
- "AggregationService/AggregationSources",
- "AggregationService/ConnectionMethods",
- "Cables",
- "Chassis",
- "ComponentIntegrity",
- "CompositionService/ActivePool",
- "CompositionService/CompositionReservations",
- "CompositionService/FreePool",
- "CompositionService/ResourceBlocks",
- "CompositionService/ResourceZones",
- "EventService/Subscriptions",
- "Fabrics",
- "Facilities",
- "JobService/Jobs",
- "JobService/Log/Entries",
- "KeyService/NVMeoFKeyPolicies",
- "KeyService/NVMeoFSecrets",
- "LicenseService/Licenses",
- "Managers",
- "NVMeDomains",
- "PowerEquipment/ElectricalBuses",
- "PowerEquipment/FloorPDUs",
- "PowerEquipment/PowerShelves",
- "PowerEquipment/RackPDUs",
- "PowerEquipment/Switchgear",
- "PowerEquipment/TransferSwitches",
- "RegisteredClients",
- "Registries",
- "ResourceBlocks",
- "Storage",
- "StorageServices",
- "StorageSystems",
- "Systems",
- "TaskService/Tasks",
- "TelemetryService/LogService/Entries",
- "TelemetryService/MetricDefinitions",
- "TelemetryService/MetricReportDefinitions",
- "TelemetryService/MetricReports",
- "TelemetryService/Triggers",
- "UpdateService/ClientCertificates",
- "UpdateService/FirmwareInventory",
- "UpdateService/RemoteServerCertificates",
- "UpdateService/SoftwareInventory",
+ "/AggregationService/Aggregates",
+ "/AggregationService/AggregationSources",
+ "/AggregationService/ConnectionMethods",
+ "/Cables",
+ "/Chassis",
+ "/ComponentIntegrity",
+ "/CompositionService/ActivePool",
+ "/CompositionService/CompositionReservations",
+ "/CompositionService/FreePool",
+ "/CompositionService/ResourceBlocks",
+ "/CompositionService/ResourceZones",
+ "/EventService/Subscriptions",
+ "/Fabrics",
+ "/Facilities",
+ "/JobService/Jobs",
+ "/JobService/Log/Entries",
+ "/KeyService/NVMeoFKeyPolicies",
+ "/KeyService/NVMeoFSecrets",
+ "/LicenseService/Licenses",
+ "/Managers",
+ "/NVMeDomains",
+ "/PowerEquipment/ElectricalBuses",
+ "/PowerEquipment/FloorPDUs",
+ "/PowerEquipment/PowerShelves",
+ "/PowerEquipment/RackPDUs",
+ "/PowerEquipment/Switchgear",
+ "/PowerEquipment/TransferSwitches",
+ "/RegisteredClients",
+ "/Registries",
+ "/ResourceBlocks",
+ "/Storage",
+ "/StorageServices",
+ "/StorageSystems",
+ "/Systems",
+ "/TaskService/Tasks",
+ "/TelemetryService/LogService/Entries",
+ "/TelemetryService/MetricDefinitions",
+ "/TelemetryService/MetricReportDefinitions",
+ "/TelemetryService/MetricReports",
+ "/TelemetryService/Triggers",
+ "/UpdateService/ClientCertificates",
+ "/UpdateService/FirmwareInventory",
+ "/UpdateService/RemoteServerCertificates",
+ "/UpdateService/SoftwareInventory",
};
} // namespace redfish