~jan0sch/smederee

Showing details for patch e80ef22ca526fc98c17bbcb564319a65574275fb.
2024-07-22 (Mon), 7:30 PM - Jens Grassel - e80ef22ca526fc98c17bbcb564319a65574275fb

chore: Cleanup

Summary of changes
1 files added
  • modules/hub/src/test/scala/de/smederee/ScalaCheckCats.scala
8 files modified with 7 lines added and 36 lines removed
  • modules/hub/src/main/scala/de/smederee/hub/AccountManagementRoutes.scala with 0 added and 3 removed lines
  • modules/hub/src/main/scala/de/smederee/hub/HubServer.scala with 0 added and 1 removed lines
  • modules/hub/src/main/scala/de/smederee/hub/OrganisationRoutes.scala with 2 added and 2 removed lines
  • modules/hub/src/test/scala/de/smederee/hub/AuthenticationRoutesTest.scala with 0 added and 1 removed lines
  • modules/hub/src/test/scala/de/smederee/hub/BaseSpec.scala with 2 added and 1 removed lines
  • modules/hub/src/test/scala/de/smederee/hub/DoobieAccountManagementRepositoryTest.scala with 0 added and 1 removed lines
  • modules/hub/src/test/scala/de/smederee/hub/Generators.scala with 0 added and 26 removed lines
  • modules/hub/src/test/scala/de/smederee/tickets/BaseSpec.scala with 3 added and 1 removed lines
diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/hub/AccountManagementRoutes.scala new-smederee/modules/hub/src/main/scala/de/smederee/hub/AccountManagementRoutes.scala
--- old-smederee/modules/hub/src/main/scala/de/smederee/hub/AccountManagementRoutes.scala	2025-01-11 00:09:24.494211211 +0000
+++ new-smederee/modules/hub/src/main/scala/de/smederee/hub/AccountManagementRoutes.scala	2025-01-11 00:09:24.498211218 +0000
@@ -47,8 +47,6 @@
   *   Middleware layer needed to send emails.
   * @param organisationsRepo
   *   The repository providing functionality to handle organisations.
-  * @param signAndValidate
-  *   A class providing functions to handle session token signing and validation.
   * @param ticketServiceApi
   *   The ticket service API which is needed to synchronise changes for the account.
   * @tparam F
@@ -59,7 +57,6 @@
     configuration: ServiceConfig,
     emailMiddleware: EmailMiddleware[F],
     organisationsRepo: OrganisationRepository[F],
