@@ -156,10 +156,6 @@ def test_app_errors(self):
156156 HTTP_AUTHORIZATION = 'token {}' .format (self .token ))
157157 self .assertContains (response , 'App IDs can only contain [a-z0-9-]' , status_code = 400 )
158158 url = '/v1/apps'
159- body = {'id' : 'deis' }
160- response = self .client .post (url , json .dumps (body ), content_type = 'application/json' ,
161- HTTP_AUTHORIZATION = 'token {}' .format (self .token ))
162- self .assertContains (response , 'deis is a reserved name.' , status_code = 400 )
163159 body = {'id' : app_id }
164160 response = self .client .post (url , json .dumps (body ), content_type = 'application/json' ,
165161 HTTP_AUTHORIZATION = 'token {}' .format (self .token ))
@@ -175,6 +171,20 @@ def test_app_errors(self):
175171 HTTP_AUTHORIZATION = 'token {}' .format (self .token ))
176172 self .assertEquals (response .status_code , 404 )
177173
174+ def test_app_reserved_names (self ):
175+ """Nobody should be able to create applications with names which are reserved."""
176+ url = '/v1/apps'
177+ reserved_names = ['foo' , 'bar' ]
178+ with self .settings (DEIS_RESERVED_NAMES = reserved_names ):
179+ for name in reserved_names :
180+ body = {'id' : name }
181+ response = self .client .post (url , json .dumps (body ), content_type = 'application/json' ,
182+ HTTP_AUTHORIZATION = 'token {}' .format (self .token ))
183+ self .assertContains (
184+ response ,
185+ '{} is a reserved name.' .format (name ),
186+ status_code = 400 )
187+
178188 def test_app_structure_is_valid_json (self ):
179189 """Application structures should be valid JSON objects."""
180190 url = '/v1/apps'
0 commit comments