diff --git a/go-apps/meep-app-enablement/server/app-support/app-support.go b/go-apps/meep-app-enablement/server/app-support/app-support.go index a743ad807380ad88fdec642a9bc6be58e1987ba8..a79558356b4098cceef9e34eec889b6a7ae6eed0 100644 --- a/go-apps/meep-app-enablement/server/app-support/app-support.go +++ b/go-apps/meep-app-enablement/server/app-support/app-support.go @@ -22,6 +22,7 @@ import ( "fmt" "net/http" "net/url" + "reflect" "strconv" "sync" "time" @@ -686,6 +687,25 @@ func appRegistrationPOST(w http.ResponseWriter, r *http.Request) { errHandlerProblemDetails(w, "Endpoint shall be present when IsInsByMec is FALSE.", http.StatusBadRequest) return } + // Process appProfile if present + if appInfo.AppProfile != nil { + // Validate appProvider, endpoint, and other fields as per mapping to EASProfile + if appInfo.AppProvider != appInfo.AppProfile.ProvId { + log.Error("appProvider in AppInfo does not match provId in appProfile") + errHandlerProblemDetails(w, "appProvider and provId must be consistent", http.StatusBadRequest) + return + } + + if appInfo.AppProfile != nil { + if !reflect.DeepEqual(getEndpointUris(appInfo.Endpoint), getProfileEndpointUris(appInfo.AppProfile.EndPt)) { + log.Error("endpoint in AppInfo does not match endPt in appProfile") + errHandlerProblemDetails(w, "Endpoint and endPt must be consistent", http.StatusBadRequest) + return + } + } + + // Additional consistency checks for fields like scheds, svcArea, etc., based on appProfile attributes + } // Get App instance log.Info("appRegistrationPOST: appInfo.AppInstanceId: ", appInfo.AppInstanceId) @@ -731,6 +751,24 @@ func appRegistrationPOST(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, jsonResponse) } +func getEndpointUris(endpoint *OneOfAppInfoEndpoint) []string { + if endpoint == nil { + return nil + } + + // Access the `Uris` field directly from `EndPointInfoUris` + return endpoint.EndPointInfoUris.Uris +} + +func getProfileEndpointUris(endPt *OneOfAppProfileEndPt) []string { + if endPt == nil { + return nil + } + + // Access the `Uris` field directly from `EndPointInfoUris` + return endPt.EndPointInfoUris.Uris +} + /* * appRegistrationGET handles retrieving the registration information of an application. * It fetches the appInstanceId from the URL variables, retrieves the associated application info from Redis, and sends it back in the response. If the appInstanceId is not found or an error occurs, it responds with the appropriate status and error message.