Unverified Commit af62a3e1 authored by Kevin Di Lallo's avatar Kevin Di Lallo Committed by GitHub
Browse files

Merge pull request #309 from pastorsx/sp_dev_alpha_test_v9

mec021 ams alpha test fixes
parents cb0630e3 1860b0a9
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -228,7 +228,7 @@ paths:
      required: true  
    post:
      tags:
        - 'amsi'
        - 'unsupported'
      summary: ' deregister the individual application mobility service'
      description: ' deregister the individual application mobility service'
      operationId: app_mobility_service_derPOST
+21 −11
Original line number Diff line number Diff line
@@ -1643,6 +1643,14 @@ func appMobilityServicePOST(w http.ResponseWriter, r *http.Request) {
		}
	}

	//validate if the appInstanceId exists
	// Validate App Instance ID
	if registrationInfo.ServiceConsumerId.AppInstanceId != "" && appInfoMap[registrationInfo.ServiceConsumerId.AppInstanceId] == nil {
		log.Error("App Instance Id does not exist.")
		http.Error(w, "App Instance Id does not exist.", http.StatusBadRequest)
		return
	}

	//new service id
	newServId := nextServiceIdAvailable
	nextServiceIdAvailable++
@@ -1785,12 +1793,14 @@ func appMobilityServiceByIdPUT(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintf(w, string(jsonResponse))
}

/*
func appMobilityServiceDerPOST(w http.ResponseWriter, r *http.Request) {
	//these 2 methods are exactly the same based on spec except that the Deregistration happens on timer expiry
	//It is not clear why the consumer service should be responsible to send that request rather than letting AMS to take care of it
	//It looks more like a notification but there is no explanation in the spec regarding that message that enlighten the reason of its existence
	appMobilityServiceByIdDELETE(w, r)
}
*/

func serviceByIdDelete(serviceId string) (error, int) {
	key := baseKey + /* ":apps:" + registrationInfo.ServiceConsumerId.AppInstanceId +*/ "services:" + serviceId
@@ -1851,7 +1861,7 @@ func appMobilityServiceGET(w http.ResponseWriter, r *http.Request) {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	if len(response.RegistrationInfoList) > 0 {
	//	if len(response.RegistrationInfoList) > 0 {
	jsonResponse, err := json.Marshal(response.RegistrationInfoList)
	if err != nil {
		log.Error(err.Error())
@@ -1861,9 +1871,9 @@ func appMobilityServiceGET(w http.ResponseWriter, r *http.Request) {
	}
	w.WriteHeader(http.StatusOK)
	fmt.Fprintf(w, string(jsonResponse))
	} else {
		w.WriteHeader(http.StatusNotFound)
	}
	//	} else {
	//		w.WriteHeader(http.StatusNotFound)
	//	}

}

+28 −17
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import (
	//met "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-metrics"
	mod "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-model"
	mq "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-mq"
	scc "github.com/InterDigitalInc/AdvantEDGE/go-packages/meep-sandbox-ctrl-client"

	"github.com/gorilla/mux"
)
@@ -717,6 +718,7 @@ func TestFailServices(t *testing.T) {
	terminateScenario()
}

/*
func TestServicesDeregister(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())
@@ -744,7 +746,7 @@ func TestServicesDeregister(t *testing.T) {

	terminateScenario()
}

*/
func TestServicesListGet(t *testing.T) {
	fmt.Println("--- ", t.Name())
	log.MeepTextLogInit(t.Name())
@@ -899,6 +901,10 @@ func testServicesPost(t *testing.T) string {
	 * request execution section
	 ******************************/

	//creating the appInfoMap so that the POST returns a valid response
	var appInfo scc.ApplicationInfo
	appInfoMap["myapp"] = &appInfo

	rr, err := sendRequest(http.MethodPost, "/services", bytes.NewBuffer(body), nil, nil, http.StatusCreated, AppMobilityServicePOST)
	if err != nil {
		t.Fatalf("Failed to get expected response")
@@ -959,6 +965,10 @@ func testServicesPut(t *testing.T, serviceId string, expectSuccess bool) string
	 ******************************/

	if expectSuccess {
		//creating the appInfoMap so that the POST returns a valid response
		var appInfo scc.ApplicationInfo
		appInfoMap["myapp"] = &appInfo

		rr, err := sendRequest(http.MethodPost, "/services", bytes.NewBuffer(body), vars, nil, http.StatusOK, AppMobilityServiceByIdPUT)
		if err != nil {
			t.Fatalf("Failed to get expected response")
@@ -1061,29 +1071,30 @@ func testServicesDelete(t *testing.T, serviceId string, expectSuccess bool) {
	}
}

/*
func testServicesDeregister(t *testing.T, serviceId string, expectSuccess bool) {

	/******************************
	 * expected response section
	 ******************************/
	// ******************************
	// * expected response section
	// ******************************

	/******************************
	 * request vars section
	 ******************************/
	// ******************************
	// * request vars section
	// ******************************
	vars := make(map[string]string)
	vars["appMobilityServiceId"] = serviceId

	/******************************
	 * request body section
	 ******************************/
	// ******************************
	// * request body section
	// ******************************

	/******************************
	 * request queries section
	 ******************************/
	// ******************************
	// * request queries section
	// ******************************

	/******************************
	 * request execution section
	 ******************************/
	// ******************************
	// * request execution section
	// ******************************

	if expectSuccess {
		_, err := sendRequest(http.MethodPost, "/services", nil, vars, nil, http.StatusNoContent, AppMobilityServiceDerPOST)
@@ -1097,7 +1108,7 @@ func testServicesDeregister(t *testing.T, serviceId string, expectSuccess bool)
		}
	}
}

*/
func testSubscriptionMobilityProcedurePost(t *testing.T) string {

	/******************************
+0 −4
Original line number Diff line number Diff line
@@ -39,10 +39,6 @@ func AppMobilityServiceByIdPUT(w http.ResponseWriter, r *http.Request) {
	appMobilityServiceByIdPUT(w, r)
}

func AppMobilityServiceDerPOST(w http.ResponseWriter, r *http.Request) {
	appMobilityServiceDerPOST(w, r)
}

func AppMobilityServiceGET(w http.ResponseWriter, r *http.Request) {
	appMobilityServiceGET(w, r)
}
+4 −0
Original line number Diff line number Diff line
@@ -30,3 +30,7 @@ import (
func AdjAppInstGET(w http.ResponseWriter, r *http.Request) {
	notImplemented(w, r)
}

func AppMobilityServiceDerPOST(w http.ResponseWriter, r *http.Request) {
	notImplemented(w, r)
}
Loading