-
Notifications
You must be signed in to change notification settings - Fork 12
fix(redfish): fixed failures on redfish protocol validator #823
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
base: redfish
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -169,10 +169,21 @@ func RegisterRoutes(router *gin.Engine, _ logger.Interface) error { | |
| return nil | ||
| } | ||
|
|
||
| // Build middleware chain with OData header | ||
| // Build middleware chain with OData header validation and response | ||
| middlewares := []redfishgenerated.MiddlewareFunc{ | ||
| func(c *gin.Context) { | ||
| c.Header("OData-Version", "4.0") | ||
| // Validate OData-Version header if present in request | ||
| requestODataVersion := c.GetHeader("OData-Version") | ||
| if requestODataVersion != "" && requestODataVersion != v1.SupportedODataVersion { | ||
| c.Header("OData-Version", v1.SupportedODataVersion) | ||
| v1.PreconditionFailedError(c, "Unsupported OData-Version. Service supports OData-Version: "+v1.SupportedODataVersion) | ||
| c.Abort() | ||
|
|
||
| return | ||
| } | ||
|
|
||
| // Set OData-Version header in response | ||
| c.Header("OData-Version", v1.SupportedODataVersion) | ||
| c.Next() | ||
| }, | ||
| } | ||
|
|
@@ -188,6 +199,14 @@ func RegisterRoutes(router *gin.Engine, _ logger.Interface) error { | |
| Middlewares: middlewares, | ||
| }) | ||
|
|
||
| // Register /redfish endpoint manually (required by Redfish protocol) | ||
| // This endpoint must be publicly accessible without authentication | ||
| router.GET("/redfish", server.GetRedfish) | ||
|
|
||
| // Per Redfish spec: POST to collection/Members is equivalent to POST to collection | ||
| // Add this route to support protocol validator requirements | ||
| router.POST("/redfish/v1/SessionService/Sessions/Members", server.PostRedfishV1SessionServiceSessions) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as the previous comment. |
||
|
|
||
| if componentConfig.AuthRequired { | ||
| server.Logger.Info("Redfish API routes registered with authentication") | ||
| } else { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -274,6 +274,15 @@ func GetDefaultServices() []ODataService { | |
| } | ||
| } | ||
|
|
||
| // GetRedfish handles GET /redfish | ||
| // Returns protocol version information. Must be publicly accessible without authentication. | ||
| func (s *RedfishServer) GetRedfish(c *gin.Context) { | ||
| // No Redfish headers for this endpoint - it's a simple JSON response | ||
| c.JSON(http.StatusOK, gin.H{ | ||
| "v1": "/redfish/v1/", | ||
| }) | ||
| } | ||
|
|
||
| // Path: GET /redfish/v1 | ||
| // Spec: Redfish ServiceRoot.v1_19_0 | ||
| // This is the entry point for the Redfish API, providing links to all available resources. | ||
|
|
@@ -350,7 +359,7 @@ func (s *RedfishServer) GetRedfishV1Odata(c *gin.Context) { | |
| } | ||
|
|
||
| response := map[string]interface{}{ | ||
| "@odata.context": odataContextServiceRoot, | ||
| "@odata.context": "/redfish/v1/$metadata", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this replaced with $metadata |
||
| "value": services, | ||
| } | ||
| c.JSON(http.StatusOK, response) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the right way to add or should it be updated in the spec so that the code gets generated automatically.