diff options
author | Pellaeon Lin <nfsmwlin@gmail.com> | 2018-06-30 11:45:35 +0300 |
---|---|---|
committer | Pellaeon Lin <nfsmwlin@gmail.com> | 2018-06-30 11:45:35 +0300 |
commit | fa438eb7ce4bedff35e5314db7f4d845a16c58fe (patch) | |
tree | cd1a237228beba43d143ee352d4e62b9088b5d38 /tests | |
parent | 68d1b39bb1992b7e681cb4baf48e0d65f7cceb5b (diff) |
Add# testing for allowed_domains in service
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/service/RegistrationServiceTest.php | 43 |
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'; |