Commit 4ec951e0 authored by Yann Garcia's avatar Yann Garcia
Browse files

Report some STF_685 issues

parent 849247b8
Loading
Loading
Loading
Loading
+3 −1
Changes for go-apps/meep-ipe/MEC/init.go: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -446,6 +446,7 @@ func InitMEC(cfg map[string]interface{}) {
	// Step # 7: Create a Node on the oneM2M platform to represent the MEC IPE service
	// nodeName := "mec_ipe_node"
	nodeID := uuid.NewString()
	
	err = onem2m.CreateNode(onem2m.NodeName(), nodeID)
	if err != nil {
		log.Printf("Failed to create a Node on the oneM2M platform: %v", err)
@@ -496,7 +497,8 @@ func InitMEC(cfg map[string]interface{}) {
	// -> Create a flex container for each service and publish it onto the CSE
	url = fmt.Sprintf("%s:%s/~/%s/%s", config["CSE-URL"], config["CSE-PORT"], config["CSE-ID"], config["CSE-NAME"])
	for _, service := range responseData {
		containerName := fmt.Sprintf("%s-%s", service.SerName, config["sandboxName"])
		// Containers live under this IPE's node, so the service name alone is unique
		containerName := service.SerName
		// Sent Get request to service endpoint
		fullUrl, err := fetchAndAppendHref(fmt.Sprintf("%suser-api/", service.TransportInfo.Endpoint.Uris[0]))
		if err != nil {
+7 −3
Changes for go-apps/meep-ipe/MEC/mec_iot_pltf_notification.go: 7 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ import (
	"io"
	"log"
	"net/http"
	"strconv"

	oneM2M "meep-ipe/oneM2M"
	// utils "meep-ipe/utils"
@@ -21,7 +22,10 @@ func MecIotPltfNotificationHandler(w http.ResponseWriter, r *http.Request) {
	}
	log.Printf("Request Body: %s", string(body))

	statusCode, respBody, err := oneM2M.CreateAE(body)
	rsc, statusCode, respBody, err := oneM2M.CreateAE(body)
	if rsc != 0 {
		w.Header().Set("X-M2M-RSC", strconv.Itoa(rsc))
	}
	if err != nil {
		log.Printf("Error creating AE: %v", err)
		// Still relay whatever the CSE said, if we have anything
@@ -34,9 +38,9 @@ func MecIotPltfNotificationHandler(w http.ResponseWriter, r *http.Request) {
		return
	}

	log.Printf("Response from oneM2M: status %d, body: %s", statusCode, string(respBody))
	log.Printf("Response from oneM2M: RSC %d, body: %s", rsc, string(respBody))

	// Relay the CSE's actual status code and body back to the sandbox
	// Relay the CSE's RSC, status code and body back to the sandbox
	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(statusCode)
	w.Write(respBody)
+1 −1
Changes for go-apps/meep-ipe/Server/ipe_init.go: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ func StartServer(config map[string]interface{}) {
	addr := fmt.Sprintf(":%s", port)
	srv := &http.Server{
		Addr:    addr,
		Handler: handlers.CORS()(router),
		Handler: handlers.CORS()(CleanPath(router)),
	}

	// Run the server in a goroutine so it doesn't block signal handling
+23 −1
Changes for go-apps/meep-ipe/Server/router.go: 23 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -35,8 +35,30 @@ type HttpRoute struct {

type HttpRoutes []HttpRoute

// CleanPath normalizes the request path (e.g. "//meep_ipe/v1/..." -> "/meep_ipe/v1/...")
func CleanPath(next http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		p := r.URL.Path
		if p == "" {
			p = "/"
		}
		cleaned := path.Clean(p)
		// Keep the trailing slash, same as gorilla/mux cleanPath
		if strings.HasSuffix(p, "/") && cleaned != "/" {
			cleaned += "/"
		}
		if cleaned != r.URL.Path {
			log.Printf("CleanPath: rewriting '%s' to '%s'", r.URL.Path, cleaned)
			r.URL.Path = cleaned
			r.URL.RawPath = ""
		}
		next.ServeHTTP(w, r)
	})
}

func NewRouter(config map[string]interface{}) *mux.Router {
	router := mux.NewRouter().StrictSlash(true)
	// No StrictSlash: its trailing slash redirect turns a POST into a GET as well
	router := mux.NewRouter()

	for _, route := range getRoutes(config) {
		fullPath := path.Join(route.Pattern)
+7 −0
Changes for go-apps/meep-ipe/config.env: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -80,9 +80,16 @@ MEEP_CSE_NAME=laboai-cse-in
# (or "S") per oneM2M originator rules. MEEP_LOCATION_NAME and
# MEEP_SANDBOX_NAME are appended automatically, e.g.
#   CMecIPE -> CMecIPE-mep1-sbxoon0fww
# Allowed characters: A-Z a-z 0-9 _ -
# Default if empty: "CMecIPE"
MEEP_AE_ID=CMecIPE

# Set to "true" to append MEEP_LOCATION_NAME and MEEP_SANDBOX_NAME to
# MEEP_CSE_ID and MEEP_CSE_NAME, matching meep-acme-mn-cse naming, e.g.
#   acme-mep-id-mn-cse -> acme-mep-id-mn-cse-mep1-sbxoon0fww
# Empty parts are skipped. Default if empty: false (IDs used as-is).
MEEP_INITIATED_MN_CSE=false

# HTTP Basic auth credentials for the CSE. Leave both empty if the CSE has
# no authorization enabled (no Authorization header is sent).
MEEP_CSE_USER=
Loading