diff --git a/server/handlers/admin.go b/server/handlers/admin.go index e496eb2..936cdcf 100644 --- a/server/handlers/admin.go +++ b/server/handlers/admin.go @@ -78,8 +78,17 @@ func (a *Admin) AddMocks(c echo.Context) error { } } + // Return the target session (id + name) so callers — shell scripts especially — can chain a + // GET /mocks?session= without a separate GET /sessions lookup. Session names are not a + // reliable key (they need not be unique); the opaque id is. + session, err := a.mocksServices.GetSessionByID(sessionID) + if err != nil { + return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) + } + return c.JSON(http.StatusOK, echo.Map{ "message": "Mocks registered successfully", + "session": session.Summarize(), }) } diff --git a/tests/features/set_mocks.yml b/tests/features/set_mocks.yml index 86e21e2..e37d434 100644 --- a/tests/features/set_mocks.yml +++ b/tests/features/set_mocks.yml @@ -12,6 +12,9 @@ testcases: assertions: - result.statuscode ShouldEqual 200 - result.bodyjson.message ShouldEqual "Mocks registered successfully" + # POST /mocks returns the target session so callers can chain GET /mocks?session=. + - result.bodyjson.session.id ShouldNotBeEmpty + - result.bodyjson.session.name ShouldNotBeEmpty - type: http method: GET