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

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGretaD <gretadoci@gmail.com>2021-02-11 20:32:08 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2021-02-26 19:59:39 +0300
commit5677ea6d1a234060466c34b181bf86f9fd8b8200 (patch)
tree3edc34eaecfb04ff4917076c34d4ed8a8f57f779 /tests
parent06842c1ad4fc1b73218d7a49b72343ce6ac92b48 (diff)
Add trusted domain
Signed-off-by: GretaD <gretadoci@gmail.com> Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests')
-rw-r--r--tests/Integration/Db/TrustedSenderMapperTest.php78
-rw-r--r--tests/Unit/Service/TrustedSenderServiceTest.php7
2 files changed, 77 insertions, 8 deletions
diff --git a/tests/Integration/Db/TrustedSenderMapperTest.php b/tests/Integration/Db/TrustedSenderMapperTest.php
index c5bbbe845..058f8cc66 100644
--- a/tests/Integration/Db/TrustedSenderMapperTest.php
+++ b/tests/Integration/Db/TrustedSenderMapperTest.php
@@ -62,7 +62,7 @@ class TrustedSenderMapperTest extends TestCase {
$this->assertFalse($exists);
}
- public function testExists(): void {
+ public function testIndividualExists(): void {
$uid = $this->user->getUID();
$qb = $this->db->getQueryBuilder();
$qb->insert('mail_trusted_senders')
@@ -77,11 +77,29 @@ class TrustedSenderMapperTest extends TestCase {
$this->assertTrue($exists);
}
- public function testCreate(): void {
+ public function testDomainExists(): void {
+ $uid = $this->user->getUID();
+ $qb = $this->db->getQueryBuilder();
+ $qb->insert('mail_trusted_senders')
+ ->values([
+ 'user_id' => $qb->createNamedParameter($uid),
+ 'email' => $qb->createNamedParameter('next.cloud'),
+ 'type' => $qb->createNamedParameter('domain'),
+
+ ])
+ ->execute();
+
+ $exists = $this->mapper->exists($uid, "christoph@next.cloud");
+
+ $this->assertTrue($exists);
+ }
+
+ public function testCreateIndividual(): void {
$uid = $this->user->getUID();
$this->mapper->create(
$uid,
- "christoph@next.cloud"
+ "christoph@next.cloud",
+ 'individual'
);
$qb = $this->db->getQueryBuilder();
@@ -97,19 +115,28 @@ class TrustedSenderMapperTest extends TestCase {
$this->assertCount(1, $rows);
}
- public function testRemove(): void {
+ public function testRemoveIndividual(): void {
$uid = $this->user->getUID();
$qb = $this->db->getQueryBuilder();
$qb->insert('mail_trusted_senders')
->values([
'user_id' => $qb->createNamedParameter($uid),
'email' => $qb->createNamedParameter('christoph@next.cloud'),
+ 'type' => $qb->createNamedParameter('individual'),
+ ])
+ ->execute();
+ $qb->insert('mail_trusted_senders')
+ ->values([
+ 'user_id' => $qb->createNamedParameter($uid),
+ 'email' => $qb->createNamedParameter('next.cloud'),
+ 'type' => $qb->createNamedParameter('domain'),
])
->execute();
$this->mapper->remove(
$uid,
- "christoph@next.cloud"
+ "christoph@next.cloud",
+ 'individual'
);
$qb = $this->db->getQueryBuilder();
@@ -117,7 +144,46 @@ class TrustedSenderMapperTest extends TestCase {
->from('mail_trusted_senders')
->where(
$qb->expr()->eq('user_id', $qb->createNamedParameter($uid)),
- $qb->expr()->eq('email', $qb->createNamedParameter("christoph@next.cloud"))
+ $qb->expr()->eq('email', $qb->createNamedParameter("christoph@next.cloud")),
+ $qb->expr()->eq('type', $qb->createNamedParameter("individual"))
+ );
+ $result = $qb->execute();
+ $rows = $result->fetchAll();
+ $result->closeCursor();
+ $this->assertEmpty($rows);
+ }
+
+ public function testRemoveDomain(): void {
+ $uid = $this->user->getUID();
+ $qb = $this->db->getQueryBuilder();
+ $qb->insert('mail_trusted_senders')
+ ->values([
+ 'user_id' => $qb->createNamedParameter($uid),
+ 'email' => $qb->createNamedParameter('christoph@next.cloud'),
+ 'type' => $qb->createNamedParameter('individual'),
+ ])
+ ->execute();
+ $qb->insert('mail_trusted_senders')
+ ->values([
+ 'user_id' => $qb->createNamedParameter($uid),
+ 'email' => $qb->createNamedParameter('next.cloud'),
+ 'type' => $qb->createNamedParameter('domain'),
+ ])
+ ->execute();
+
+ $this->mapper->remove(
+ $uid,
+ "next.cloud",
+ 'domain'
+ );
+
+ $qb = $this->db->getQueryBuilder();
+ $qb->select('*')
+ ->from('mail_trusted_senders')
+ ->where(
+ $qb->expr()->eq('user_id', $qb->createNamedParameter($uid)),
+ $qb->expr()->eq('email', $qb->createNamedParameter("next.cloud")),
+ $qb->expr()->eq('type', $qb->createNamedParameter("domain"))
);
$result = $qb->execute();
$rows = $result->fetchAll();
diff --git a/tests/Unit/Service/TrustedSenderServiceTest.php b/tests/Unit/Service/TrustedSenderServiceTest.php
index e37b80387..005018e26 100644
--- a/tests/Unit/Service/TrustedSenderServiceTest.php
+++ b/tests/Unit/Service/TrustedSenderServiceTest.php
@@ -92,7 +92,8 @@ class TrustedSenderServiceTest extends TestCase {
$this->service->trust(
$uid,
- $email
+ $email,
+ 'individual'
);
}
@@ -109,7 +110,8 @@ class TrustedSenderServiceTest extends TestCase {
$this->service->trust(
$uid,
- $email
+ $email,
+ 'individual'
);
}
@@ -127,6 +129,7 @@ class TrustedSenderServiceTest extends TestCase {
$this->service->trust(
$uid,
$email,
+ 'individual',
false
);
}