From adda60ca1619b49ffd0c543e1df8fe3fe39ddad0 Mon Sep 17 00:00:00 2001 From: Arthur Date: Fri, 7 Apr 2023 13:28:09 -0700 Subject: [PATCH] 11091 test case for invalid token creation --- netbox/users/tests/test_api.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/netbox/users/tests/test_api.py b/netbox/users/tests/test_api.py index 7041eb812..4633d9c9f 100644 --- a/netbox/users/tests/test_api.py +++ b/netbox/users/tests/test_api.py @@ -153,6 +153,19 @@ class TokenTest( response = self.client.post(url, data, format='json', **self.header) self.assertEqual(response.status_code, 403) + def test_provision_token_other_user(self): + """ + Test the behavior of the token provisioning view when invalid credentials are supplied. + """ + user2 = User.objects.create_user(username='testuser2') + data = { + 'user': user2.id, + } + url = reverse('users-api:token-list') + + response = self.client.post(url, data, format='json', **self.header) + self.assertEqual(response.status_code, 403) + class ObjectPermissionTest( # No GraphQL support for ObjectPermission