-    signAndValidate: SignAndValidate,
     ticketServiceApi: TicketServiceApi[F]
 ) extends HttpBaseRoute[F] {
     private val log = LoggerFactory.getLogger(getClass)
diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/hub/HubServer.scala new-smederee/modules/hub/src/main/scala/de/smederee/hub/HubServer.scala
--- old-smederee/modules/hub/src/main/scala/de/smederee/hub/HubServer.scala	2025-01-11 00:09:24.494211211 +0000
+++ new-smederee/modules/hub/src/main/scala/de/smederee/hub/HubServer.scala	2025-01-11 00:09:24.498211218 +0000
@@ -482,7 +482,6 @@
                         hubConfiguration.service,
                         emailMiddleware,
                         orgRepo,
-                        signAndValidate,
                         ticketServiceApi
                     )
                     authenticationRoutes = new AuthenticationRoutes[IO](
diff -rN -u old-smederee/modules/hub/src/main/scala/de/smederee/hub/OrganisationRoutes.scala new-smederee/modules/hub/src/main/scala/de/smederee/hub/OrganisationRoutes.scala
--- old-smederee/modules/hub/src/main/scala/de/smederee/hub/OrganisationRoutes.scala	2025-01-11 00:09:24.498211218 +0000
+++ new-smederee/modules/hub/src/main/scala/de/smederee/hub/OrganisationRoutes.scala	2025-01-11 00:09:24.498211218 +0000
@@ -336,7 +336,7 @@
                     orgaData = orgAndAdmins.filter(tuple => tuple._1.owner === user.uid || tuple._2.exists(_ === user))
                     resp <- orgaData match {
                         case None => NotFound()
-                        case Some((organisation, admins, _)) =>
+                        case Some((organisation, _, _)) =>
                             val members = orgMembers.getOrElse(Nil)
                             for {
                                 formData <- Sync[F].delay(urlForm.valuesWithoutEmptyStrings)
@@ -550,7 +550,7 @@
                 orgaData = orgAndAdmins.filter(tuple => tuple._1.owner === user.uid || tuple._2.exists(_ === user))
                 resp <- orgaData match {
                     case None => NotFound("Organisation not found!")
-                    case Some((organisation, admins, _)) =>
+                    case Some((organisation, _, _)) =>
                         val members = orgMembers.getOrElse(Nil)
                         user.validatedEmail match {
                             case false =>
diff -rN -u old-smederee/modules/hub/src/test/scala/de/smederee/hub/AuthenticationRoutesTest.scala new-smederee/modules/hub/src/test/scala/de/smederee/hub/AuthenticationRoutesTest.scala
--- old-smederee/modules/hub/src/test/scala/de/smederee/hub/AuthenticationRoutesTest.scala	2025-01-11 00:09:24.498211218 +0000
+++ new-smederee/modules/hub/src/test/scala/de/smederee/hub/AuthenticationRoutesTest.scala	2025-01-11 00:09:24.498211218 +0000
@@ -12,7 +12,6 @@
 import cats.effect.*
 import cats.syntax.all.*
 import com.typesafe.config.ConfigFactory
-import de.smederee.hub.Generators.*
 import de.smederee.hub.Generators.given
 import de.smederee.hub.config.*
 import de.smederee.hub.forms.*
diff -rN -u old-smederee/modules/hub/src/test/scala/de/smederee/hub/BaseSpec.scala new-smederee/modules/hub/src/test/scala/de/smederee/hub/BaseSpec.scala
--- old-smederee/modules/hub/src/test/scala/de/smederee/hub/BaseSpec.scala	2025-01-11 00:09:24.498211218 +0000
+++ new-smederee/modules/hub/src/test/scala/de/smederee/hub/BaseSpec.scala	2025-01-11 00:09:24.498211218 +0000
@@ -16,6 +16,7 @@
 import cats.syntax.all.*
 import com.comcast.ip4s.*
 import com.typesafe.config.ConfigFactory
+import de.smederee.ScalaCheckCats
 import de.smederee.email.EmailAddress
 import de.smederee.hub.config.*
 import de.smederee.i18n.LanguageCode
@@ -33,7 +34,7 @@
   * does initialise the test database for each suite. The latter means a possibly existing database with the name
   * configured **will be deleted**!
   */
-abstract class BaseSpec extends CatsEffectSuite with ScalaCheckEffectSuite {
+abstract class BaseSpec extends CatsEffectSuite with ScalaCheckEffectSuite with ScalaCheckCats {
 
     protected final val configuration: SmedereeHubConfig =
         ConfigSource
diff -rN -u old-smederee/modules/hub/src/test/scala/de/smederee/hub/DoobieAccountManagementRepositoryTest.scala new-smederee/modules/hub/src/test/scala/de/smederee/hub/DoobieAccountManagementRepositoryTest.scala
--- old-smederee/modules/hub/src/test/scala/de/smederee/hub/DoobieAccountManagementRepositoryTest.scala	2025-01-11 00:09:24.498211218 +0000
+++ new-smederee/modules/hub/src/test/scala/de/smederee/hub/DoobieAccountManagementRepositoryTest.scala	2025-01-11 00:09:24.498211218 +0000
@@ -13,7 +13,6 @@
 import cats.effect.*
 import cats.syntax.all.*
 import de.smederee.TestTags.*
-import de.smederee.hub.Generators.*
 import de.smederee.hub.Generators.given
 import de.smederee.i18n.LanguageCode
 import de.smederee.security.*
diff -rN -u old-smederee/modules/hub/src/test/scala/de/smederee/hub/Generators.scala new-smederee/modules/hub/src/test/scala/de/smederee/hub/Generators.scala
--- old-smederee/modules/hub/src/test/scala/de/smederee/hub/Generators.scala	2025-01-11 00:09:24.498211218 +0000
+++ new-smederee/modules/hub/src/test/scala/de/smederee/hub/Generators.scala	2025-01-11 00:09:24.498211218 +0000
@@ -11,7 +11,6 @@
 import java.util.Locale
 import java.util.UUID
 
-import cats.data.NonEmptyList
 import cats.syntax.all.*
 import de.smederee.email.EmailAddress
 import de.smederee.i18n.LanguageCode
@@ -241,29 +240,4 @@
     val genPermissions: Gen[Set[Permission]] = Gen.choose(0, 7).map(Permission.decode)
 
     given Arbitrary[Set[Permission]] = Arbitrary(genPermissions)
-
-    /** Provide a generator that generates a [[NonEmptyList]] with head and a non empty tail given that an [[Arbitrary]]
-      * for the desired type `A` is in scope. This is defined as a `Given` to be used later on to create an arbitrary of
-      * this generator.
-      *
-      * @param singleValue
-      *   An arbitrary instance for the desired type `A`.
-      * @return
-      *   A generator for a `NonEmptyList[A]`.
-      */
-    given genNel[A](using singleValue: Arbitrary[A]): Gen[NonEmptyList[A]] =
-        for {
-            head <- singleValue.arbitrary
-            tail <- Gen.nonEmptyListOf(singleValue.arbitrary)
-        } yield NonEmptyList.of(head, tail: _*)
-
-    /** Provide an arbitrary for a [[NonEmptyList]] of the desired type `A` if a generator for `NonEmptyList[A]` is in
-      * scope.
-      *
-      * @param genNel
-      *   A generator for a `NonEmptyList[A]`.
-      * @return
-      *   An arbitrary instance of `NonEmptyList[A]`.
-      */
-    given [A](using genNel: Gen[NonEmptyList[A]]): Arbitrary[NonEmptyList[A]] = Arbitrary(genNel)
 }
diff -rN -u old-smederee/modules/hub/src/test/scala/de/smederee/ScalaCheckCats.scala new-smederee/modules/hub/src/test/scala/de/smederee/ScalaCheckCats.scala
--- old-smederee/modules/hub/src/test/scala/de/smederee/ScalaCheckCats.scala	1970-01-01 00:00:00.000000000 +0000
+++ new-smederee/modules/hub/src/test/scala/de/smederee/ScalaCheckCats.scala	2025-01-11 00:09:24.498211218 +0000
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2022 Contributors as noted in the AUTHORS.md file
+ *
+ * Licensed under the EUPL
+ */
+
+package de.smederee
+
+import cats.data.*
+
+import org.scalacheck.*
+
+/** Provide helpers for automatically providing generators for Cats data types like NonEmptyList.
+  */
+trait ScalaCheckCats {
+
+    /** Provide a generator that generates a [[NonEmptyList]] with head and a non empty tail given that an [[Arbitrary]]
+      * for the desired type `A` is in scope. This is defined as a `Given` to be used later on to create an arbitrary of
+      * this generator.
+      *
+      * @param singleValue
+      *   An arbitrary instance for the desired type `A`.
+      * @return
+      *   A generator for a `NonEmptyList[A]`.
+      */
+    given genNel[A](using singleValue: Arbitrary[A]): Gen[NonEmptyList[A]] =
+        for {
+            head <- singleValue.arbitrary
+            tail <- Gen.nonEmptyListOf(singleValue.arbitrary)
+        } yield NonEmptyList.of(head, tail: _*)
+
+    /** Provide an arbitrary for a [[NonEmptyList]] of the desired type `A` if a generator for `NonEmptyList[A]` is in
+      * scope.
+      *
+      * @param genNel
+      *   A generator for a `NonEmptyList[A]`.
+      * @return
+      *   An arbitrary instance of `NonEmptyList[A]`.
+      */
+    given [A](using genNel: Gen[NonEmptyList[A]]): Arbitrary[NonEmptyList[A]] = Arbitrary(genNel)
+}
diff -rN -u old-smederee/modules/hub/src/test/scala/de/smederee/tickets/BaseSpec.scala new-smederee/modules/hub/src/test/scala/de/smederee/tickets/BaseSpec.scala
--- old-smederee/modules/hub/src/test/scala/de/smederee/tickets/BaseSpec.scala	2025-01-11 00:09:24.498211218 +0000
+++ new-smederee/modules/hub/src/test/scala/de/smederee/tickets/BaseSpec.scala	2025-01-11 00:09:24.498211218 +0000
@@ -12,6 +12,7 @@
 import cats.syntax.all.*
 import com.comcast.ip4s.*
 import com.typesafe.config.ConfigFactory
+import de.smederee.ScalaCheckCats
 import de.smederee.email.EmailAddress
 import de.smederee.i18n.LanguageCode
 import de.smederee.security.UserId
@@ -30,7 +31,8 @@
   * does initialise the test database for each suite. The latter means a possibly existing database with the name
   * configured **will be deleted**!
   */
-abstract class BaseSpec extends CatsEffectSuite {
+abstract class BaseSpec extends CatsEffectSuite with ScalaCheckCats {
+
     protected final val configuration: SmedereeTicketsConfiguration =
         ConfigSource
             .fromConfig(ConfigFactory.load(getClass.getClassLoader))