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
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/Integration
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/Integration')
-rw-r--r--tests/Integration/Db/TrustedSenderMapperTest.php78
1 files changed, 72 insertions, 6 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();