authentik.sources.oauth.tests.test_type_mailcow

Mailcow Type tests

 1"""Mailcow Type tests"""
 2
 3from django.test import TestCase
 4
 5from authentik.sources.oauth.models import OAuthSource
 6from authentik.sources.oauth.types.mailcow import MailcowType
 7
 8# https://community.mailcow.email/d/13-mailcow-oauth-json-format/2
 9MAILCOW_USER = {
10    "success": True,
11    "username": "email@example.com",
12    "identifier": "email@example.com",
13    "email": "email@example.com",
14    "full_name": "Example User",
15    "displayName": "Example User",
16    "created": "2020-05-15 11:33:08",
17    "modified": "2020-05-15 12:23:31",
18    "active": 1,
19}
20
21
22class TestTypeMailcow(TestCase):
23    """OAuth Source tests"""
24
25    def setUp(self):
26        self.source = OAuthSource.objects.create(
27            name="test",
28            slug="test",
29            provider_type="mailcow",
30            authorization_url="",
31            profile_url="",
32            consumer_key="",
33        )
34
35    def test_enroll_context(self):
36        """Test mailcow Enrollment context"""
37        ak_context = MailcowType().get_base_user_properties(source=self.source, info=MAILCOW_USER)
38        self.assertEqual(ak_context["email"], MAILCOW_USER["email"])
39        self.assertEqual(ak_context["name"], MAILCOW_USER["full_name"])
MAILCOW_USER = {'success': True, 'username': 'email@example.com', 'identifier': 'email@example.com', 'email': 'email@example.com', 'full_name': 'Example User', 'displayName': 'Example User', 'created': '2020-05-15 11:33:08', 'modified': '2020-05-15 12:23:31', 'active': 1}
class TestTypeMailcow(django.test.testcases.TestCase):
23class TestTypeMailcow(TestCase):
24    """OAuth Source tests"""
25
26    def setUp(self):
27        self.source = OAuthSource.objects.create(
28            name="test",
29            slug="test",
30            provider_type="mailcow",
31            authorization_url="",
32            profile_url="",
33            consumer_key="",
34        )
35
36    def test_enroll_context(self):
37        """Test mailcow Enrollment context"""
38        ak_context = MailcowType().get_base_user_properties(source=self.source, info=MAILCOW_USER)
39        self.assertEqual(ak_context["email"], MAILCOW_USER["email"])
40        self.assertEqual(ak_context["name"], MAILCOW_USER["full_name"])

OAuth Source tests

def setUp(self):
26    def setUp(self):
27        self.source = OAuthSource.objects.create(
28            name="test",
29            slug="test",
30            provider_type="mailcow",
31            authorization_url="",
32            profile_url="",
33            consumer_key="",
34        )

Hook method for setting up the test fixture before exercising it.

def test_enroll_context(self):
36    def test_enroll_context(self):
37        """Test mailcow Enrollment context"""
38        ak_context = MailcowType().get_base_user_properties(source=self.source, info=MAILCOW_USER)
39        self.assertEqual(ak_context["email"], MAILCOW_USER["email"])
40        self.assertEqual(ak_context["name"], MAILCOW_USER["full_name"])

Test mailcow Enrollment context