summaryrefslogtreecommitdiff
path: root/service/test
diff options
context:
space:
mode:
Diffstat (limited to 'service/test')
-rw-r--r--service/test/support/integration/app_test_client.py2
-rw-r--r--service/test/support/integration/multi_user_client.py2
-rw-r--r--service/test/unit/bitmask_libraries/test_smtp_client_certificate.py2
-rw-r--r--service/test/unit/test_authentication.py34
4 files changed, 37 insertions, 3 deletions
diff --git a/service/test/support/integration/app_test_client.py b/service/test/support/integration/app_test_client.py
index 4e7b8c66..1be07e58 100644
--- a/service/test/support/integration/app_test_client.py
+++ b/service/test/support/integration/app_test_client.py
@@ -40,7 +40,7 @@ from pixelated.application import UserAgentMode, set_up_protected_resources
from pixelated.config.sessions import LeapSession
from pixelated.config.services import Services, ServicesFactory, SingleUserServicesFactory
from pixelated.config.site import PixelatedSite
-from pixelated.config.authentication import Authentication
+from pixelated.authentication import Authentication
from pixelated.adapter.mailstore import LeapMailStore
from pixelated.adapter.mailstore.searchable_mailstore import SearchableMailStore
diff --git a/service/test/support/integration/multi_user_client.py b/service/test/support/integration/multi_user_client.py
index 420ff54b..3c80bf48 100644
--- a/service/test/support/integration/multi_user_client.py
+++ b/service/test/support/integration/multi_user_client.py
@@ -21,7 +21,7 @@ from pixelated.application import UserAgentMode, set_up_protected_resources
from pixelated.config.services import ServicesFactory
from pixelated.config.sessions import LeapSessionFactory
-from pixelated.config.authentication import Authentication
+from pixelated.authentication import Authentication
import pixelated.config.services
from pixelated.resources.root_resource import RootResource
from test.support.integration import AppTestClient
diff --git a/service/test/unit/bitmask_libraries/test_smtp_client_certificate.py b/service/test/unit/bitmask_libraries/test_smtp_client_certificate.py
index c9a51694..c4d0b0b7 100644
--- a/service/test/unit/bitmask_libraries/test_smtp_client_certificate.py
+++ b/service/test/unit/bitmask_libraries/test_smtp_client_certificate.py
@@ -19,7 +19,7 @@ import tempdir
import leap.common.certs as certs
from mockito import mock, unstub, when, any as ANY
-from pixelated.config.authentication import Authentication
+from pixelated.authentication import Authentication
from pixelated.config.sessions import SmtpClientCertificate
from tempfile import NamedTemporaryFile
diff --git a/service/test/unit/test_authentication.py b/service/test/unit/test_authentication.py
new file mode 100644
index 00000000..2fb97d69
--- /dev/null
+++ b/service/test/unit/test_authentication.py
@@ -0,0 +1,34 @@
+from twisted.trial import unittest
+
+from leap.bitmask.bonafide._srp import SRPAuthError
+from pixelated.authentication import Authentication
+
+
+class AuthenticationTest(unittest.TestCase):
+
+ def test_authenticates_with_username_and_password(self):
+ self.fail()
+
+ def test_validate_username_accepts_username(self):
+ auth = Authentication('domain.org')
+ self.assertTrue(auth.validate_username('username'))
+
+ def test_validate_username_accepts_email_address(self):
+ auth = Authentication('domain.org')
+ self.assertTrue(auth.validate_username('username@domain.org'))
+
+ def test_validate_username_denies_other_domains(self):
+ auth = Authentication('domain.org')
+ self.assertFalse(auth.validate_username('username@wrongdomain.org'))
+
+ def test_username_with_domain(self):
+ auth = Authentication('domain.org')
+ self.assertEqual('user@domain.org', auth.username_with_domain('user'))
+
+ def test_extract_username_extracts_from_plain_username(self):
+ auth = Authentication('domain.org')
+ self.assertEqual(auth.extract_username('user'), 'user')
+
+ def test_extract_username_extracts_from_email_address(self):
+ auth = Authentication('domain.org')
+ self.assertEqual(auth.extract_username('user@domain.org'), 'user')