Skip to content

Commit 54a0622

Browse files
committed
Create new user rather than hijacking an existing one
1 parent 7da6b77 commit 54a0622

3 files changed

Lines changed: 34 additions & 8 deletions

File tree

dojo/fixtures/dojo_testdata.json

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,24 @@
112112
"date_joined": "2018-04-13T07:59:51.527Z"
113113
}
114114
},
115+
{
116+
"pk": 7,
117+
"model": "auth.user",
118+
"fields": {
119+
"username": "globalWriter",
120+
"first_name": "Global",
121+
"last_name": "Writer",
122+
"is_active": true,
123+
"is_superuser": false,
124+
"is_staff": false,
125+
"last_login": null,
126+
"groups": [],
127+
"user_permissions": [],
128+
"password": "pbkdf2_sha256$36000$pe8Ff8HrBPac$Lb3ee6/R9z/aL9nM+D2AXWTpIt9Pa9kcLueXxYNy1ZY=",
129+
"email": "global_writer@email.com",
130+
"date_joined": "2018-04-13T07:59:51.527Z"
131+
}
132+
},
115133
{
116134
"pk": "2dqr18yqu9mzb87abk0okid75w2clakl",
117135
"model": "sessions.session",
@@ -2804,6 +2822,14 @@
28042822
"created": "2018-04-16T06:54:35.933Z"
28052823
}
28062824
},
2825+
{
2826+
"pk": "184770c4c3256aba904297610fbb4da3fa15ba36",
2827+
"model": "authtoken.token",
2828+
"fields": {
2829+
"user": 7,
2830+
"created": "2018-04-16T06:54:35.933Z"
2831+
}
2832+
},
28072833
{
28082834
"pk": "1",
28092835
"model": "dojo.dojo_group",
@@ -2875,7 +2901,7 @@
28752901
"pk": 4,
28762902
"model": "dojo.global_role",
28772903
"fields": {
2878-
"user": 4,
2904+
"user": 7,
28792905
"role": 2
28802906
}
28812907
},

unittests/test_notifications.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def test_product_types(self, mock):
215215
with self.subTest("product_type_added"):
216216
with set_actor(self.notification_tester), pghistory.context(user=self.notification_tester.id):
217217
prod_type = Product_Type.objects.create(name="notif prod type")
218-
self.assertEqual(mock.call_count, last_count + 4)
218+
self.assertEqual(mock.call_count, last_count + 5)
219219
self.assertEqual(mock.call_args_list[-1].args[0], "product_type_added")
220220
self.assertEqual(mock.call_args_list[-1].kwargs["url"], f"/product/type/{prod_type.id}")
221221

@@ -236,7 +236,7 @@ def test_products(self, mock):
236236
with set_actor(self.notification_tester), pghistory.context(user=self.notification_tester.id):
237237
prod_type = Product_Type.objects.first()
238238
prod, _ = Product.objects.get_or_create(prod_type=prod_type, name="prod name")
239-
self.assertEqual(mock.call_count, last_count + 5)
239+
self.assertEqual(mock.call_count, last_count + 6)
240240
self.assertEqual(mock.call_args_list[-1].args[0], "product_added")
241241
self.assertEqual(mock.call_args_list[-1].kwargs["url"], f"/product/{prod.id}")
242242

@@ -257,7 +257,7 @@ def test_engagements(self, mock):
257257
with set_actor(self.notification_tester), pghistory.context(user=self.notification_tester.id):
258258
prod = Product.objects.first()
259259
eng = Engagement.objects.create(product=prod, target_start=timezone.now(), target_end=timezone.now())
260-
self.assertEqual(mock.call_count, last_count + 5)
260+
self.assertEqual(mock.call_count, last_count + 6)
261261
self.assertEqual(mock.call_args_list[-1].args[0], "engagement_added")
262262
self.assertEqual(mock.call_args_list[-1].kwargs["url"], f"/engagement/{eng.id}")
263263

@@ -266,7 +266,7 @@ def test_engagements(self, mock):
266266
with set_actor(self.notification_tester), pghistory.context(user=self.notification_tester.id):
267267
eng.status = "Completed"
268268
eng.save()
269-
self.assertEqual(mock.call_count, last_count + 5)
269+
self.assertEqual(mock.call_count, last_count + 6)
270270
self.assertEqual(mock.call_args_list[-1].args[0], "engagement_closed")
271271
self.assertEqual(mock.call_args_list[-1].kwargs["url"], f"/engagement/{eng.id}/finding/all")
272272

@@ -275,7 +275,7 @@ def test_engagements(self, mock):
275275
with set_actor(self.notification_tester), pghistory.context(user=self.notification_tester.id):
276276
eng.status = "In Progress"
277277
eng.save()
278-
self.assertEqual(mock.call_count, last_count + 5)
278+
self.assertEqual(mock.call_count, last_count + 6)
279279
self.assertEqual(mock.call_args_list[-1].args[0], "engagement_reopened")
280280
self.assertEqual(mock.call_args_list[-1].kwargs["url"], f"/engagement/{eng.id}")
281281

@@ -376,7 +376,7 @@ def test_finding_groups(self, mock):
376376
with self.subTest("test_deleted itself"):
377377
with set_actor(self.notification_tester), pghistory.context(user=self.notification_tester.id):
378378
fg2.delete()
379-
self.assertEqual(mock.call_count, last_count + 5)
379+
self.assertEqual(mock.call_count, last_count + 6)
380380
self.assertEqual(mock.call_args_list[-1].args[0], "finding_group_deleted")
381381
self.assertEqual(mock.call_args_list[-1].kwargs["description"], 'The finding group "fg test" was deleted by admin')
382382
self.assertEqual(mock.call_args_list[-1].kwargs["url"], f"/test/{test2.id}")

unittests/test_rest_framework.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ class BaseClass:
372372
class RESTEndpointTest(DojoAPITestCase):
373373
NOT_AUTHORIZED_USER_ID = 3
374374
GLOBAL_READER_USER_ID = 5
375-
GLOBAL_WRITER_USER_ID = 4
375+
GLOBAL_WRITER_USER_ID = 7
376376
GLOBAL_OWNER_USER_ID = 6
377377

378378
def __init__(self, *args, **kwargs):

0 commit comments

Comments
 (0)