Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/registration.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPellaeon Lin <nfsmwlin@gmail.com>2018-06-30 11:45:35 +0300
committerPellaeon Lin <nfsmwlin@gmail.com>2018-06-30 11:45:35 +0300
commitfa438eb7ce4bedff35e5314db7f4d845a16c58fe (patch)
treecd1a237228beba43d143ee352d4e62b9088b5d38 /tests
parent68d1b39bb1992b7e681cb4baf48e0d65f7cceb5b (diff)
Add# testing for allowed_domains in service
Diffstat (limited to 'tests')
-rw-r--r--tests/integration/service/RegistrationServiceTest.php43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/integration/service/RegistrationServiceTest.php b/tests/integration/service/RegistrationServiceTest.php
index 34b400e..d9abe33 100644
--- a/tests/integration/service/RegistrationServiceTest.php
+++ b/tests/integration/service/RegistrationServiceTest.php
@@ -122,6 +122,49 @@ class RegistrationServiceTest extends TestCase {
$this->assertTrue($ret);
}
+ public function testValidateNewEmailWithinAllowedDomain() {
+ $email = 'aaaa@example.com';
+
+ $this->config->expects($this->atLeastOnce())
+ ->method('getAppValue')
+ ->with("registration", 'allowed_domains', '')
+ ->willReturn('example.com');
+
+ $ret = $this->service->validateEmail($email);
+ $this->assertTrue($ret, print_r($ret, true));
+ }
+ /**
+ * @depends testValidateNewEmailWithinAllowedDomain
+ * @expectedException OCA\Registration\Service\RegistrationException
+ */
+ public function testValidateNewEmailNotWithinAllowedDomain() {
+ $email2 = 'bbbb@gmail.com';
+
+ $this->service->validateEmail($email2);
+ }
+
+ public function testValidateNewEmailWithinMultipleAllowedDomain() {
+ $email = 'aaaa@example.com';
+ $email2 = 'bbbb@gmail.com';
+
+ $this->config->expects($this->atLeastOnce())
+ ->method('getAppValue')
+ ->with("registration", 'allowed_domains', '')
+ ->willReturn('example.com;gmail.com');
+
+ $this->assertTrue($this->service->validateEmail($email));
+ $this->assertTrue($this->service->validateEmail($email2));
+ }
+ /**
+ * @depends testValidateNewEmailWithinMultipleAllowedDomain
+ * @expectedException OCA\Registration\Service\RegistrationException
+ */
+ public function testValidateNewEmailNotWithinMultipleAllowedDomain() {
+ $email2 = 'cccc@yahoo.com';
+
+ $this->service->validateEmail($email2);
+ }
+
public function testValidatePendingReg() {
$email = 'aaaa@example.com';