diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2018-07-31 06:43:44 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2018-07-31 06:43:44 +0200 |
commit | fc149bab3cc6388895588985b352c1bd2413152b (patch) | |
tree | 6ca300cfa325cf0ed581334928f3c2cb4345a999 /tests/lib/Authentication | |
parent | 5e43f3c6a6b55601bfeb2fcd6ebcd173bd77f195 (diff) | |
download | nextcloud-server-fc149bab3cc6388895588985b352c1bd2413152b.tar.gz nextcloud-server-fc149bab3cc6388895588985b352c1bd2413152b.zip |
Fix duplicate inserts in the 2fa provider registry DAO
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests/lib/Authentication')
-rw-r--r-- | tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php b/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php index d1fed0c3a60..6323c2f0aa4 100644 --- a/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php +++ b/tests/lib/Authentication/TwoFactorAuth/Db/ProviderUserAssignmentDaoTest.php @@ -93,4 +93,23 @@ class ProviderUserAssignmentDaoTest extends TestCase { $this->assertCount(1, $data); } + public function testPersistTwice() { + $qb = $this->dbConn->getQueryBuilder(); + + $this->dao->persist('twofactor_totp', 'user123', 0); + $this->dao->persist('twofactor_totp', 'user123', 1); + + $q = $qb + ->select('*') + ->from(ProviderUserAssignmentDao::TABLE_NAME) + ->where($qb->expr()->eq('provider_id', $qb->createNamedParameter('twofactor_totp'))) + ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter('user123'))) + ->andWhere($qb->expr()->eq('enabled', $qb->createNamedParameter(1))); + $res = $q->execute(); + $data = $res->fetchAll(); + $res->closeCursor(); + + $this->assertCount(1, $data); + } + } |