summaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)AuthorFilesLines
2022-12-15Prepare for boost::url upgradeEd Tanous1-5/+5
The new boost URL now interops properly with std::string_view, which is great, and cleans up a bunch of mediocre code to convert one to another. It has also been pulled into boost-proper, so we no longer need a boost-url dependency that's separate. Unfortunately, boost url makes these improvements by changing boost::string_view for boost::urls::const_string, which causes us to have some compile errors on the missing type. The bulk of these changes fall into a couple categories, and have to be executed in one commit. string() is replaced with buffer() on the url and url_view types boost::string_view is replaced by std::string_view for many times, in many cases removing a temporary that we had in the code previously. Tested: Code compiles with boost 1.81.0 beta. Redfish service validator passes. Pretty good unit test coverage for URL-specific use cases. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I8d3dc89b53d1cc390887fe53605d4867f75f76fd
2022-12-08Aggregation: Detect and fix all URI propertiesCarson Labrado1-0/+41
There are a number of properties of Type "string (uri)" for which we do not currently support adding prefixes. This patch adds support for all existing URI properties which are missed by the existing implementation. This change will be needed by future patches which will expand aggregation support to all top level collections defined by the schema. Those collections that are not currently supported include properties whose URIs should be fixed, but would be missed by the existing implementation. Tested: New unit test passes. URI properties are still handled correctly. ```shell curl localhost/redfish/v1/Chassis/5B247A_<chassisID> { "@odata.id": "/redfish/v1/Chassis/5B247A_<chassisID>", "@odata.type": "#Chassis.v1_16_0.Chassis", "Actions": { "#Chassis.Reset": { "@Redfish.ActionInfo": "/redfish/v1/Chassis/5B247A_<chassisID>/ResetActionInfo", "target": "/redfish/v1/Chassis/5B247A_<chassisID>/Actions/Chassis.Reset" } }, ... } ``` Signed-off-by: Carson Labrado <clabrado@google.com> Change-Id: I3b3e06ee3191564d266598f7bc9f1641e6fcb333
2022-12-06Make router take up less space for verbsEd Tanous1-0/+56
As is, the router designates routes for every possible boost verb, of which there are 31. In bmcweb, we only make use of 6 of those verbs, so that ends up being quite a bit of wasted space and cache non-locality. This commit invents a new enum class for declaring a subset of boost verbs that we support, and a mapping between bmcweb verbs and boost verbs. Then it walks through and updates the router to support converting one to another. Tested: Unit Tested Redfish Service Validator performed on future commit Signed-off-by: Ed Tanous <edtanous@google.com> Signed-off-by: Edward Lee <edwarddl@google.com> Change-Id: I3c89e896c632a5d4134dbd08a30b313c12a60de6
2022-11-09thermal subsystem test: fix typoNan Zhou1-2/+2
Testd: unit test only change Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: I0a8d1e97d8f0be8a79b9c40a75eeb0659bba638b
2022-11-08Add a whitespace in testNan Zhou1-0/+1
This is a dummy commit to test owner plugin. It can be merged in as well given that it adds a little bit readability. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: Ia4cc1866ebeb19e6d0f1d1ceece0ecc73fb4b468
2022-10-26utility: Append Url Pieces to existing UrlWilly Tu1-0/+13
Add helper function to append pieces to existing url to allow more flexible control over the url. This allows us to avoid have each resource append the pieces outside of the utility functions and help maintain all url modifications in a central place for easy management. Tested: Does not affect Redfish Tree. Unit Test passed. Change-Id: I751f3c120cbadb465915b12aa253edd53ef32123 Signed-off-by: Willy Tu <wltu@google.com>
2022-10-21Implements PowerSubsystem schemaChicago Duan1-0/+43
This commit implements the Redfish PowerSubsystem schema and collects default property values. PowerSupplies will be implemented in the next commit. ref: https://www.dmtf.org/sites/default/files/standards/documents/ DSP0268_2022.2.pdf (6.86 PowerSubsystem 1.1.0) https://redfish.dmtf.org/schemas/v1/PowerSupply.v1_1_0.json Tested: Validator and UT passes 1. curl -k -H "X-Auth-Token: $token" -X GET https://${bmc}/redfish/v1/Chassis/chassis/PowerSubsystem { "@odata.id": "/redfish/v1/Chassis/chassis/PowerSubsystem", "@odata.type": "#PowerSubsystem.v1_1_0.PowerSubsystem", "Id": "PowerSubsystem", "Name": "Power Subsystem", "Status": { "Health": "OK", "State": "Enabled" } } 2. bad chassisID curl -k -H "X-Auth-Token: $token" -X GET https://${bmc} /redfish/v1/Chassis/badchassisID/PowerSubsystem/ PowerSupplies/powersupply0 { "error": { "@Message.ExtendedInfo": [ { "@odata.type": "#Message.v1_1_1.Message", "Message": "The requested resource of type Chassis named badchassisID was not found.", "MessageArgs": [ "Chassis", "badchassisID" ], "MessageId": "Base.1.13.1.ResourceNotFound", "MessageSeverity": "Critical", "Resolution": "Provide a valid resource identifier and resubmit the request." } ], "code": "Base.1.13.1.ResourceNotFound", "message": "The requested resource of type Chassis named badchassisID was not found." } } Signed-off-by: Chicago Duan <duanzhijia01@inspur.com> Change-Id: I6885b1777082538eceaf7ea85a8f69966459ee43
2022-10-12header cleanupsNan Zhou4-6/+6
This commit fixed several places (but not all) where wrong include directory is specified and prevent the clean up in the chidren changes. Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: Ibbba62e2c0cfe3583a65f1befa1b233bd3eebf19
2022-10-05Fixed issues with multipart parserKrzysztof Grobelny1-9/+183
- Index was not checked against size before dereference. Which cased to override memory. - Header without colon could put parser into invalid state. Now it will return with error. - Content after boundary was not correctly discarded. - Parser did not check body for final boudary. Now missing final boundary will return with error. Tested: - Tested that payload with header without colon doesn't cause memory corruption anymore. Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com> Change-Id: I12f496ab5f53e6c088cdfdf2e96be636d66f7c7f
2022-09-22Fix content-type return behavior for */*Ed Tanous1-15/+20
An HTTP header of Accepts: */* throws a big wrench into our implementation for a couple reasons. First, because it's the default in a lot of commonly-used libraries, and second, because clients use it when they certainly don't mean what the specification says it should mean "ie, I accept ANY type". This commit tries to address some of that, by making an explicit option for content-type="ANY" and pushes it to the individual callers to handle explicitly as if it were yet another type. In most protocols, there's a "most common" representation, so protocols are free to use that, or to explicitly handle it, and require that the user be explicit. Tested: Redfish Protocol Validator no longer locks up. (TBD, getting bugs filed with protocol validator for this missing Accepts header). For ServiceRoot GET /redfish/v1 Accepts: application/json - returns json GET /redfish/v1 Accepts: */* - returns json GET /redfish/v1 Accepts: text/html - returns html GET /redfish/v1 no-accepts header - returns json Redfish-service-validator passes. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Iae6711ae587115d3e159a48a6fc46a903ed6c403
2022-09-22treewide: reorganize unit testsNan Zhou23-0/+3273
Like other C++ projects, unit tests normally are in a separate repo and respect the folder structure of the file under test. This commit deleted all "ut" folder and move tests to a "test" folder. The test folder also has similar structure as the main folder. This commit also made neccessary include changes to make codes compile. Unused tests are untouched. Tested: unit test passed. Reference: [1] https://github.com/grpc/grpc/tree/master/test [2] https://github.com/boostorg/core/tree/414dfb466878af427d33b36e6ccf84d21c0e081b/test [3] Many other OpenBMC repos: https://github.com/openbmc/entity-manager/tree/master/test [4] https://stackoverflow.com/questions/2360734/whats-a-good-directory-structure-for-larger-c-projects-using-makefile Signed-off-by: Nan Zhou <nanzhoumails@gmail.com> Change-Id: I4521c7ef5fa03c47cca5c146d322bbb51365ee96