diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-11-25 18:58:40 +0100 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-11-25 18:58:40 +0100 |
commit | a90f1bf06ef576c0c259139d108f0ceb0c63a729 (patch) | |
tree | 5634ebb0fc360d26657cce1e3345dcd12ec4e329 | |
parent | 2d4733f446dd4e62a554bfe637b1d595571842f8 (diff) | |
download | ick2-a90f1bf06ef576c0c259139d108f0ceb0c63a729.tar.gz |
Fix: PUT /projects/foo with no foo existing, now an error
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | ick2/apibase.py | 8 | ||||
-rw-r--r-- | yarns/100-projects.yarn | 7 |
3 files changed, 17 insertions, 2 deletions
@@ -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 |