~jan0sch/smederee
Showing details for patch 075b389bd1c1e0551975b3602efaf4d7beb436e9.
diff -rN -u old-smederee/modules/hub/src/it/scala/de/smederee/ssh/DoobieSshAuthenticationRepositoryTest.scala new-smederee/modules/hub/src/it/scala/de/smederee/ssh/DoobieSshAuthenticationRepositoryTest.scala --- old-smederee/modules/hub/src/it/scala/de/smederee/ssh/DoobieSshAuthenticationRepositoryTest.scala 1970-01-01 00:00:00.000000000 +0000 +++ new-smederee/modules/hub/src/it/scala/de/smederee/ssh/DoobieSshAuthenticationRepositoryTest.scala 2025-01-31 02:40:18.261269556 +0000 @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2022 Contributors as noted in the AUTHORS.md file + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +package de.smederee.ssh + +import cats.effect._ +import cats.syntax.all._ +import de.smederee.hub.BaseSpec +import de.smederee.hub.Generators._ +import de.smederee.security._ +import doobie._ + +final class DoobieSshAuthenticationRepositoryTest extends BaseSpec { + test("findVcsRepositoryOwner must return the correct owner") { + genValidAccount.sample match { + case Some(account) => + val dbConfig = configuration.database + val tx = Transactor.fromDriverManager[IO](dbConfig.driver, dbConfig.url, dbConfig.user, dbConfig.pass) + val repo = new DoobieSshAuthenticationRepository[IO](tx) + val test = for { + _ <- createAccount(account, PasswordHash("I am not a password hash!"), None, None) + owner <- repo.findVcsRepositoryOwner(account.name) + } yield owner + test.assertEquals(account.toVcsRepositoryOwner.some) + case _ => fail("Could not generate data samples!") + } + } +}