From a90f1bf06ef576c0c259139d108f0ceb0c63a729 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 25 Nov 2017 18:58:40 +0100 Subject: Fix: PUT /projects/foo with no foo existing, now an error --- NEWS | 4 +++- ick2/apibase.py | 8 +++++++- yarns/100-projects.yarn | 7 +++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index a6cec8f..01d0f1f 100644 --- a/NEWS +++ b/NEWS @@ -24,7 +24,9 @@ Version 0.17+git, not yet released pipeline in every project. * `POST /projects` (or `icktool create-project`) with a project - description that names an already existing project fails. + description that names an already existing project fails. Likewise, + `PUT /projrect/foo` (or `icktool update-project`) when no project + foo exists is now an error. Version 0.17, released 2017-11-19 ---------------------------------- diff --git a/ick2/apibase.py b/ick2/apibase.py index 9795178..361baaa 100644 --- a/ick2/apibase.py +++ b/ick2/apibase.py @@ -159,7 +159,13 @@ class ResourceApiBase(APIbase): raise NotImplementedError() def update(self, body, name, **kwargs): - return self._state.update_resource(self._type_name, name, body) + name = self.get_resource_name(body) + try: + self._state.get_resource(self._type_name, name) + except ick2.NotFound: + raise + else: + return self._state.update_resource(self._type_name, name, body) def delete(self, name, **kwargs): self._state.remove_resource(self._type_name, name) diff --git a/yarns/100-projects.yarn b/yarns/100-projects.yarn index de7f9c7..aa04b7a 100644 --- a/yarns/100-projects.yarn +++ b/yarns/100-projects.yarn @@ -203,4 +203,11 @@ Creating a new project with the same name is forbidden. WHEN user makes request GET /projects/website THEN result has status code 404 + WHEN user makes request PUT /projects/nosuchproject with a valid token and body + ... { + ... "project": "nosuchproject", + ... "pipelines": [] + ... } + THEN result has status code 404 + FINALLY stop ick controller -- cgit v1.2.1