Skip to content

Commit

Permalink
fixup! Add to test to ensure public clients do not see "Created by" f…
Browse files Browse the repository at this point in the history
…ield
  • Loading branch information
pcaisse committed Sep 11, 2018
1 parent 2806c4e commit 88ad078
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions app/data/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,26 +180,20 @@ def test_arbitrary_filters(self):
response_data2 = json.loads(self.admin_client.get(url2).content)
self.assertEqual(len(response_data2), 2)

def test_created_by(self):
url = '/api/records/?details_only=True'

admin_response_data = json.loads(self.admin_client.get(url).content)
record2_result = next(
r for r in admin_response_data['results']
if r['uuid'] == str(self.record2.uuid)
)
record3_result = next(
r for r in admin_response_data['results']
if r['uuid'] == str(self.record3.uuid)
)
def test_created_by_admin_client_email(self):
url = '/api/records/{uuid}/?details_only=True'.format(uuid=self.record2.uuid)
response_data = json.loads(self.admin_client.get(url).content)
self.assertEqual(response_data['created_by'], self.audit_log_entry1.user.email)

self.assertTrue(all('created_by' in result for result in admin_response_data['results']))
self.assertEqual(record2_result['created_by'], self.audit_log_entry1.user.email)
self.assertEqual(record3_result['created_by'], self.audit_log_entry2.username)
def test_created_by_admin_client_username(self):
url = '/api/records/{uuid}/?details_only=True'.format(uuid=self.record3.uuid)
response_data = json.loads(self.admin_client.get(url).content)
self.assertEqual(response_data['created_by'], self.audit_log_entry2.username)

def test_created_by_public_client(self):
url = '/api/records/?details_only=True'
public_response_data = json.loads(self.public_client.get(url).content)
self.assertFalse(all('created_by' in result for result in public_response_data['results']))

self.assertTrue(all('created_by' not in result for result in public_response_data['results']))

def test_tilekey_param(self):
"""Ensure that the tilekey param stores a SQL query in Redis and returns an access token"""
Expand Down

0 comments on commit 88ad078

Please sign in to comment.