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:
authorJoas Schilling <coding@schilljs.com>2020-08-28 21:30:01 +0300
committerJoas Schilling <coding@schilljs.com>2020-08-28 21:39:37 +0300
commit9bdf377aecc7ea1e11d60451e9d2c5a4a89157eb (patch)
tree5fddc758f8b935bf0f9e3344108602f4f3c4caa9 /tests
parent2438813f1711fe69762d69c0774f74fae9c07049 (diff)
Add settings for blocklist and showing the domain list
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/Integration/Service/RegistrationServiceTest.php85
1 files changed, 45 insertions, 40 deletions
diff --git a/tests/Integration/Service/RegistrationServiceTest.php b/tests/Integration/Service/RegistrationServiceTest.php
index 0292ff6..32fd823 100644
--- a/tests/Integration/Service/RegistrationServiceTest.php
+++ b/tests/Integration/Service/RegistrationServiceTest.php
@@ -106,12 +106,18 @@ class RegistrationServiceTest extends TestCase {
public function dataValidateEmail(): array {
return [
- ['aaaa@example.com', ''],
- ['aaaa@example.com', 'example.com'],
- ['aaaa@example.com', 'eXample.com'],
- ['aaaa@eXample.com', 'example.com'],
- ['aaaa@cloud.example.com', '*.example.com'],
- ['aaaa@cloud.example.com', 'cloud.example.*'],
+ ['aaaa@example.com', '', 'no'],
+ ['aaaa@example.com', 'example.com', 'no'],
+ ['aaaa@example.com', 'eXample.com', 'no'],
+ ['aaaa@eXample.com', 'example.com', 'no'],
+ ['aaaa@example.com', 'example.com;example.tld', 'no'],
+ ['aaaa@example.com', 'example.tld;example.com', 'no'],
+ ['aaaa@cloud.example.com', '*.example.com', 'no'],
+ ['aaaa@cloud.example.com', 'cloud.example.*', 'no'],
+
+ ['aaaa@example.com', '', 'yes'],
+ ['aaaa@example.com', 'nextcloud.com', 'yes'],
+ ['aaaa@example.com', 'nextcloud.com;example.tld', 'yes'],
];
}
@@ -119,55 +125,54 @@ class RegistrationServiceTest extends TestCase {
* @dataProvider dataValidateEmail
* @param string $email
* @param string $allowedDomains
+ * @param string $blocked
* @throws RegistrationException
*/
- public function testValidateEmail(string $email, string $allowedDomains) {
- $this->config->expects($this->once())
- ->method('getAppValue')
- ->with('registration', 'allowed_domains', '')
- ->willReturn($allowedDomains);
-
- $this->service->validateEmail($email);
- }
-
- public function testValidateNewEmailNotWithinAllowedDomain() {
- $email2 = 'bbbb@gmail.com';
-
+ public function testValidateEmail(string $email, string $allowedDomains, string $blocked) {
$this->config->expects($this->atLeastOnce())
->method('getAppValue')
- ->with('registration', 'allowed_domains', '')
- ->willReturn('example.com');
+ ->willReturnMap([
+ ['registration', 'allowed_domains', '', $allowedDomains],
+ ['registration', 'domains_is_blocklist', 'no', $blocked],
+ ['registration', 'show_domains', 'no', 'no'],
+ ]);
- $this->expectException(RegistrationException::class);
- $this->service->validateEmail($email2);
+ $this->service->validateEmail($email);
}
- 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->service->validateEmail($email);
- $this->service->validateEmail($email2);
+ public function dataValidateEmailThrows(): array {
+ return [
+ ['aaaa@example.com', 'nextcloud.com;example.tld', 'no'],
+ ['aaaa@example.com', 'nextcloud.com', 'no'],
+
+ ['aaaa@example.com', 'example.com', 'yes'],
+ ['aaaa@example.com', 'eXample.com', 'yes'],
+ ['aaaa@eXample.com', 'example.com', 'yes'],
+ ['aaaa@example.com', 'example.com;example.tld', 'yes'],
+ ['aaaa@example.com', 'example.tld;example.com', 'yes'],
+ ['aaaa@cloud.example.com', '*.example.com', 'yes'],
+ ['aaaa@cloud.example.com', 'cloud.example.*', 'yes'],
+ ];
}
/**
- * @depends testValidateNewEmailWithinMultipleAllowedDomain
+ * @dataProvider dataValidateEmailThrows
+ * @param string $email
+ * @param string $allowedDomains
+ * @param string $blocked
+ * @throws RegistrationException
*/
- public function testValidateNewEmailNotWithinMultipleAllowedDomain() {
- $email2 = 'cccc@yahoo.com';
-
+ public function testValidateEmailThrows(string $email, string $allowedDomains, string $blocked) {
$this->config->expects($this->atLeastOnce())
->method('getAppValue')
- ->with('registration', 'allowed_domains', '')
- ->willReturn('example.com;gmail.com');
+ ->willReturnMap([
+ ['registration', 'allowed_domains', '', $allowedDomains],
+ ['registration', 'domains_is_blocklist', 'no', $blocked],
+ ['registration', 'show_domains', 'no', 'no'],
+ ]);
$this->expectException(RegistrationException::class);
- $this->service->validateEmail($email2);
+ $this->service->validateEmail($email);
}
public function testCreatePendingReg() {