Skip to content

Commit 787aac1

Browse files
author
Matthew Fisher
committed
Merge pull request #2718 from bacongobbler/issue-2650
fix(controller): set config as the issuing user
2 parents 960438b + 724c19c commit 787aac1

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

controller/api/tests/test_config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ def test_admin_can_create_config_on_other_apps(self):
187187
HTTP_AUTHORIZATION='token {}'.format(self.token))
188188
self.assertEqual(response.status_code, 201)
189189
self.assertIn('PORT', response.data['values'])
190+
return response
190191

191192
@mock.patch('requests.post', mock_import_repository_task)
192193
def test_limit_memory(self):
@@ -423,3 +424,11 @@ def test_tags(self):
423424
self.assertEqual(response.status_code, 405)
424425
response = self.client.delete(url, HTTP_AUTHORIZATION='token {}'.format(self.token))
425426
self.assertEqual(response.status_code, 405)
427+
428+
def test_config_owner_is_requesting_user(self):
429+
"""
430+
Ensure that setting the config value is owned by the requesting user
431+
See https://github.com/deis/deis/issues/2650
432+
"""
433+
response = self.test_admin_can_create_config_on_other_apps()
434+
self.assertEqual(response.data['owner'], self.user.username)

controller/api/views.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ def pre_save(self, config):
289289
previous_config = config.app.config_set.latest()
290290
config.owner = self.request.user
291291
if previous_config:
292-
config.owner = previous_config.owner
293292
for attr in ['cpu', 'memory', 'tags', 'values']:
294293
# Guard against migrations from older apps without fixes to
295294
# JSONField encoding.

0 commit comments

Comments
 (0)