Skip to content

Commit 54e3dc7

Browse files
committed
test(controller): add unit tests for app-related permission checks
1 parent 1aa3251 commit 54e3dc7

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

controller/api/tests/test_perm.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ def test_create(self):
154154
self.client.login(username='autotest-2', password='password'))
155155
response = self.client.get('/api/apps')
156156
self.assertEqual(len(response.data['results']), 0)
157+
# check that user 2 can't see any of the app's builds, configs,
158+
# containers, limits, or releases
159+
for model in ['builds', 'config', 'containers', 'limits', 'releases']:
160+
response = self.client.get("/api/apps/{}/{}/".format(app_id, model))
161+
self.assertEqual(response.data['detail'], 'Not found')
157162
# TODO: test that git pushing to the app fails
158163
# give user 2 permission to user 1's app
159164
self.assertTrue(
@@ -168,6 +173,12 @@ def test_create(self):
168173
response = self.client.get('/api/apps')
169174
self.assertEqual(response.status_code, 200)
170175
self.assertEqual(len(response.data['results']), 1)
176+
# check that user 2 sees (empty) results now for builds, containers,
177+
# and releases. (config and limit will still give 404s since we didn't
178+
# push a build here.)
179+
for model in ['builds', 'containers', 'releases']:
180+
response = self.client.get("/api/apps/{}/{}/".format(app_id, model))
181+
self.assertEqual(len(response.data['results']), 0)
171182
# TODO: check that user 2 can git push the app
172183

173184
def test_create_errors(self):

0 commit comments

Comments
 (0)