This repository has been archived on 2022-05-05. You can view files and clone it, but cannot push or open issues or pull requests.
userausfall/userausfall/rest_api/tests/trust_bridges.py

35 lines
1.2 KiB
Python

from rest_framework import status
from userausfall.rest_api.tests import UserausfallAPITestCase
from userausfall.tests import UserMixin
class TrustBridgeTestCase(UserMixin, UserausfallAPITestCase):
def test_retrieve_trust_bridge(self):
"""
Retrieve the trust bridge information of a user without an ldap account.
"""
url = "/trust-bridge/"
self.authenticate_user()
response = self.client.get(self.get_api_url(url))
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(
response.data,
{
"is_trusted": False,
"trust_giver": None,
},
)
def test_update_trust_bridge(self):
"""
Update the trust giver of the user's trust bridge.
"""
url = "/trust-bridge/"
other_user = self.create_user()
self.create_user()
self.authenticate_user()
response = self.client.put(self.get_api_url(url), {"trust_giver": other_user.pk})
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(self.user.trust_bridge.trust_giver, other_user)