@@ -602,47 +602,45 @@ class ServerTest
602602 }
603603 }
604604
605- // Valid POST /addLabel
606- /* "add a generic label to an instance is label and id are valid" in {
607- Post("/addLabel?Id=0& Label=ElasticSearchDefaultLabel" ) ~> addAuthorization("Admin") ~> server.routes ~> check {
605+ // Valid POST /instances/{id}/label
606+ " add a generic label to an instance is label and id are valid" in {
607+ Post (" /instances/0/label " , HttpEntity ( ContentTypes .`application/json`, """ { " Label": "Private"} """ ) ) ~> addAuthorization(" Admin" ) ~> server.routes ~> check {
608608 assert(status === StatusCodes .OK )
609609 responseAs[String ] shouldEqual " Successfully added label"
610610 }
611611 }
612-
613- //Invalid POST /addLabel
614- "fail to add label if id is invalid or label too long" in{
612+ // Invalid POST /instances/{id}/label
613+ " fail to add label if id is invalid or label too long" in {
615614 // Unknown id - expect 404
616- Post("/addLabel?Id=45& Label= Private") ~> addAuthorization("Admin") ~> server.routes ~> check {
615+ Post (" /instances/45/label " , HttpEntity ( ContentTypes .`application/json`, """ { " Label": " Private"} """ ) ) ~> addAuthorization(" Admin" ) ~> server.routes ~> check {
617616 assert(status === StatusCodes .NOT_FOUND )
618617 responseAs[String ] shouldEqual " Cannot add label, id 45 not found."
619618 }
620-
621- val tooLongLabel = "VeryVeryExtraLongLabelThatDoesNotWorkWhileAddingLabel"
622619 // Label out of bounds - expect 400
623- Post(s"/addLabel?Id=0&Label=$tooLongLabel") ~> addAuthorization("Admin") ~> server.routes ~> check {
620+ val tooLongLabel = " VeryVeryExtraLongLabelThatDoesNotWorkWhileAddingLabel"
621+ val jsonStr = tooLongLabel.toJson
622+ Post (" /instances/0/label" ,HttpEntity (ContentTypes .`application/json`, s """ { "Label": $jsonStr} """ )) ~> addAuthorization(" Admin" ) ~> server.routes ~> check {
624623 assert(status === StatusCodes .BAD_REQUEST )
625624 responseAs[String ].toLowerCase should include (" exceeds character limit" )
626625 }
627-
628626 // Wrong user type
629- Post("/addLabel?Id=0& Label= Private") ~> addAuthorization("Component") ~> Route.seal(server.routes) ~> check {
627+ Post (" /instances/0/label " , HttpEntity ( ContentTypes .`application/json`, """ { " Label": " Private"} """ )) ~> addAuthorization(" Component" ) ~> Route .seal(server.routes) ~> check {
630628 assert(status === StatusCodes .UNAUTHORIZED )
631629 responseAs[String ] shouldEqual " The supplied authentication is invalid"
632630 }
633631
634632 // Wrong user type
635- Post("/addLabel?Id=0& Label= Private") ~> addAuthorization("User") ~> Route.seal(server.routes) ~> check {
633+ Post (" /instances/0/label " , HttpEntity ( ContentTypes .`application/json`, """ { " Label": " Private"} """ ) ) ~> addAuthorization(" User" ) ~> Route .seal(server.routes) ~> check {
636634 assert(status === StatusCodes .UNAUTHORIZED )
637635 responseAs[String ] shouldEqual " The supplied authentication is invalid"
638636 }
639-
640637 // No authorization
641- Post("/addLabel?Id=0& Label= Private") ~> Route.seal(server.routes) ~> check {
638+ Post (" /instances/0/label " , HttpEntity ( ContentTypes .`application/json`, """ { " Label": " Private"} """ )) ~> Route .seal(server.routes) ~> check {
642639 assert(status === StatusCodes .UNAUTHORIZED )
643640 responseAs[String ].toLowerCase should include (" not supplied with the request" )
644641 }
645- } */
642+
643+ }
646644
647645 /** Minimal tests for docker operations**/
648646
0 commit comments