@@ -278,7 +278,7 @@ var _ = Describe("api", func() {
278278 })
279279 })
280280
281- FContext ("Tracking endpoints" , func () {
281+ Context ("Tracking endpoints" , func () {
282282 var dummyClient * dummyTrackerClient
283283 var testClient * http.Client
284284
@@ -525,6 +525,49 @@ var _ = Describe("api", func() {
525525 }
526526 })
527527
528+ It ("/configurations/status should reject invalid json, and marshal valid fields" , func () {
529+ // setup test data
530+ dummyClient .code = http .StatusOK
531+ testData := []string {
532+ "invalid-json" ,
533+ `{"serviceId":"8eebdb60-be68-4380-a902-8cd0a2a0744c",
534+ "reportedTime":"2017-08-09T13:30:03.987-07:00"}` ,
535+ `{"invalid-field1":"8eebdb60-be68-4380-a902-8cd0a2a0744c",
536+ "invalid-field2":"2017-08-09T13:30:03.987-07:00"}` ,
537+ }
538+
539+ expectedCode := []int {
540+ http .StatusBadRequest ,
541+ http .StatusOK ,
542+ http .StatusBadRequest ,
543+ }
544+
545+ expectedBody := []string {
546+ "json" ,
547+ "" ,
548+ "" ,
549+ }
550+
551+ // setup http client
552+ uri , err := url .Parse (apiTestUrl )
553+ Expect (err ).Should (Succeed ())
554+ for i , data := range testData {
555+ uri .Path = testApiMan .configStatusEndpoint
556+ log .Debug (uri .String (), data )
557+ req , err := http .NewRequest ("PUT" , uri .String (), strings .NewReader (data ))
558+ Expect (err ).Should (Succeed ())
559+ // http put
560+ res , err := testClient .Do (req )
561+ Expect (err ).Should (Succeed ())
562+ // parse response
563+ defer res .Body .Close ()
564+ Expect (res .StatusCode ).Should (Equal (expectedCode [i ]))
565+ body , err := ioutil .ReadAll (res .Body )
566+ Expect (err ).Should (Succeed ())
567+ Expect (strings .Contains (strings .ToLower (string (body )), strings .ToLower (expectedBody [i ]))).To (BeTrue ())
568+ }
569+ })
570+
528571 It ("/configurations/status should populate errors from tracker" , func () {
529572 // setup test data
530573 testData := [][]string {
@@ -804,7 +847,6 @@ func GenerateUUID() string {
804847}
805848
806849func generateStatusDetails (flag int ) (* statusDetailsJson , string ) {
807- log .Warnf ("flag: %v" , flag )
808850 id := GenerateUUID ()
809851 var ret * statusDetailsJson
810852 var expected string
0 commit comments