From 1de710b991aabcb2951d55b07dd36f1439220289 Mon Sep 17 00:00:00 2001 From: Paul Cleary Date: Tue, 28 Apr 2020 10:08:03 -0400 Subject: [PATCH] Update dependencies (#939) * Updating dependencies Updated almost all dependencies to current. There were some issues with akka-http 10.1.11 so I stayed with 10.1.10 for the time being. Func tests passed locally and manual review of the UI looks to be good Significant changes are: - `pureconfig` - this update had breaking syntax, so I had to update everywhere we use pureconfig. Functionally it is the same, just different syntax - `scalatest` - this was a big change, as scalatest has refactored out things like Mockito and scalacheck. Many imports changed. - `Java11` - formally moved everything to java 11. This required some new dependencies like `javax.activation` and `java.xml.bind` * Updating travis to JDK 11 * Finishing JDK 11 update In order to update to JDK 11, needed to modify several docker things. Removed timeout test that was causing issues as timeout tests here are not good for running in travis. --- .gitignore | 1 + .jvmopts | 4 +- .travis.yml | 4 +- build.sbt | 60 +----- build/docker/api/Dockerfile | 4 +- build/docker/portal/Dockerfile | 4 +- docker/api/Dockerfile | 2 +- ...BatchChangeRepositoryIntegrationSpec.scala | 5 +- .../dns/DnsConversionsIntegrationSpec.scala | 5 +- .../RecordSetServiceIntegrationSpec.scala | 4 +- ...neConnectionValidatorIntegrationSpec.scala | 5 +- .../zone/ZoneServiceIntegrationSpec.scala | 6 +- .../zone/ZoneViewLoaderIntegrationSpec.scala | 5 +- .../email/EmailNotifierIntegrationSpec.scala | 5 +- .../sns/SnsNotifierIntegrationSpec.scala | 5 +- .../scala/vinyldns/api/VinylDNSConfig.scala | 42 +++- .../domain/batch/BatchChangeConverter.scala | 1 - .../vinyldns/api/metrics/APIMetrics.scala | 12 +- .../email/EmailNotifierProvider.scala | 15 +- .../api/notifier/sns/SnsNotifier.scala | 1 - .../notifier/sns/SnsNotifierProvider.scala | 12 +- .../scala/vinyldns/api/ResultHelpers.scala | 5 +- .../vinyldns/api/VinylDNSConfigSpec.scala | 5 +- .../api/backend/CommandHandlerSpec.scala | 8 +- .../api/domain/DomainValidationsSpec.scala | 8 +- .../api/domain/ReverseZoneHelpersSpec.scala | 7 +- .../domain/access/AccessValidationsSpec.scala | 8 +- .../api/domain/access/GlobalAclSpec.scala | 7 +- .../MembershipAuthPrincipalProviderSpec.scala | 7 +- .../batch/BatchChangeConverterSpec.scala | 5 +- .../domain/batch/BatchChangeInputSpec.scala | 5 +- .../batch/BatchChangeInterfacesSpec.scala | 5 +- .../domain/batch/BatchChangeServiceSpec.scala | 8 +- .../batch/BatchChangeValidationsSpec.scala | 10 +- .../batch/BatchTransformationsSpec.scala | 5 +- .../V6DiscoveryNibbleBoundariesSpec.scala | 5 +- .../api/domain/dns/DnsConnectionSpec.scala | 8 +- .../api/domain/dns/DnsConversionsSpec.scala | 8 +- .../membership/MembershipServiceSpec.scala | 8 +- .../MembershipValidationsSpec.scala | 8 +- .../domain/record/RecordSetChangeSpec.scala | 5 +- .../domain/record/RecordSetHelpersSpec.scala | 5 +- .../domain/record/RecordSetServiceSpec.scala | 8 +- .../record/RecordSetValidationsSpec.scala | 7 +- .../zone/ZoneConnectionValidatorSpec.scala | 29 +-- .../zone/ZoneRecordValidationsSpec.scala | 5 +- .../api/domain/zone/ZoneServiceSpec.scala | 8 +- .../api/domain/zone/ZoneValidationsSpec.scala | 7 +- .../api/domain/zone/ZoneViewLoaderSpec.scala | 7 +- .../api/domain/zone/ZoneViewSpec.scala | 5 +- .../api/engine/BatchChangeHandlerSpec.scala | 7 +- .../engine/RecordSetChangeHandlerSpec.scala | 8 +- .../api/engine/ZoneChangeHandlerSpec.scala | 7 +- .../api/engine/ZoneSyncHandlerSpec.scala | 8 +- .../vinyldns/api/metrics/APIMetricsSpec.scala | 7 +- .../notifier/email/EmailNotifierSpec.scala | 8 +- .../api/notifier/sns/SnsNotifierSpec.scala | 8 +- .../ApiDataAccessorProviderSpec.scala | 7 +- .../api/repository/TestDataLoaderSpec.scala | 7 +- .../api/route/ACLRuleInfoSerializerSpec.scala | 5 +- .../api/route/Aws4AuthenticatorSpec.scala | 5 +- .../route/BatchChangeJsonProtocolSpec.scala | 5 +- .../api/route/BatchChangeRoutingSpec.scala | 10 +- .../api/route/BlueGreenRoutingSpec.scala | 5 +- .../CreateGroupInputSerializerSpec.scala | 5 +- .../api/route/GroupSerializerSpec.scala | 5 +- .../api/route/HealthCheckRoutingSpec.scala | 8 +- .../api/route/JsonValidationSpec.scala | 5 +- .../api/route/MembershipRoutingSpec.scala | 8 +- .../vinyldns/api/route/PingRoutingSpec.scala | 5 +- .../api/route/PrometheusRoutingSpec.scala | 8 +- .../api/route/RecordSetRoutingSpec.scala | 5 +- .../api/route/StatusRoutingSpec.scala | 6 +- .../UpdateGroupInputSerializerSpec.scala | 5 +- .../api/route/VinylDNSAuthenticatorSpec.scala | 7 +- .../api/route/VinylDNSDirectivesSpec.scala | 8 +- .../api/route/VinylDNSJsonProtocolSpec.scala | 5 +- .../api/route/VinylDNSRouteTestHelper.scala | 8 +- .../api/route/VinylDNSServiceSpec.scala | 8 +- .../vinyldns/api/route/ZoneRoutingSpec.scala | 6 +- .../core/crypto/CryptoAlgebraSpec.scala | 5 +- .../vinyldns/core/crypto/JavaCryptoSpec.scala | 5 +- .../vinyldns/core/crypto/NoOpCryptoSpec.scala | 5 +- .../core/domain/batch/BatchChangeSpec.scala | 5 +- .../domain/batch/BatchChangeSummarySpec.scala | 5 +- .../core/domain/membership/GroupSpec.scala | 5 +- .../domain/membership/UserChangeSpec.scala | 6 +- .../membership/UserChangeTypeSpec.scala | 5 +- .../core/domain/record/ChangeSetSpec.scala | 5 +- .../core/domain/record/RecordDataSpec.scala | 5 +- .../core/domain/record/RecordSetSpec.scala | 5 +- .../core/domain/zone/ZoneACLSpec.scala | 4 +- .../core/domain/zone/ZoneChangeSpec.scala | 5 +- .../core/domain/zone/ZoneConnectionSpec.scala | 5 +- .../vinyldns/core/domain/zone/ZoneSpec.scala | 5 +- .../core/health/HealthServiceSpec.scala | 5 +- .../core/notifier/AllNotifiersSpec.scala | 7 +- .../core/notifier/NotifierLoaderSpec.scala | 7 +- .../BatchChangeProtobufConversionsSpec.scala | 6 +- .../GroupProtobufConversionsSpec.scala | 5 +- .../protobuf/ProtobufConversionsSpec.scala | 6 +- .../core/queue/MessageQueueLoaderSpec.scala | 7 +- .../core/repository/DataStoreLoaderSpec.scala | 7 +- .../repository/MockDataStoreProvider.scala | 2 +- .../vinyldns/core/route/MonitorSpec.scala | 8 +- .../core/task/TaskSchedulerSpec.scala | 12 +- ...moDBDataStoreProviderIntegrationSpec.scala | 7 +- .../repository/DynamoDBIntegrationSpec.scala | 4 +- .../DynamoDBDataStoreProvider.scala | 17 +- .../DynamoDBGroupChangeRepository.scala | 1 - .../DynamoDBMembershipRepository.scala | 1 - .../DynamoDBRecordChangeRepository.scala | 1 - .../DynamoDBRecordSetRepository.scala | 1 - .../DynamoDBUserChangeRepository.scala | 1 - .../DynamoDBZoneChangeRepository.scala | 1 - .../vinyldns/dynamodb/DynamoTestConfig.scala | 21 +- .../DynamoDBDataStoreProviderSpec.scala | 9 +- .../DynamoDBGroupChangeRepositorySpec.scala | 8 +- .../DynamoDBGroupRepositorySpec.scala | 8 +- .../repository/DynamoDBHelperSpec.scala | 8 +- .../DynamoDBMembershipRepositorySpec.scala | 8 +- .../DynamoDBRecordChangeRepositorySpec.scala | 8 +- .../DynamoDBRecordSetConversionsSpec.scala | 7 +- .../DynamoDBRecordSetRepositorySpec.scala | 8 +- .../DynamoDBUserRepositorySpec.scala | 8 +- .../DynamoDBZoneChangeRepositorySpec.scala | 8 +- .../dynamodb/repository/QueryHelperSpec.scala | 8 +- .../vinyldns/mysql/MySqlIntegrationSpec.scala | 4 +- .../MySqlMessageQueueIntegrationSpec.scala | 8 +- ...BatchChangeRepositoryIntegrationSpec.scala | 4 +- ...ySqlDataStoreProviderIntegrationSpec.scala | 5 +- ...GroupChangeRepositoryIntegrationSpec.scala | 4 +- .../MySqlGroupRepositoryIntegrationSpec.scala | 4 +- ...lMembershipRepositoryIntegrationSpec.scala | 4 +- ...ecordChangeRepositoryIntegrationSpec.scala | 6 +- ...qlRecordSetRepositoryIntegrationSpec.scala | 195 +++++++++++++----- .../MySqlTaskRepositoryIntegrationSpec.scala | 4 +- ...lUserChangeRepositoryIntegrationSpec.scala | 6 +- .../MySqlUserRepositoryIntegrationSpec.scala | 4 +- ...lZoneChangeRepositoryIntegrationSpec.scala | 4 +- .../MySqlZoneRepositoryIntegrationSpec.scala | 4 +- .../queue/MySqlMessageQueueProvider.scala | 14 +- .../repository/MySqlDataStoreProvider.scala | 12 +- .../MySqlRecordChangeRepository.scala | 1 - .../mysql/MySqlConnectionConfigSpec.scala | 19 +- .../queue/MySqlMessageQueueProviderSpec.scala | 10 +- .../MySqlDataStoreProviderSpec.scala | 11 +- .../MySqlRecordSetRepositorySpec.scala | 5 +- .../repository/MySqlZoneRepositorySpec.scala | 8 +- .../app/controllers/OidcAuthenticator.scala | 4 +- modules/portal/app/controllers/Settings.scala | 20 +- .../SqsMessageQueueIntegrationSpec.scala | 11 +- ...sMessageQueueProviderIntegrationSpec.scala | 20 +- .../sqs/queue/SqsMessageQueueProvider.scala | 13 +- .../queue/SqsMessageQueueProviderSpec.scala | 5 +- .../sqs/queue/SqsMessageQueueSpec.scala | 7 +- .../vinyldns/sqs/queue/SqsMessageSpec.scala | 6 +- .../sqs/queue/SqsMessageTypeSpec.scala | 5 +- project/Dependencies.scala | 28 +-- project/Resolvers.scala | 1 - project/build.properties | 2 +- project/plugins.sbt | 16 +- scalastyle-config.xml | 79 ------- scalastyle-test-config.xml | 81 -------- 164 files changed, 845 insertions(+), 696 deletions(-) delete mode 100644 scalastyle-config.xml delete mode 100644 scalastyle-test-config.xml diff --git a/.gitignore b/.gitignore index 32cd33d61..cdcfcb5bb 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ package-lock.json .metals tmp.out .vscode +project/metals.sbt \ No newline at end of file diff --git a/.jvmopts b/.jvmopts index 2794b30ba..ced317cdb 100644 --- a/.jvmopts +++ b/.jvmopts @@ -1,5 +1,5 @@ --Xms512M --Xmx4096M +-Xms356M +-Xmx2048M -Xss2M -XX:MaxMetaspaceSize=2048M -XX:ReservedCodeCacheSize=1024M diff --git a/.travis.yml b/.travis.yml index ce6dcd849..4ed1e15aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,11 @@ language: scala scala: -- 2.12.9 +- 2.12.11 python: - 2.7 sudo: false jdk: -- openjdk8 +- openjdk11 services: - docker cache: diff --git a/build.sbt b/build.sbt index e85bdb8f8..0ac3fd0b7 100644 --- a/build.sbt +++ b/build.sbt @@ -12,46 +12,13 @@ resolvers ++= additionalResolvers lazy val IntegrationTest = config("it") extend Test -// Needed because we want scalastyle for integration tests which is not first class -val codeStyleIntegrationTest = taskKey[Unit]("enforce code style then integration test") -def scalaStyleIntegrationTest: Seq[Def.Setting[_]] = { - inConfig(IntegrationTest)(ScalastylePlugin.rawScalastyleSettings()) ++ - Seq( - scalastyleConfig in IntegrationTest := root.base / "scalastyle-test-config.xml", - scalastyleTarget in IntegrationTest := target.value / "scalastyle-it-results.xml", - scalastyleFailOnError in IntegrationTest := (scalastyleFailOnError in scalastyle).value, - (scalastyleFailOnWarning in IntegrationTest) := (scalastyleFailOnWarning in scalastyle).value, - scalastyleSources in IntegrationTest := (unmanagedSourceDirectories in IntegrationTest).value, - codeStyleIntegrationTest := scalastyle.in(IntegrationTest).toTask("").value - ) -} - -// Create a default Scala style task to run with tests -lazy val testScalastyle = taskKey[Unit]("testScalastyle") -def scalaStyleTest: Seq[Def.Setting[_]] = Seq( - (scalastyleConfig in Test) := baseDirectory.value / ".." / ".." / "scalastyle-test-config.xml", - scalastyleTarget in Test := target.value / "scalastyle-test-results.xml", - scalastyleFailOnError in Test := (scalastyleFailOnError in scalastyle).value, - (scalastyleFailOnWarning in Test) := (scalastyleFailOnWarning in scalastyle).value, - scalastyleSources in Test := (unmanagedSourceDirectories in Test).value, - testScalastyle := scalastyle.in(Test).toTask("").value -) - -lazy val compileScalastyle = taskKey[Unit]("compileScalastyle") -def scalaStyleCompile: Seq[Def.Setting[_]] = Seq( - compileScalastyle := scalastyle.in(Compile).toTask("").value -) - -def scalaStyleSettings: Seq[Def.Setting[_]] = scalaStyleCompile ++ scalaStyleTest ++ scalaStyleIntegrationTest - // settings that should be inherited by all projects lazy val sharedSettings = Seq( organization := "vinyldns", - scalaVersion := "2.12.9", + scalaVersion := "2.12.11", organizationName := "Comcast Cable Communications Management, LLC", startYear := Some(2018), licenses += ("Apache-2.0", new URL("https://www.apache.org/licenses/LICENSE-2.0.txt")), - scalacOptions += "-target:jvm-1.8", scalacOptions ++= scalacOptionsByV(scalaVersion.value), scalacOptions in (Compile, doc) += "-no-link-warnings", // Use wart remover to eliminate code badness @@ -93,7 +60,7 @@ lazy val apiSettings = Seq( "-Dlogback.configurationFile=test/logback.xml", s"""-Dvinyldns.base-version=${(version in ThisBuild).value}""" ), - coverageExcludedPackages := ".*Boot.*" + coverageExcludedPackages := "Boot.*" ) lazy val apiAssemblySettings = Seq( @@ -113,7 +80,7 @@ lazy val apiAssemblySettings = Seq( ) lazy val apiDockerSettings = Seq( - dockerBaseImage := "openjdk:8u191-jdk-alpine3.9", + dockerBaseImage := "adoptopenjdk/openjdk11:jdk-11.0.7_10-alpine", dockerUsername := Some("vinyldns"), packageName in Docker := "api", dockerExposedPorts := Seq(9000), @@ -140,7 +107,7 @@ lazy val apiDockerSettings = Seq( ) lazy val portalDockerSettings = Seq( - dockerBaseImage := "openjdk:8u191-jdk-alpine3.9", + dockerBaseImage := "adoptopenjdk/openjdk11:jdk-11.0.7_10-alpine", dockerUsername := Some("vinyldns"), packageName in Docker := "portal", dockerExposedPorts := Seq(9001), @@ -215,8 +182,7 @@ lazy val allApiSettings = Revolver.settings ++ Defaults.itSettings ++ apiAssemblySettings ++ testSettings ++ apiPublishSettings ++ - apiDockerSettings ++ - scalaStyleSettings + apiDockerSettings lazy val api = (project in file("modules/api")) .enablePlugins(JavaAppPackaging, AutomateHeaderPlugin) @@ -236,8 +202,6 @@ lazy val root = (project in file(".")).enablePlugins(DockerComposePlugin, Automa .settings(sharedSettings) .settings( inConfig(IntegrationTest)(scalafmtConfigSettings), - (scalastyleConfig in Test) := baseDirectory.value / "scalastyle-test-config.xml", - (scalastyleConfig in IntegrationTest) := baseDirectory.value / "scalastyle-test-config.xml", killDocker := { import scala.sys.process._ "./bin/remove-vinyl-containers.sh" ! @@ -284,7 +248,6 @@ lazy val core = (project in file("modules/core")).enablePlugins(AutomateHeaderPl .settings(corePublishSettings) .settings(testSettings) .settings(libraryDependencies ++= coreDependencies ++ commonTestDependencies.map(_ % "test")) - .settings(scalaStyleCompile ++ scalaStyleTest) .settings( organization := "io.vinyldns" ) @@ -299,7 +262,6 @@ lazy val dynamodb = (project in file("modules/dynamodb")) .settings(testSettings) .settings(Defaults.itSettings) .settings(libraryDependencies ++= dynamoDBDependencies ++ commonTestDependencies.map(_ % "test, it")) - .settings(scalaStyleCompile ++ scalaStyleTest) .settings( organization := "io.vinyldns", parallelExecution in Test := true, @@ -317,7 +279,6 @@ lazy val mysql = (project in file("modules/mysql")) .settings(testSettings) .settings(Defaults.itSettings) .settings(libraryDependencies ++= mysqlDependencies ++ commonTestDependencies.map(_ % "test, it")) - .settings(scalaStyleCompile ++ scalaStyleTest) .settings( organization := "io.vinyldns" ).dependsOn(core % "compile->compile;test->test") @@ -333,7 +294,6 @@ lazy val sqs = (project in file("modules/sqs")) .settings(testSettings) .settings(Defaults.itSettings) .settings(libraryDependencies ++= sqsDependencies ++ commonTestDependencies.map(_ % "test, it")) - .settings(scalaStyleCompile ++ scalaStyleTest) .settings( organization := "io.vinyldns", ).dependsOn(core % "compile->compile;test->test") @@ -352,7 +312,7 @@ lazy val portal = (project in file("modules/portal")).enablePlugins(PlayScala, A name := "portal", libraryDependencies ++= portalDependencies, routesGenerator := InjectedRoutesGenerator, - coverageExcludedPackages := ";views.html.*;router.*", + coverageExcludedPackages := ";views.html.*;router.*;controllers\\.javascript.*;.*Reverse.*", javaOptions in Test += "-Dconfig.file=conf/application-test.conf", // ads the version when working locally with sbt run @@ -482,13 +442,7 @@ addCommandAlias("validate", "; root/clean; " + "dynamodb/headerCheck dynamodb/test:headerCheck dynamodb/it:headerCheck " + "mysql/headerCheck mysql/test:headerCheck mysql/it:headerCheck " + "sqs/headerCheck sqs/test:headerCheck sqs/it:headerCheck " + - "portal/headerCheck portal/test:headerCheck; " + - "all core/scalastyle core/test:scalastyle " + - "api/scalastyle api/test:scalastyle api/it:scalastyle " + - "dynamodb/scalastyle dynamodb/test:scalastyle dynamodb/it:scalastyle" + - "mysql/scalastyle mysql/test:scalastyle mysql/it:scalastyle" + - "sqs/scalastyle sqs/test:scalastyle sqs/it:scalastyle" + - "portal/scalastyle portal/test:scalastyle;" + + "portal/headerCheck portal/test:headerCheck; " + "portal/createJsHeaders;portal/checkJsHeaders;" + "root/compile;root/test:compile;root/it:compile" ) diff --git a/build/docker/api/Dockerfile b/build/docker/api/Dockerfile index ce58a6e57..63c5254f8 100644 --- a/build/docker/api/Dockerfile +++ b/build/docker/api/Dockerfile @@ -1,4 +1,4 @@ -FROM hseeberger/scala-sbt:8u212_1.2.8_2.12.9 as builder +FROM hseeberger/scala-sbt:11.0.7_1.3.10_2.11.12 ARG BRANCH=master ARG VINYLDNS_VERSION @@ -10,7 +10,7 @@ COPY .jvmopts /vinyldns RUN cd /vinyldns ; sbt "set version in ThisBuild := \"${VINYLDNS_VERSION}\"" api/stage -FROM openjdk:8u201-jdk-alpine3.9 +FROM adoptopenjdk/openjdk11:jdk-11.0.7_10-alpine RUN apk add --update --no-cache netcat-openbsd bash diff --git a/build/docker/portal/Dockerfile b/build/docker/portal/Dockerfile index 050c08888..16265a290 100644 --- a/build/docker/portal/Dockerfile +++ b/build/docker/portal/Dockerfile @@ -1,4 +1,4 @@ -FROM hseeberger/scala-sbt:8u212_1.2.8_2.12.9 as builder +FROM hseeberger/scala-sbt:11.0.7_1.3.10_2.11.12 as builder ARG BRANCH=master ARG VINYLDNS_VERSION @@ -20,7 +20,7 @@ RUN apt-get update \ RUN cd /vinyldns ; sbt "set version in ThisBuild := \"${VINYLDNS_VERSION}\"" portal/preparePortal universal:packageZipTarball -FROM openjdk:8u201-jdk-alpine3.9 +FROM adoptopenjdk/openjdk11:jdk-11.0.7_10-alpine RUN apk add --update --no-cache netcat-openbsd bash diff --git a/docker/api/Dockerfile b/docker/api/Dockerfile index bea7d96b6..a65b93ad4 100644 --- a/docker/api/Dockerfile +++ b/docker/api/Dockerfile @@ -1,4 +1,4 @@ -FROM openjdk:8u201-jdk-alpine3.9 +FROM adoptopenjdk/openjdk11:jdk-11.0.7_10-alpine RUN apk add --update --no-cache netcat-openbsd bash diff --git a/modules/api/src/it/scala/vinyldns/api/domain/batch/BatchChangeRepositoryIntegrationSpec.scala b/modules/api/src/it/scala/vinyldns/api/domain/batch/BatchChangeRepositoryIntegrationSpec.scala index 4c91645e5..9cc3d10f1 100644 --- a/modules/api/src/it/scala/vinyldns/api/domain/batch/BatchChangeRepositoryIntegrationSpec.scala +++ b/modules/api/src/it/scala/vinyldns/api/domain/batch/BatchChangeRepositoryIntegrationSpec.scala @@ -17,7 +17,8 @@ package vinyldns.api.domain.batch import org.joda.time.DateTime -import org.scalatest.{Matchers, WordSpecLike} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike import vinyldns.api.MySqlApiIntegrationSpec import vinyldns.core.TestMembershipData._ import vinyldns.core.domain.batch.{ @@ -33,7 +34,7 @@ class BatchChangeRepositoryIntegrationSpec extends MySqlApiIntegrationSpec with MySqlIntegrationSpec with Matchers - with WordSpecLike { + with AnyWordSpecLike { import vinyldns.api.domain.DomainValidations._ diff --git a/modules/api/src/it/scala/vinyldns/api/domain/dns/DnsConversionsIntegrationSpec.scala b/modules/api/src/it/scala/vinyldns/api/domain/dns/DnsConversionsIntegrationSpec.scala index 20a7e5bd5..f37351d1d 100644 --- a/modules/api/src/it/scala/vinyldns/api/domain/dns/DnsConversionsIntegrationSpec.scala +++ b/modules/api/src/it/scala/vinyldns/api/domain/dns/DnsConversionsIntegrationSpec.scala @@ -16,7 +16,8 @@ package vinyldns.api.domain.dns -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import org.xbill.DNS import vinyldns.api.domain.dns.DnsProtocol.{DnsResponse, NoError} import vinyldns.api.domain.record.RecordSetChangeGenerator @@ -25,7 +26,7 @@ import vinyldns.api.ResultHelpers import vinyldns.core.TestRecordSetData.{aaaa, ds} import vinyldns.core.domain.record.{RecordSet, RecordType} -class DnsConversionsIntegrationSpec extends WordSpec with Matchers with ResultHelpers { +class DnsConversionsIntegrationSpec extends AnyWordSpec with Matchers with ResultHelpers { private val zoneName = "example.com." private val testZone = Zone( diff --git a/modules/api/src/it/scala/vinyldns/api/domain/record/RecordSetServiceIntegrationSpec.scala b/modules/api/src/it/scala/vinyldns/api/domain/record/RecordSetServiceIntegrationSpec.scala index 36f2160fa..c4f34f157 100644 --- a/modules/api/src/it/scala/vinyldns/api/domain/record/RecordSetServiceIntegrationSpec.scala +++ b/modules/api/src/it/scala/vinyldns/api/domain/record/RecordSetServiceIntegrationSpec.scala @@ -20,9 +20,9 @@ import cats.effect._ import cats.scalatest.EitherMatchers import org.joda.time.DateTime import org.mockito.Mockito._ -import org.scalatest.Matchers +import org.scalatest.matchers.should.Matchers import org.scalatest.concurrent.PatienceConfiguration -import org.scalatest.mockito.MockitoSugar +import org.scalatestplus.mockito.MockitoSugar import org.scalatest.time.{Seconds, Span} import vinyldns.api.Interfaces._ import vinyldns.api._ diff --git a/modules/api/src/it/scala/vinyldns/api/domain/zone/ZoneConnectionValidatorIntegrationSpec.scala b/modules/api/src/it/scala/vinyldns/api/domain/zone/ZoneConnectionValidatorIntegrationSpec.scala index aecee47fd..b6089425d 100644 --- a/modules/api/src/it/scala/vinyldns/api/domain/zone/ZoneConnectionValidatorIntegrationSpec.scala +++ b/modules/api/src/it/scala/vinyldns/api/domain/zone/ZoneConnectionValidatorIntegrationSpec.scala @@ -16,12 +16,13 @@ package vinyldns.api.domain.zone import cats.scalatest.EitherMatchers -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.VinylDNSConfig import vinyldns.core.domain.zone.ConfiguredDnsConnections import vinyldns.core.health.HealthCheck.HealthCheckError -class ZoneConnectionValidatorIntegrationSpec extends WordSpec with Matchers with EitherMatchers { +class ZoneConnectionValidatorIntegrationSpec extends AnyWordSpec with Matchers with EitherMatchers { "ZoneConnectionValidatorIntegrationSpec" should { "have a valid health check if we can connect to DNS backend" in { val check = new ZoneConnectionValidator(VinylDNSConfig.configuredDnsConnections) diff --git a/modules/api/src/it/scala/vinyldns/api/domain/zone/ZoneServiceIntegrationSpec.scala b/modules/api/src/it/scala/vinyldns/api/domain/zone/ZoneServiceIntegrationSpec.scala index d44622c56..779684210 100644 --- a/modules/api/src/it/scala/vinyldns/api/domain/zone/ZoneServiceIntegrationSpec.scala +++ b/modules/api/src/it/scala/vinyldns/api/domain/zone/ZoneServiceIntegrationSpec.scala @@ -19,8 +19,10 @@ package vinyldns.api.domain.zone import cats.effect._ import org.joda.time.DateTime import org.scalatest._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import org.scalatest.concurrent.{PatienceConfiguration, ScalaFutures} -import org.scalatest.mockito.MockitoSugar +import org.scalatestplus.mockito.MockitoSugar import org.scalatest.time.{Seconds, Span} import scalikejdbc.DB import vinyldns.api.domain.access.AccessValidations @@ -40,7 +42,7 @@ import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.duration._ class ZoneServiceIntegrationSpec - extends WordSpec + extends AnyWordSpec with ScalaFutures with Matchers with MockitoSugar diff --git a/modules/api/src/it/scala/vinyldns/api/domain/zone/ZoneViewLoaderIntegrationSpec.scala b/modules/api/src/it/scala/vinyldns/api/domain/zone/ZoneViewLoaderIntegrationSpec.scala index 3f3478e22..7ab875962 100644 --- a/modules/api/src/it/scala/vinyldns/api/domain/zone/ZoneViewLoaderIntegrationSpec.scala +++ b/modules/api/src/it/scala/vinyldns/api/domain/zone/ZoneViewLoaderIntegrationSpec.scala @@ -16,11 +16,12 @@ package vinyldns.api.domain.zone -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import org.xbill.DNS.ZoneTransferException import vinyldns.core.domain.zone.{Zone, ZoneConnection} -class ZoneViewLoaderIntegrationSpec extends WordSpec with Matchers { +class ZoneViewLoaderIntegrationSpec extends AnyWordSpec with Matchers { "ZoneViewLoader" should { "return a ZoneView upon success" in { DnsZoneViewLoader(Zone("vinyldns.", "test@test.com")) diff --git a/modules/api/src/it/scala/vinyldns/api/notifier/email/EmailNotifierIntegrationSpec.scala b/modules/api/src/it/scala/vinyldns/api/notifier/email/EmailNotifierIntegrationSpec.scala index b36a472d7..bcc1f8a7e 100644 --- a/modules/api/src/it/scala/vinyldns/api/notifier/email/EmailNotifierIntegrationSpec.scala +++ b/modules/api/src/it/scala/vinyldns/api/notifier/email/EmailNotifierIntegrationSpec.scala @@ -20,7 +20,8 @@ import com.typesafe.config.{Config, ConfigFactory} import vinyldns.core.notifier._ import vinyldns.api.MySqlApiIntegrationSpec import vinyldns.mysql.MySqlIntegrationSpec -import org.scalatest.{Matchers, WordSpecLike} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike import vinyldns.core.domain.batch._ import vinyldns.core.domain.record.RecordType import vinyldns.core.domain.record.AData @@ -36,7 +37,7 @@ class EmailNotifierIntegrationSpec extends MySqlApiIntegrationSpec with MySqlIntegrationSpec with Matchers - with WordSpecLike + with AnyWordSpecLike with BeforeAndAfterEach { import vinyldns.api.domain.DomainValidations._ diff --git a/modules/api/src/it/scala/vinyldns/api/notifier/sns/SnsNotifierIntegrationSpec.scala b/modules/api/src/it/scala/vinyldns/api/notifier/sns/SnsNotifierIntegrationSpec.scala index 6c1aab887..508d15a04 100644 --- a/modules/api/src/it/scala/vinyldns/api/notifier/sns/SnsNotifierIntegrationSpec.scala +++ b/modules/api/src/it/scala/vinyldns/api/notifier/sns/SnsNotifierIntegrationSpec.scala @@ -20,7 +20,8 @@ import com.typesafe.config.{Config, ConfigFactory} import vinyldns.core.notifier._ import vinyldns.api.MySqlApiIntegrationSpec import vinyldns.mysql.MySqlIntegrationSpec -import org.scalatest.{Matchers, WordSpecLike} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike import vinyldns.core.domain.batch._ import vinyldns.core.domain.record.RecordType import vinyldns.core.domain.record.AData @@ -39,7 +40,7 @@ class SnsNotifierIntegrationSpec extends MySqlApiIntegrationSpec with MySqlIntegrationSpec with Matchers - with WordSpecLike { + with AnyWordSpecLike { import vinyldns.api.domain.DomainValidations._ diff --git a/modules/api/src/main/scala/vinyldns/api/VinylDNSConfig.scala b/modules/api/src/main/scala/vinyldns/api/VinylDNSConfig.scala index a4208d850..1ddb91347 100644 --- a/modules/api/src/main/scala/vinyldns/api/VinylDNSConfig.scala +++ b/modules/api/src/main/scala/vinyldns/api/VinylDNSConfig.scala @@ -17,10 +17,12 @@ package vinyldns.api import akka.actor.ActorSystem -import cats.effect.{ContextShift, IO} +import cats.effect.{Blocker, ContextShift, IO} import cats.implicits._ import com.typesafe.config.{Config, ConfigFactory} -import pureconfig.module.catseffect.loadConfigF +import pureconfig._ +import pureconfig.generic.auto._ +import pureconfig.module.catseffect.syntax._ import vinyldns.api.crypto.Crypto import com.comcast.ip4s._ import net.ceedubs.ficus.Ficus._ @@ -51,7 +53,9 @@ object VinylDNSConfig { .asScala .toList .map { configKey => - loadConfigF[IO, DataStoreConfig](vinyldnsConfig, configKey) + Blocker[IO].use( + ConfigSource.fromConfig(vinyldnsConfig).at(configKey).loadF[IO, DataStoreConfig](_) + ) } .parSequence @@ -61,14 +65,18 @@ object VinylDNSConfig { .asScala .toList .map { configKey => - loadConfigF[IO, NotifierConfig](vinyldnsConfig, configKey) + Blocker[IO].use( + ConfigSource.fromConfig(vinyldnsConfig).at(configKey).loadF[IO, NotifierConfig](_) + ) } .parSequence lazy val restConfig: Config = vinyldnsConfig.getConfig("rest") lazy val monitoringConfig: Config = vinyldnsConfig.getConfig("monitoring") lazy val messageQueueConfig: IO[MessageQueueConfig] = - loadConfigF[IO, MessageQueueConfig](vinyldnsConfig.getConfig("queue")) + Blocker[IO].use( + ConfigSource.fromConfig(vinyldnsConfig.getConfig("queue")).loadF[IO, MessageQueueConfig](_) + ) lazy val cryptoConfig: Config = vinyldnsConfig.getConfig("crypto") lazy val system: ActorSystem = ActorSystem("VinylDNS", VinylDNSConfig.config) lazy val approvedNameServers: List[Regex] = @@ -111,7 +119,7 @@ object VinylDNSConfig { .getConfigList("backends") .asScala .map { - pureconfig.loadConfigOrThrow[DnsBackend] + ConfigSource.fromConfig(_).loadOrThrow[DnsBackend] } .toList .map(_.encrypted(Crypto.instance)) @@ -122,7 +130,14 @@ object VinylDNSConfig { } lazy val healthCheckTimeout: IO[Int] = - loadConfigF[IO, Option[Int]](vinyldnsConfig, "health-check-timeout").map(_.getOrElse(10000)) + Blocker[IO].use( + ConfigSource + .fromConfig(vinyldnsConfig) + .at("health-check-timeout") + .loadF[IO, Option[Int]](_) + .map(_.getOrElse(10000)) + .handleError(_ => 10000) + ) def getOptionalStringList(key: String): List[String] = if (vinyldnsConfig.hasPath(key)) { @@ -136,12 +151,21 @@ object VinylDNSConfig { .getOrElse(false) lazy val globalAcl: IO[GlobalAcls] = - loadConfigF[IO, List[GlobalAcl]](vinyldnsConfig, "global-acl-rules").map(GlobalAcls) + Blocker[IO] + .use( + ConfigSource.fromConfig(vinyldnsConfig).at("global-acl-rules").loadF[IO, List[GlobalAcl]](_) + ) + .map(GlobalAcls(_)) // defines nibble boundary for ipv6 zone discovery // (min of 2, max of 3 means zones of form X.X.ip6-arpa. and X.X.X.ip6-arpa. will be discovered) lazy val v6DiscoveryBoundaries: IO[V6DiscoveryNibbleBoundaries] = - loadConfigF[IO, V6DiscoveryNibbleBoundaries](vinyldnsConfig, "v6-discovery-nibble-boundaries") + Blocker[IO].use( + ConfigSource + .fromConfig(vinyldnsConfig) + .at("v6-discovery-nibble-boundaries") + .loadF[IO, V6DiscoveryNibbleBoundaries](_) + ) lazy val scheduledChangesEnabled: Boolean = vinyldnsConfig .as[Option[Boolean]]("scheduled-changes-enabled") diff --git a/modules/api/src/main/scala/vinyldns/api/domain/batch/BatchChangeConverter.scala b/modules/api/src/main/scala/vinyldns/api/domain/batch/BatchChangeConverter.scala index 74f3265d6..7ddf13702 100644 --- a/modules/api/src/main/scala/vinyldns/api/domain/batch/BatchChangeConverter.scala +++ b/modules/api/src/main/scala/vinyldns/api/domain/batch/BatchChangeConverter.scala @@ -18,7 +18,6 @@ package vinyldns.api.domain.batch import cats.data.NonEmptyList import cats.syntax.list._ -import cats.syntax.functor._ import org.joda.time.DateTime import org.slf4j.LoggerFactory import vinyldns.api.domain.batch.BatchChangeInterfaces._ diff --git a/modules/api/src/main/scala/vinyldns/api/metrics/APIMetrics.scala b/modules/api/src/main/scala/vinyldns/api/metrics/APIMetrics.scala index f48e93e03..f981fd7f8 100644 --- a/modules/api/src/main/scala/vinyldns/api/metrics/APIMetrics.scala +++ b/modules/api/src/main/scala/vinyldns/api/metrics/APIMetrics.scala @@ -17,18 +17,22 @@ package vinyldns.api.metrics import java.util.concurrent.TimeUnit -import cats.effect.IO +import cats.effect.{Blocker, ContextShift, IO} import com.codahale.metrics.Slf4jReporter.LoggingLevel import com.codahale.metrics.{Metric, MetricFilter, ScheduledReporter, Slf4jReporter} import com.typesafe.config.Config import org.slf4j.LoggerFactory -import pureconfig.module.catseffect.loadConfigF +import pureconfig._ +import pureconfig.generic.auto._ +import pureconfig.module.catseffect.syntax._ import vinyldns.core.VinylDNSMetrics final case class MemoryMetricsSettings(logEnabled: Boolean, logSeconds: Int) final case class APIMetricsSettings(memory: MemoryMetricsSettings) object APIMetrics { + private implicit val cs: ContextShift[IO] = + IO.contextShift(scala.concurrent.ExecutionContext.global) // Output all memory metrics to the log, do not start unless configured private val logReporter = Slf4jReporter @@ -53,5 +57,7 @@ object APIMetrics { } def loadSettings(config: Config): IO[APIMetricsSettings] = - loadConfigF[IO, APIMetricsSettings](config) + Blocker[IO].use( + ConfigSource.fromConfig(config).loadF[IO, APIMetricsSettings](_) + ) } diff --git a/modules/api/src/main/scala/vinyldns/api/notifier/email/EmailNotifierProvider.scala b/modules/api/src/main/scala/vinyldns/api/notifier/email/EmailNotifierProvider.scala index 111eaeaab..e10768e17 100644 --- a/modules/api/src/main/scala/vinyldns/api/notifier/email/EmailNotifierProvider.scala +++ b/modules/api/src/main/scala/vinyldns/api/notifier/email/EmailNotifierProvider.scala @@ -18,22 +18,27 @@ package vinyldns.api.notifier.email import vinyldns.core.notifier.{Notifier, NotifierConfig, NotifierProvider} import vinyldns.core.domain.membership.UserRepository -import pureconfig.module.catseffect.loadConfigF -import cats.effect.IO +import pureconfig._ +import pureconfig.generic.auto._ +import pureconfig.module.catseffect.syntax._ +import cats.effect.{Blocker, ContextShift, IO} import javax.mail.Session class EmailNotifierProvider extends NotifierProvider { - import EmailNotifierConfig._ + private implicit val cs: ContextShift[IO] = + IO.contextShift(scala.concurrent.ExecutionContext.global) + def load(config: NotifierConfig, userRepository: UserRepository): IO[Notifier] = for { - emailConfig <- loadConfigF[IO, EmailNotifierConfig](config.settings) + emailConfig <- Blocker[IO].use( + ConfigSource.fromConfig(config.settings).loadF[IO, EmailNotifierConfig](_) + ) session <- createSession(emailConfig) } yield new EmailNotifier(emailConfig, session, userRepository) def createSession(config: EmailNotifierConfig): IO[Session] = IO { Session.getInstance(config.smtp) } - } diff --git a/modules/api/src/main/scala/vinyldns/api/notifier/sns/SnsNotifier.scala b/modules/api/src/main/scala/vinyldns/api/notifier/sns/SnsNotifier.scala index 6eb7bf5e8..74c34b536 100644 --- a/modules/api/src/main/scala/vinyldns/api/notifier/sns/SnsNotifier.scala +++ b/modules/api/src/main/scala/vinyldns/api/notifier/sns/SnsNotifier.scala @@ -17,7 +17,6 @@ package vinyldns.api.notifier.sns import cats.effect.IO -import cats.syntax.functor._ import com.amazonaws.services.sns.AmazonSNS import com.amazonaws.services.sns.model.{MessageAttributeValue, PublishRequest} import org.json4s.JsonAST.JNull diff --git a/modules/api/src/main/scala/vinyldns/api/notifier/sns/SnsNotifierProvider.scala b/modules/api/src/main/scala/vinyldns/api/notifier/sns/SnsNotifierProvider.scala index c4acbe064..dccd3c56d 100644 --- a/modules/api/src/main/scala/vinyldns/api/notifier/sns/SnsNotifierProvider.scala +++ b/modules/api/src/main/scala/vinyldns/api/notifier/sns/SnsNotifierProvider.scala @@ -18,8 +18,10 @@ package vinyldns.api.notifier.sns import vinyldns.core.notifier.{Notifier, NotifierConfig, NotifierProvider} import vinyldns.core.domain.membership.UserRepository -import pureconfig.module.catseffect.loadConfigF -import cats.effect.IO +import pureconfig._ +import pureconfig.generic.auto._ +import pureconfig.module.catseffect.syntax._ +import cats.effect.{Blocker, ContextShift, IO} import com.amazonaws.services.sns.AmazonSNS import org.slf4j.LoggerFactory import com.amazonaws.services.sns.AmazonSNSClientBuilder @@ -29,11 +31,15 @@ import com.amazonaws.auth.BasicAWSCredentials class SnsNotifierProvider extends NotifierProvider { + private implicit val cs: ContextShift[IO] = + IO.contextShift(scala.concurrent.ExecutionContext.global) private val logger = LoggerFactory.getLogger(classOf[SnsNotifierProvider]) def load(config: NotifierConfig, userRepository: UserRepository): IO[Notifier] = for { - snsConfig <- loadConfigF[IO, SnsNotifierConfig](config.settings) + snsConfig <- Blocker[IO].use( + ConfigSource.fromConfig(config.settings).loadF[IO, SnsNotifierConfig](_) + ) client <- createClient(snsConfig) } yield new SnsNotifier(snsConfig, client) diff --git a/modules/api/src/test/scala/vinyldns/api/ResultHelpers.scala b/modules/api/src/test/scala/vinyldns/api/ResultHelpers.scala index 6a18b6ff1..79db6ac23 100644 --- a/modules/api/src/test/scala/vinyldns/api/ResultHelpers.scala +++ b/modules/api/src/test/scala/vinyldns/api/ResultHelpers.scala @@ -21,7 +21,8 @@ import cats.data.ValidatedNel import cats.effect._ import cats.implicits._ import cats.scalatest.ValidatedMatchers -import org.scalatest.{Matchers, PropSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec import scala.concurrent.ExecutionContext import scala.concurrent.duration._ @@ -71,7 +72,7 @@ trait ResultHelpers { def rightValue[T](t: Either[Throwable, T]): T = t.toOption.get } -object ValidationTestImprovements extends PropSpec with Matchers with ValidatedMatchers { +object ValidationTestImprovements extends AnyPropSpec with Matchers with ValidatedMatchers { implicit class ValidatedNelTestImprovements[DomainValidationError, A]( value: ValidatedNel[DomainValidationError, A] diff --git a/modules/api/src/test/scala/vinyldns/api/VinylDNSConfigSpec.scala b/modules/api/src/test/scala/vinyldns/api/VinylDNSConfigSpec.scala index 4c29ad0c2..3a8f80b07 100644 --- a/modules/api/src/test/scala/vinyldns/api/VinylDNSConfigSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/VinylDNSConfigSpec.scala @@ -16,12 +16,13 @@ package vinyldns.api -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.crypto.Crypto import vinyldns.core.domain.zone.ZoneConnection import vinyldns.core.repository.RepositoryName._ -class VinylDNSConfigSpec extends WordSpec with Matchers { +class VinylDNSConfigSpec extends AnyWordSpec with Matchers { "VinylDNSConfig" should { "load the rest config" in { diff --git a/modules/api/src/test/scala/vinyldns/api/backend/CommandHandlerSpec.scala b/modules/api/src/test/scala/vinyldns/api/backend/CommandHandlerSpec.scala index f3485a6b5..0fcd533bd 100644 --- a/modules/api/src/test/scala/vinyldns/api/backend/CommandHandlerSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/backend/CommandHandlerSpec.scala @@ -22,8 +22,10 @@ import org.mockito import org.mockito.Matchers._ import org.mockito.Mockito._ import org.mockito.{ArgumentCaptor, Mockito} -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, EitherValues, Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.{BeforeAndAfterEach, EitherValues} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.VinylDNSTestHelpers import vinyldns.api.backend.CommandHandler.{DeleteMessage, RetryMessage} import vinyldns.api.domain.dns.DnsConnection @@ -39,7 +41,7 @@ import scala.concurrent.duration._ import vinyldns.core.notifier.AllNotifiers class CommandHandlerSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with BeforeAndAfterEach diff --git a/modules/api/src/test/scala/vinyldns/api/domain/DomainValidationsSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/DomainValidationsSpec.scala index e7f34196c..0e1a931aa 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/DomainValidationsSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/DomainValidationsSpec.scala @@ -18,15 +18,17 @@ package vinyldns.api.domain import cats.scalatest.ValidatedMatchers import org.scalacheck._ +import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks import org.scalatest._ -import org.scalatest.prop._ +import org.scalatest.propspec.AnyPropSpec +import org.scalatest.matchers.should.Matchers import vinyldns.api.ValidationTestImprovements._ import vinyldns.core.domain.{InvalidDomainName, InvalidLength} class DomainValidationsSpec - extends PropSpec + extends AnyPropSpec with Matchers - with GeneratorDrivenPropertyChecks + with ScalaCheckDrivenPropertyChecks with ValidatedMatchers { import Gen._ diff --git a/modules/api/src/test/scala/vinyldns/api/domain/ReverseZoneHelpersSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/ReverseZoneHelpersSpec.scala index 4bf319625..028baad95 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/ReverseZoneHelpersSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/ReverseZoneHelpersSpec.scala @@ -19,8 +19,9 @@ package vinyldns.api.domain import cats.scalatest.EitherMatchers import org.joda.time.DateTime import org.scalatest.concurrent.Eventually -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.domain.record._ import vinyldns.api.domain.zone.InvalidRequest import vinyldns.api.ResultHelpers @@ -29,7 +30,7 @@ import vinyldns.core.TestZoneData._ import vinyldns.core.domain.zone.Zone class ReverseZoneHelpersSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with Eventually diff --git a/modules/api/src/test/scala/vinyldns/api/domain/access/AccessValidationsSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/access/AccessValidationsSpec.scala index 6258d08f2..390933b43 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/access/AccessValidationsSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/access/AccessValidationsSpec.scala @@ -18,8 +18,9 @@ package vinyldns.api.domain.access import cats.scalatest.EitherMatchers import org.joda.time.DateTime -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{Matchers, WordSpecLike} + +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.ResultHelpers import vinyldns.api.domain.zone.{NotAuthorizedError, RecordSetInfo, RecordSetListInfo} import vinyldns.core.TestMembershipData._ @@ -30,9 +31,10 @@ import vinyldns.core.domain.auth.AuthPrincipal import vinyldns.core.domain.membership.User import vinyldns.core.domain.record._ import vinyldns.core.domain.zone.{ACLRule, AccessLevel, Zone, ZoneACL} +import org.scalatestplus.mockito.MockitoSugar class AccessValidationsSpec - extends WordSpecLike + extends AnyWordSpec with Matchers with MockitoSugar with ResultHelpers diff --git a/modules/api/src/test/scala/vinyldns/api/domain/access/GlobalAclSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/access/GlobalAclSpec.scala index b3eed408e..78e627cd0 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/access/GlobalAclSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/access/GlobalAclSpec.scala @@ -17,14 +17,15 @@ package vinyldns.api.domain.access import cats.scalatest.EitherMatchers -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{Matchers, WordSpecLike} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.ResultHelpers import vinyldns.core.domain.Fqdn import vinyldns.core.domain.record.{PTRData, RecordType} class GlobalAclSpec - extends WordSpecLike + extends AnyWordSpec with Matchers with MockitoSugar with ResultHelpers diff --git a/modules/api/src/test/scala/vinyldns/api/domain/auth/MembershipAuthPrincipalProviderSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/auth/MembershipAuthPrincipalProviderSpec.scala index f54f16fe4..6558c1c69 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/auth/MembershipAuthPrincipalProviderSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/auth/MembershipAuthPrincipalProviderSpec.scala @@ -18,8 +18,9 @@ package vinyldns.api.domain.auth import org.mockito.Matchers._ import org.mockito.Mockito._ -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.ResultHelpers import vinyldns.core.TestMembershipData._ import vinyldns.core.domain.membership.{MembershipRepository, UserRepository} @@ -27,7 +28,7 @@ import cats.effect._ import vinyldns.core.domain.auth.AuthPrincipal class MembershipAuthPrincipalProviderSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with ResultHelpers { diff --git a/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchChangeConverterSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchChangeConverterSpec.scala index f59f47dd1..ba3d9bcf2 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchChangeConverterSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchChangeConverterSpec.scala @@ -19,7 +19,8 @@ package vinyldns.api.domain.batch import cats.data.NonEmptyList import cats.implicits._ import org.joda.time.DateTime -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.CatsHelpers import vinyldns.api.domain.batch.BatchTransformations._ import vinyldns.api.domain.batch.BatchTransformations.LogicalChangeType._ @@ -35,7 +36,7 @@ import vinyldns.core.domain.record.RecordType.{RecordType, _} import vinyldns.core.domain.record._ import vinyldns.core.domain.zone.Zone -class BatchChangeConverterSpec extends WordSpec with Matchers with CatsHelpers { +class BatchChangeConverterSpec extends AnyWordSpec with Matchers with CatsHelpers { private def makeSingleAddChange( name: String, diff --git a/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchChangeInputSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchChangeInputSpec.scala index e7fa337cb..5b07ba12c 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchChangeInputSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchChangeInputSpec.scala @@ -18,14 +18,15 @@ package vinyldns.api.domain.batch import cats.data.NonEmptyList import org.joda.time.DateTime -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.VinylDNSConfig import vinyldns.core.domain.{DomainValidationErrorType, Fqdn, SingleChangeError, ZoneDiscoveryError} import vinyldns.core.domain.batch._ import vinyldns.core.domain.record.RecordType._ import vinyldns.core.domain.record.{AAAAData, AData, CNAMEData} -class BatchChangeInputSpec extends WordSpec with Matchers { +class BatchChangeInputSpec extends AnyWordSpec with Matchers { "BatchChangeInput" should { "ensure trailing dot on A, AAAA, and CNAME fqdn" in { val changeA = AddChangeInput("apex.test.com", A, Some(100), AData("1.1.1.1")) diff --git a/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchChangeInterfacesSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchChangeInterfacesSpec.scala index 0dfe6f0be..fffcd46dd 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchChangeInterfacesSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchChangeInterfacesSpec.scala @@ -16,14 +16,15 @@ package vinyldns.api.domain.batch -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.CatsHelpers import vinyldns.api.domain.batch.BatchChangeInterfaces._ import cats.effect._ import cats.implicits._ import vinyldns.core.domain.{BatchChangeIsEmpty, ChangeLimitExceeded} -class BatchChangeInterfacesSpec extends WordSpec with Matchers with CatsHelpers { +class BatchChangeInterfacesSpec extends AnyWordSpec with Matchers with CatsHelpers { "toBatchResult" should { "work with either success input" in { diff --git a/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchChangeServiceSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchChangeServiceSpec.scala index f0762acd1..8fa234507 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchChangeServiceSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchChangeServiceSpec.scala @@ -21,8 +21,10 @@ import cats.effect._ import cats.implicits._ import cats.scalatest.{EitherMatchers, ValidatedMatchers} import org.joda.time.DateTime -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, EitherValues, Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.{BeforeAndAfterEach, EitherValues} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.ValidatedBatchMatcherImprovements.containChangeForValidation import vinyldns.api._ import vinyldns.api.domain.auth.AuthPrincipalProvider @@ -52,7 +54,7 @@ import vinyldns.api.domain.access.AccessValidations import scala.concurrent.ExecutionContext class BatchChangeServiceSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with CatsHelpers diff --git a/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchChangeValidationsSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchChangeValidationsSpec.scala index 0251b0741..12b2c0bc7 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchChangeValidationsSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchChangeValidationsSpec.scala @@ -20,8 +20,10 @@ import cats.implicits._ import cats.scalatest.{EitherMatchers, ValidatedMatchers} import org.joda.time.DateTime import org.scalacheck.Gen -import org.scalatest.prop.GeneratorDrivenPropertyChecks -import org.scalatest.{EitherValues, Matchers, PropSpec} +import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks +import org.scalatest.EitherValues +import org.scalatest.matchers.should.Matchers +import org.scalatest.propspec.AnyPropSpec import vinyldns.api.domain.access.AccessValidations import vinyldns.api.domain.batch.BatchTransformations._ import vinyldns.api.domain.{DomainValidations, batch} @@ -37,9 +39,9 @@ import vinyldns.core.domain.zone.{ACLRule, AccessLevel, Zone, ZoneStatus} import scala.util.Random class BatchChangeValidationsSpec - extends PropSpec + extends AnyPropSpec with Matchers - with GeneratorDrivenPropertyChecks + with ScalaCheckDrivenPropertyChecks with EitherMatchers with EitherValues with ValidatedMatchers { diff --git a/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchTransformationsSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchTransformationsSpec.scala index 828127d58..7d8e6af30 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchTransformationsSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/batch/BatchTransformationsSpec.scala @@ -16,11 +16,12 @@ package vinyldns.api.domain.batch -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.domain.batch.BatchTransformations.ExistingZones import vinyldns.core.domain.zone.Zone -class BatchTransformationsSpec extends WordSpec with Matchers { +class BatchTransformationsSpec extends AnyWordSpec with Matchers { "ExistingZones" should { val ip4base1 = Zone("1.2.3.in-addr.arpa.", "test") diff --git a/modules/api/src/test/scala/vinyldns/api/domain/batch/V6DiscoveryNibbleBoundariesSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/batch/V6DiscoveryNibbleBoundariesSpec.scala index f4e645c2a..f21a02e3c 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/batch/V6DiscoveryNibbleBoundariesSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/batch/V6DiscoveryNibbleBoundariesSpec.scala @@ -16,9 +16,10 @@ package vinyldns.api.domain.batch -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class V6DiscoveryNibbleBoundariesSpec extends WordSpec with Matchers { +class V6DiscoveryNibbleBoundariesSpec extends AnyWordSpec with Matchers { "V6DiscoveryNibbleBoundaries" should { "Succeed with valid input" in { noException should be thrownBy V6DiscoveryNibbleBoundaries(2, 10) diff --git a/modules/api/src/test/scala/vinyldns/api/domain/dns/DnsConnectionSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/dns/DnsConnectionSpec.scala index 307c80a32..167b01bfd 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/dns/DnsConnectionSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/dns/DnsConnectionSpec.scala @@ -23,8 +23,10 @@ import org.joda.time.DateTime import org.mockito.ArgumentCaptor import org.mockito.Matchers._ import org.mockito.Mockito._ -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatest.BeforeAndAfterEach +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import org.xbill.DNS import org.xbill.DNS.{Lookup, Name} import vinyldns.api.ResultHelpers @@ -37,7 +39,7 @@ import vinyldns.core.domain.zone.{Zone, ZoneConnection} import scala.collection.JavaConverters._ class DnsConnectionSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with ResultHelpers diff --git a/modules/api/src/test/scala/vinyldns/api/domain/dns/DnsConversionsSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/dns/DnsConversionsSpec.scala index ea750bda1..4a9ddbd0d 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/dns/DnsConversionsSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/dns/DnsConversionsSpec.scala @@ -20,8 +20,10 @@ import java.net.InetAddress import org.joda.time.DateTime import org.mockito.Mockito._ -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatest.BeforeAndAfterEach +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import org.xbill.DNS import vinyldns.api.ResultHelpers import vinyldns.api.domain.dns.DnsProtocol._ @@ -33,7 +35,7 @@ import vinyldns.core.domain.Fqdn import scala.collection.JavaConverters._ class DnsConversionsSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with ResultHelpers diff --git a/modules/api/src/test/scala/vinyldns/api/domain/membership/MembershipServiceSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/membership/MembershipServiceSpec.scala index fa7823a2e..ff49c4bb6 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/membership/MembershipServiceSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/membership/MembershipServiceSpec.scala @@ -20,8 +20,10 @@ import cats.scalatest.EitherMatchers import org.mockito.ArgumentCaptor import org.mockito.Matchers._ import org.mockito.Mockito._ -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec +import org.scalatest.BeforeAndAfterEach import vinyldns.api.Interfaces._ import vinyldns.api.ResultHelpers import vinyldns.core.domain.auth.AuthPrincipal @@ -34,7 +36,7 @@ import vinyldns.core.domain.membership._ import vinyldns.core.domain.record.RecordSetRepository class MembershipServiceSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with BeforeAndAfterEach diff --git a/modules/api/src/test/scala/vinyldns/api/domain/membership/MembershipValidationsSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/membership/MembershipValidationsSpec.scala index 37017c54f..1488264d4 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/membership/MembershipValidationsSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/membership/MembershipValidationsSpec.scala @@ -17,8 +17,10 @@ package vinyldns.api.domain.membership import cats.scalatest.EitherMatchers -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpecLike} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.BeforeAndAfterEach +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.ResultHelpers import vinyldns.core.TestMembershipData._ import vinyldns.core.domain.auth.AuthPrincipal @@ -26,7 +28,7 @@ import vinyldns.api.domain.zone.NotAuthorizedError import vinyldns.core.domain.membership.User class MembershipValidationsSpec - extends WordSpecLike + extends AnyWordSpec with Matchers with MockitoSugar with BeforeAndAfterEach diff --git a/modules/api/src/test/scala/vinyldns/api/domain/record/RecordSetChangeSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/record/RecordSetChangeSpec.scala index 28e176ef1..a964cc154 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/record/RecordSetChangeSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/record/RecordSetChangeSpec.scala @@ -16,13 +16,14 @@ package vinyldns.api.domain.record -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.TestMembershipData.okAuth import vinyldns.core.TestRecordSetData._ import vinyldns.core.TestZoneData.okZone import vinyldns.core.domain.record.{AData, RecordSet} -class RecordSetChangeSpec extends WordSpec with Matchers { +class RecordSetChangeSpec extends AnyWordSpec with Matchers { val apexRs: RecordSet = rsOk.copy(name = "@") diff --git a/modules/api/src/test/scala/vinyldns/api/domain/record/RecordSetHelpersSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/record/RecordSetHelpersSpec.scala index 89366672d..f0157434d 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/record/RecordSetHelpersSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/record/RecordSetHelpersSpec.scala @@ -16,14 +16,15 @@ package vinyldns.api.domain.record -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.domain.record.RecordSetHelpers._ import vinyldns.core.TestRecordSetData._ import vinyldns.core.TestZoneData._ import vinyldns.core.domain.Fqdn import vinyldns.core.domain.record._ -class RecordSetHelpersSpec extends WordSpec with Matchers { +class RecordSetHelpersSpec extends AnyWordSpec with Matchers { "RecordSetHelpers" should { "matches" should { diff --git a/modules/api/src/test/scala/vinyldns/api/domain/record/RecordSetServiceSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/record/RecordSetServiceSpec.scala index 5076dbe0a..bbf3912d9 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/record/RecordSetServiceSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/record/RecordSetServiceSpec.scala @@ -20,8 +20,10 @@ import cats.effect._ import cats.scalatest.EitherMatchers import org.mockito.Matchers.any import org.mockito.Mockito.doReturn -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec +import org.scalatest.BeforeAndAfterEach import vinyldns.api.Interfaces._ import vinyldns.api.ResultHelpers import vinyldns.api.domain.access.AccessValidations @@ -40,7 +42,7 @@ import vinyldns.core.domain.zone._ import vinyldns.core.queue.MessageQueue class RecordSetServiceSpec - extends WordSpec + extends AnyWordSpec with EitherMatchers with Matchers with MockitoSugar diff --git a/modules/api/src/test/scala/vinyldns/api/domain/record/RecordSetValidationsSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/record/RecordSetValidationsSpec.scala index 9502f164a..a38cb2a80 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/record/RecordSetValidationsSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/record/RecordSetValidationsSpec.scala @@ -18,8 +18,9 @@ package vinyldns.api.domain.record import cats.scalatest.EitherMatchers import org.joda.time.DateTime -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.domain.record.RecordType._ import vinyldns.api.domain.zone.{ InvalidGroupError, @@ -36,7 +37,7 @@ import vinyldns.core.domain.membership.Group import vinyldns.core.domain.record._ class RecordSetValidationsSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with ResultHelpers diff --git a/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneConnectionValidatorSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneConnectionValidatorSpec.scala index b59a09498..44d7a5058 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneConnectionValidatorSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneConnectionValidatorSpec.scala @@ -19,8 +19,10 @@ package vinyldns.api.domain.zone import cats.scalatest.{EitherMatchers, EitherValues} import org.joda.time.DateTime import org.mockito.Mockito._ -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec +import org.scalatest.BeforeAndAfterEach import vinyldns.api.Interfaces._ import vinyldns.api.domain.dns.DnsConnection import vinyldns.api.domain.dns.DnsProtocol.TypeNotFound @@ -33,7 +35,7 @@ import vinyldns.core.domain.zone.{ConfiguredDnsConnections, DnsBackend, Zone, Zo import scala.concurrent.duration._ class ZoneConnectionValidatorSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with BeforeAndAfterEach @@ -58,7 +60,7 @@ class ZoneConnectionValidatorSpec case "error." => IO.raiseError(new RuntimeException("transfer connection failure!")) case "timeout." => IO { - Thread.sleep(100) + Thread.sleep(200) mockZoneView } case _ => @@ -241,25 +243,6 @@ class ZoneConnectionValidatorSpec result.getMessage should include("transfer connection failure!") } - "respond with a failure if loadDns times out" in { - val badZone = Zone( - "timeout.", - "test@test.com", - connection = - Some(ZoneConnection("vinyldns.", "vinyldns.", "nzisn+4G2ldMn0q1CV3vsg==", "10.1.1.1")), - transferConnection = - Some(ZoneConnection("vinyldns.", "vinyldns.", "nzisn+4G2ldMn0q1CV3vsg==", "10.1.1.1")) - ) - - doReturn(List(mockRecordSet).toResult) - .when(mockDnsConnection) - .resolve(badZone.name, badZone.name, RecordType.SOA) - - val result = underTest.validateZoneConnections(badZone).value.unsafeRunSync() - val error = result.leftValue - error shouldBe a[ConnectionFailed] - error.getMessage should include("Transfer connection invalid") - } "isValidBackendId" should { val backend = DnsBackend("some-test-backend", testDefaultConnection, testDefaultConnection) val underTest = diff --git a/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneRecordValidationsSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneRecordValidationsSpec.scala index 7a8bc6b99..89e2d1629 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneRecordValidationsSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneRecordValidationsSpec.scala @@ -18,7 +18,8 @@ package vinyldns.api.domain.zone import cats.scalatest.ValidatedMatchers import com.comcast.ip4s._ -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.domain.{ DomainValidationError, Fqdn, @@ -28,7 +29,7 @@ import vinyldns.core.domain.{ import vinyldns.core.domain.record._ import vinyldns.core.TestRecordSetData._ -class ZoneRecordValidationsSpec extends WordSpec with Matchers with ValidatedMatchers { +class ZoneRecordValidationsSpec extends AnyWordSpec with Matchers with ValidatedMatchers { import vinyldns.api.domain.zone.ZoneRecordValidations._ diff --git a/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneServiceSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneServiceSpec.scala index 703a5f33c..a114f00df 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneServiceSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneServiceSpec.scala @@ -18,12 +18,14 @@ package vinyldns.api.domain.zone import org.mockito.Matchers.{any, anyString} import org.mockito.Mockito.{doReturn, reset} -import org.scalatest._ -import org.scalatest.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec +import org.scalatestplus.mockito.MockitoSugar import cats.implicits._ import vinyldns.api.Interfaces._ import vinyldns.api.ResultHelpers import cats.effect._ +import org.scalatest.{BeforeAndAfterEach, EitherValues} import vinyldns.api.domain.access.AccessValidations import vinyldns.api.repository.TestDataLoader import vinyldns.core.domain.auth.AuthPrincipal @@ -36,7 +38,7 @@ import vinyldns.core.TestZoneData._ import scala.concurrent.duration._ class ZoneServiceSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with ResultHelpers diff --git a/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneValidationsSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneValidationsSpec.scala index a670bd73f..bd899a4ef 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneValidationsSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneValidationsSpec.scala @@ -18,15 +18,16 @@ package vinyldns.api.domain.zone import cats.scalatest.EitherMatchers import org.joda.time.DateTime -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.ResultHelpers import vinyldns.core.TestZoneData._ import vinyldns.core.domain.record._ import vinyldns.core.domain.zone.{ACLRule, ZoneACL} class ZoneValidationsSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with ResultHelpers diff --git a/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneViewLoaderSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneViewLoaderSpec.scala index 08cfb8069..7b5ce4cdf 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneViewLoaderSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneViewLoaderSpec.scala @@ -22,8 +22,9 @@ import org.joda.time.DateTime import org.mockito.Matchers._ import org.mockito.Mockito._ import org.scalatest.concurrent.ScalaFutures.whenReady -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import org.xbill.DNS import org.xbill.DNS.{Name, ZoneTransferIn} import vinyldns.api.domain.dns.DnsConversions @@ -37,7 +38,7 @@ import vinyldns.core.domain.record.NameSort.NameSort import vinyldns.core.domain.record.RecordType.RecordType import vinyldns.core.domain.zone.{Zone, ZoneConnection, ZoneStatus} -class ZoneViewLoaderSpec extends WordSpec with Matchers with MockitoSugar with DnsConversions { +class ZoneViewLoaderSpec extends AnyWordSpec with Matchers with MockitoSugar with DnsConversions { val testZoneName = "vinyldns." val testZoneConnection: Option[ZoneConnection] = Some( diff --git a/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneViewSpec.scala b/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneViewSpec.scala index 0fe70fc12..de183ee0e 100644 --- a/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneViewSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/domain/zone/ZoneViewSpec.scala @@ -17,13 +17,14 @@ package vinyldns.api.domain.zone import org.joda.time.DateTime -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.VinylDNSTestHelpers import vinyldns.api.domain.record.RecordSetChangeGenerator import vinyldns.core.domain.record._ import vinyldns.core.domain.zone.Zone -class ZoneViewSpec extends WordSpec with Matchers with VinylDNSTestHelpers { +class ZoneViewSpec extends AnyWordSpec with Matchers with VinylDNSTestHelpers { val testZone = Zone("vinyldns.", "test@test.com") diff --git a/modules/api/src/test/scala/vinyldns/api/engine/BatchChangeHandlerSpec.scala b/modules/api/src/test/scala/vinyldns/api/engine/BatchChangeHandlerSpec.scala index 09b1521e5..5708fc88a 100644 --- a/modules/api/src/test/scala/vinyldns/api/engine/BatchChangeHandlerSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/engine/BatchChangeHandlerSpec.scala @@ -20,8 +20,9 @@ import cats.effect._ import org.joda.time.DateTime import org.mockito.Matchers.any import org.mockito.Mockito.{doReturn, verify} -import org.scalatest.{BeforeAndAfterEach, WordSpec} -import org.scalatest.mockito.MockitoSugar +import org.scalatest.BeforeAndAfterEach +import org.scalatest.wordspec.AnyWordSpec +import org.scalatestplus.mockito.MockitoSugar import vinyldns.api.CatsHelpers import vinyldns.api.repository.InMemoryBatchChangeRepository import vinyldns.core.domain.batch._ @@ -31,7 +32,7 @@ import vinyldns.core.notifier.{AllNotifiers, Notification, Notifier} import scala.concurrent.ExecutionContext class BatchChangeHandlerSpec - extends WordSpec + extends AnyWordSpec with MockitoSugar with BeforeAndAfterEach with CatsHelpers { diff --git a/modules/api/src/test/scala/vinyldns/api/engine/RecordSetChangeHandlerSpec.scala b/modules/api/src/test/scala/vinyldns/api/engine/RecordSetChangeHandlerSpec.scala index 89986bdb8..d43911d65 100644 --- a/modules/api/src/test/scala/vinyldns/api/engine/RecordSetChangeHandlerSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/engine/RecordSetChangeHandlerSpec.scala @@ -21,8 +21,10 @@ import org.joda.time.DateTime import org.mockito.ArgumentCaptor import org.mockito.Matchers._ import org.mockito.Mockito._ -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec +import org.scalatest.BeforeAndAfterEach import org.xbill.DNS import vinyldns.api.domain.dns.DnsConnection import vinyldns.api.domain.dns.DnsProtocol.{NoError, NotAuthorized, Refused, TryAgain} @@ -43,7 +45,7 @@ import scala.concurrent.ExecutionContext import cats.effect.ContextShift class RecordSetChangeHandlerSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with BeforeAndAfterEach diff --git a/modules/api/src/test/scala/vinyldns/api/engine/ZoneChangeHandlerSpec.scala b/modules/api/src/test/scala/vinyldns/api/engine/ZoneChangeHandlerSpec.scala index 78e4c51d0..7109f1c83 100644 --- a/modules/api/src/test/scala/vinyldns/api/engine/ZoneChangeHandlerSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/engine/ZoneChangeHandlerSpec.scala @@ -20,14 +20,15 @@ import cats.effect._ import org.mockito.ArgumentCaptor import org.mockito.Matchers._ import org.mockito.Mockito._ -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.TestZoneData.zoneChangePending import vinyldns.core.domain.record.RecordSetRepository import vinyldns.core.domain.zone.ZoneRepository.DuplicateZoneError import vinyldns.core.domain.zone._ -class ZoneChangeHandlerSpec extends WordSpec with Matchers with MockitoSugar { +class ZoneChangeHandlerSpec extends AnyWordSpec with Matchers with MockitoSugar { trait Fixture { val mockZoneRepo = mock[ZoneRepository] diff --git a/modules/api/src/test/scala/vinyldns/api/engine/ZoneSyncHandlerSpec.scala b/modules/api/src/test/scala/vinyldns/api/engine/ZoneSyncHandlerSpec.scala index 998af86a7..c85162c5f 100644 --- a/modules/api/src/test/scala/vinyldns/api/engine/ZoneSyncHandlerSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/engine/ZoneSyncHandlerSpec.scala @@ -21,8 +21,10 @@ import org.joda.time.DateTime import org.mockito.ArgumentCaptor import org.mockito.Matchers.any import org.mockito.Mockito.{doReturn, reset, times, verify} -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec +import org.scalatest.BeforeAndAfterEach import vinyldns.api.VinylDNSTestHelpers import vinyldns.api.domain.record.RecordSetChangeGenerator import vinyldns.api.domain.zone.{DnsZoneViewLoader, VinylDNSZoneViewLoader, ZoneView} @@ -34,7 +36,7 @@ import vinyldns.core.domain.zone.ZoneRepository.DuplicateZoneError import vinyldns.core.domain.zone._ class ZoneSyncHandlerSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with BeforeAndAfterEach diff --git a/modules/api/src/test/scala/vinyldns/api/metrics/APIMetricsSpec.scala b/modules/api/src/test/scala/vinyldns/api/metrics/APIMetricsSpec.scala index e51f0fa20..29d8ed96a 100644 --- a/modules/api/src/test/scala/vinyldns/api/metrics/APIMetricsSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/metrics/APIMetricsSpec.scala @@ -21,11 +21,12 @@ import cats.scalatest.EitherMatchers import com.codahale.metrics.ScheduledReporter import com.typesafe.config.ConfigFactory import org.mockito.Mockito._ -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.VinylDNSConfig -class APIMetricsSpec extends WordSpec with Matchers with MockitoSugar with EitherMatchers { +class APIMetricsSpec extends AnyWordSpec with Matchers with MockitoSugar with EitherMatchers { "APIMetricsSettings" should { "succeed with valid config" in { diff --git a/modules/api/src/test/scala/vinyldns/api/notifier/email/EmailNotifierSpec.scala b/modules/api/src/test/scala/vinyldns/api/notifier/email/EmailNotifierSpec.scala index 3f30ea0a9..e3e26ba05 100644 --- a/modules/api/src/test/scala/vinyldns/api/notifier/email/EmailNotifierSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/notifier/email/EmailNotifierSpec.scala @@ -15,8 +15,10 @@ */ package vinyldns.api.notifier.email -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} -import org.scalatest.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec +import org.scalatest.BeforeAndAfterEach +import org.scalatestplus.mockito.MockitoSugar import vinyldns.api.CatsHelpers import javax.mail.{Provider, Session, Transport, URLName} import java.util.Properties @@ -56,7 +58,7 @@ class MockTransport(session: Session, urlname: URLName) extends Transport(sessio } class EmailNotifierSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with BeforeAndAfterEach diff --git a/modules/api/src/test/scala/vinyldns/api/notifier/sns/SnsNotifierSpec.scala b/modules/api/src/test/scala/vinyldns/api/notifier/sns/SnsNotifierSpec.scala index b680dfbd9..5729c6993 100644 --- a/modules/api/src/test/scala/vinyldns/api/notifier/sns/SnsNotifierSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/notifier/sns/SnsNotifierSpec.scala @@ -15,8 +15,10 @@ */ package vinyldns.api.notifier.sns -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} -import org.scalatest.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec +import org.scalatest.BeforeAndAfterEach +import org.scalatestplus.mockito.MockitoSugar import vinyldns.api.CatsHelpers import vinyldns.core.domain.membership.UserRepository import vinyldns.core.notifier.Notification @@ -42,7 +44,7 @@ import com.amazonaws.services.sns.model.PublishRequest import com.amazonaws.services.sns.model.PublishResult class SnsNotifierSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with BeforeAndAfterEach diff --git a/modules/api/src/test/scala/vinyldns/api/repository/ApiDataAccessorProviderSpec.scala b/modules/api/src/test/scala/vinyldns/api/repository/ApiDataAccessorProviderSpec.scala index 8ec0c77f8..bd3109af9 100644 --- a/modules/api/src/test/scala/vinyldns/api/repository/ApiDataAccessorProviderSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/repository/ApiDataAccessorProviderSpec.scala @@ -18,8 +18,9 @@ package vinyldns.api.repository import cats.scalatest.ValidatedMatchers import com.typesafe.config.{Config, ConfigFactory} -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.domain.batch.BatchChangeRepository import vinyldns.core.domain.membership.{ GroupChangeRepository, @@ -32,7 +33,7 @@ import vinyldns.core.domain.zone.{ZoneChangeRepository, ZoneRepository} import vinyldns.core.repository.{DataStore, DataStoreConfig, RepositoriesConfig} class ApiDataAccessorProviderSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with ValidatedMatchers { diff --git a/modules/api/src/test/scala/vinyldns/api/repository/TestDataLoaderSpec.scala b/modules/api/src/test/scala/vinyldns/api/repository/TestDataLoaderSpec.scala index 9bae8038a..8b74f78bc 100644 --- a/modules/api/src/test/scala/vinyldns/api/repository/TestDataLoaderSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/repository/TestDataLoaderSpec.scala @@ -19,15 +19,16 @@ package vinyldns.api.repository import java.util.UUID import cats.effect.IO -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import org.mockito.Matchers._ import org.mockito.Mockito._ import vinyldns.core.domain.membership._ import vinyldns.core.domain.zone.{Zone, ZoneRepository} import vinyldns.core.TestMembershipData._ -class TestDataLoaderSpec extends WordSpec with Matchers with MockitoSugar { +class TestDataLoaderSpec extends AnyWordSpec with Matchers with MockitoSugar { val userRepo: UserRepository = mock[UserRepository] doReturn(IO.pure(okUser)).when(userRepo).save(any[User]) diff --git a/modules/api/src/test/scala/vinyldns/api/route/ACLRuleInfoSerializerSpec.scala b/modules/api/src/test/scala/vinyldns/api/route/ACLRuleInfoSerializerSpec.scala index acf841cac..ab9a5c56d 100644 --- a/modules/api/src/test/scala/vinyldns/api/route/ACLRuleInfoSerializerSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/route/ACLRuleInfoSerializerSpec.scala @@ -19,12 +19,13 @@ package vinyldns.api.route import cats.scalatest.{ValidatedMatchers, ValidatedValues} import org.json4s.JsonDSL._ import org.json4s.{Extraction, Serializer => json4sSerializer} -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.domain.record.RecordType import vinyldns.core.domain.zone.AccessLevel class ACLRuleInfoSerializerSpec - extends WordSpec + extends AnyWordSpec with ACLJsonProtocol with Matchers with ValidatedMatchers diff --git a/modules/api/src/test/scala/vinyldns/api/route/Aws4AuthenticatorSpec.scala b/modules/api/src/test/scala/vinyldns/api/route/Aws4AuthenticatorSpec.scala index 9b6a7ac89..fda9e6a7e 100644 --- a/modules/api/src/test/scala/vinyldns/api/route/Aws4AuthenticatorSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/route/Aws4AuthenticatorSpec.scala @@ -17,9 +17,10 @@ package vinyldns.api.route import akka.http.scaladsl.model.{ContentTypes, HttpEntity, HttpRequest} -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class Aws4AuthenticatorSpec extends WordSpec with Matchers { +class Aws4AuthenticatorSpec extends AnyWordSpec with Matchers { "getting canonical headers" should { "pull the content type" in { diff --git a/modules/api/src/test/scala/vinyldns/api/route/BatchChangeJsonProtocolSpec.scala b/modules/api/src/test/scala/vinyldns/api/route/BatchChangeJsonProtocolSpec.scala index b244123f9..4d3a55cac 100644 --- a/modules/api/src/test/scala/vinyldns/api/route/BatchChangeJsonProtocolSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/route/BatchChangeJsonProtocolSpec.scala @@ -23,7 +23,8 @@ import org.joda.time.DateTime import org.json4s.Extraction._ import org.json4s.JsonDSL._ import org.json4s._ -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.domain._ import vinyldns.api.domain.batch.BatchTransformations.{AddChangeForValidation, ChangeForValidation} import vinyldns.api.domain.batch.ChangeInputType._ @@ -43,7 +44,7 @@ import vinyldns.core.domain.record.RecordType._ import vinyldns.core.domain.record._ class BatchChangeJsonProtocolSpec - extends WordSpec + extends AnyWordSpec with Matchers with BatchChangeJsonProtocol with ValidatedValues diff --git a/modules/api/src/test/scala/vinyldns/api/route/BatchChangeRoutingSpec.scala b/modules/api/src/test/scala/vinyldns/api/route/BatchChangeRoutingSpec.scala index 1dd91e894..a6b2bdb6d 100644 --- a/modules/api/src/test/scala/vinyldns/api/route/BatchChangeRoutingSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/route/BatchChangeRoutingSpec.scala @@ -27,8 +27,10 @@ import org.joda.time.DateTime import org.json4s.JsonDSL._ import org.json4s._ import org.json4s.jackson.JsonMethods._ -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec +import org.scalatest.BeforeAndAfterEach import vinyldns.api.domain.batch._ import vinyldns.core.TestMembershipData._ import vinyldns.core.domain.BatchChangeIsEmpty @@ -39,7 +41,7 @@ import vinyldns.core.domain.record.RecordType._ import vinyldns.core.domain.record._ class BatchChangeRoutingSpec() - extends WordSpec + extends AnyWordSpec with ScalatestRouteTest with MockitoSugar with VinylDNSJsonProtocol @@ -542,12 +544,10 @@ class BatchChangeRoutingSpec() "return a 400 BadRequest for scheduled change disabled" in { val scheduledDisabledRequest = buildValidBatchChangeInputJson("scheduledDisabledRequest") - Post("/zones/batchrecordchanges").withEntity( HttpEntity(ContentTypes.`application/json`, scheduledDisabledRequest) ) ~> Route.seal(batchChangeRoute) ~> check { - response.entity.toString should include(ScheduledChangesDisabled.message) status shouldBe BadRequest } diff --git a/modules/api/src/test/scala/vinyldns/api/route/BlueGreenRoutingSpec.scala b/modules/api/src/test/scala/vinyldns/api/route/BlueGreenRoutingSpec.scala index 8c715318e..7aba2363a 100644 --- a/modules/api/src/test/scala/vinyldns/api/route/BlueGreenRoutingSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/route/BlueGreenRoutingSpec.scala @@ -19,10 +19,11 @@ package vinyldns.api.route import akka.actor.ActorSystem import akka.http.scaladsl.model.StatusCodes import akka.http.scaladsl.testkit.ScalatestRouteTest -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec class BlueGreenRoutingSpec - extends WordSpec + extends AnyWordSpec with ScalatestRouteTest with BlueGreenRoute with Matchers { diff --git a/modules/api/src/test/scala/vinyldns/api/route/CreateGroupInputSerializerSpec.scala b/modules/api/src/test/scala/vinyldns/api/route/CreateGroupInputSerializerSpec.scala index 26015d6a7..20a262d0f 100644 --- a/modules/api/src/test/scala/vinyldns/api/route/CreateGroupInputSerializerSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/route/CreateGroupInputSerializerSpec.scala @@ -20,11 +20,12 @@ import cats.scalatest.ValidatedMatchers import org.json4s.JsonDSL._ import org.json4s._ import org.json4s.jackson.JsonMethods._ -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.domain.membership.UserId class CreateGroupInputSerializerSpec - extends WordSpec + extends AnyWordSpec with MembershipJsonProtocol with Matchers with ValidatedMatchers { diff --git a/modules/api/src/test/scala/vinyldns/api/route/GroupSerializerSpec.scala b/modules/api/src/test/scala/vinyldns/api/route/GroupSerializerSpec.scala index 00263c89a..46f7c7db6 100644 --- a/modules/api/src/test/scala/vinyldns/api/route/GroupSerializerSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/route/GroupSerializerSpec.scala @@ -20,11 +20,12 @@ import cats.scalatest.{ValidatedMatchers, ValidatedValues} import org.joda.time.DateTime import org.json4s.JsonDSL._ import org.json4s._ -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.domain.membership.GroupStatus class GroupSerializerSpec - extends WordSpec + extends AnyWordSpec with MembershipJsonProtocol with Matchers with ValidatedMatchers diff --git a/modules/api/src/test/scala/vinyldns/api/route/HealthCheckRoutingSpec.scala b/modules/api/src/test/scala/vinyldns/api/route/HealthCheckRoutingSpec.scala index 93a584e23..914a2cc34 100644 --- a/modules/api/src/test/scala/vinyldns/api/route/HealthCheckRoutingSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/route/HealthCheckRoutingSpec.scala @@ -19,14 +19,16 @@ package vinyldns.api.route import akka.http.scaladsl.model.StatusCodes import akka.http.scaladsl.testkit.ScalatestRouteTest import org.mockito.Mockito.doReturn -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{Matchers, OneInstancePerTest, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.OneInstancePerTest +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import cats.effect._ import vinyldns.core.health.HealthCheck.HealthCheckError import vinyldns.core.health.HealthService class HealthCheckRoutingSpec - extends WordSpec + extends AnyWordSpec with ScalatestRouteTest with HealthCheckRoute with OneInstancePerTest diff --git a/modules/api/src/test/scala/vinyldns/api/route/JsonValidationSpec.scala b/modules/api/src/test/scala/vinyldns/api/route/JsonValidationSpec.scala index b17638855..ff445bf52 100644 --- a/modules/api/src/test/scala/vinyldns/api/route/JsonValidationSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/route/JsonValidationSpec.scala @@ -22,7 +22,8 @@ import org.json4s._ import org.json4s.JsonDSL._ import org.json4s.jackson.JsonMethods._ import org.scalatest.Matchers -import org.scalatest.WordSpec +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import cats.implicits._ @@ -49,7 +50,7 @@ case class Pet(typ: PetType, name: String) case class User(name: String, pet: Option[Pet], home: Home, typ: UserType) class JsonValidationSpec - extends WordSpec + extends AnyWordSpec with JsonValidation with ScalatestRouteTest with Matchers { diff --git a/modules/api/src/test/scala/vinyldns/api/route/MembershipRoutingSpec.scala b/modules/api/src/test/scala/vinyldns/api/route/MembershipRoutingSpec.scala index 9fa5d36af..71d9d35c3 100644 --- a/modules/api/src/test/scala/vinyldns/api/route/MembershipRoutingSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/route/MembershipRoutingSpec.scala @@ -26,8 +26,10 @@ import org.json4s.jackson.JsonMethods._ import org.mockito.ArgumentCaptor import org.mockito.Matchers._ import org.mockito.Mockito._ -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec +import org.scalatest.BeforeAndAfterEach import vinyldns.api.Interfaces._ import vinyldns.api.domain.membership._ import vinyldns.api.domain.zone.NotAuthorizedError @@ -38,7 +40,7 @@ import vinyldns.core.domain.membership.LockStatus.LockStatus import vinyldns.core.domain.membership.{Group, LockStatus} class MembershipRoutingSpec - extends WordSpec + extends AnyWordSpec with ScalatestRouteTest with VinylDNSJsonProtocol with VinylDNSRouteTestHelper diff --git a/modules/api/src/test/scala/vinyldns/api/route/PingRoutingSpec.scala b/modules/api/src/test/scala/vinyldns/api/route/PingRoutingSpec.scala index ac3b44c3e..21875264c 100644 --- a/modules/api/src/test/scala/vinyldns/api/route/PingRoutingSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/route/PingRoutingSpec.scala @@ -19,9 +19,10 @@ package vinyldns.api.route import akka.actor.ActorSystem import akka.http.scaladsl.model.StatusCodes import akka.http.scaladsl.testkit.ScalatestRouteTest -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class PingRoutingSpec extends WordSpec with ScalatestRouteTest with PingRoute with Matchers { +class PingRoutingSpec extends AnyWordSpec with ScalatestRouteTest with PingRoute with Matchers { def actorRefFactory: ActorSystem = system diff --git a/modules/api/src/test/scala/vinyldns/api/route/PrometheusRoutingSpec.scala b/modules/api/src/test/scala/vinyldns/api/route/PrometheusRoutingSpec.scala index ab35178a2..ad105d45b 100644 --- a/modules/api/src/test/scala/vinyldns/api/route/PrometheusRoutingSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/route/PrometheusRoutingSpec.scala @@ -20,12 +20,14 @@ import akka.http.scaladsl.model.{HttpProtocol, HttpResponse, StatusCodes} import akka.http.scaladsl.testkit.ScalatestRouteTest import io.prometheus.client.CollectorRegistry import io.prometheus.client.dropwizard.DropwizardExports -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec +import org.scalatest.BeforeAndAfterEach import vinyldns.core.VinylDNSMetrics class PrometheusRoutingSpec - extends WordSpec + extends AnyWordSpec with ScalatestRouteTest with PrometheusRoute with BeforeAndAfterEach diff --git a/modules/api/src/test/scala/vinyldns/api/route/RecordSetRoutingSpec.scala b/modules/api/src/test/scala/vinyldns/api/route/RecordSetRoutingSpec.scala index 0317fc39a..bb4447cc0 100644 --- a/modules/api/src/test/scala/vinyldns/api/route/RecordSetRoutingSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/route/RecordSetRoutingSpec.scala @@ -23,7 +23,8 @@ import org.joda.time.DateTime import org.json4s.JsonDSL._ import org.json4s._ import org.json4s.jackson.JsonMethods._ -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.Interfaces._ import vinyldns.api.domain.record.{ListRecordSetChangesResponse, RecordSetServiceAlgebra} import vinyldns.api.domain.zone._ @@ -39,7 +40,7 @@ import vinyldns.core.domain.zone._ import scala.util.Random class RecordSetRoutingSpec - extends WordSpec + extends AnyWordSpec with ScalatestRouteTest with VinylDNSJsonProtocol with VinylDNSRouteTestHelper diff --git a/modules/api/src/test/scala/vinyldns/api/route/StatusRoutingSpec.scala b/modules/api/src/test/scala/vinyldns/api/route/StatusRoutingSpec.scala index 42a0db605..ad20e99ef 100644 --- a/modules/api/src/test/scala/vinyldns/api/route/StatusRoutingSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/route/StatusRoutingSpec.scala @@ -22,10 +22,12 @@ import akka.http.scaladsl.testkit.ScalatestRouteTest import cats.effect.{ContextShift, IO} import fs2.concurrent.SignallingRef import org.scalatest._ -import org.scalatest.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec +import org.scalatestplus.mockito.MockitoSugar class StatusRoutingSpec - extends WordSpec + extends AnyWordSpec with ScalatestRouteTest with StatusRoute with OneInstancePerTest diff --git a/modules/api/src/test/scala/vinyldns/api/route/UpdateGroupInputSerializerSpec.scala b/modules/api/src/test/scala/vinyldns/api/route/UpdateGroupInputSerializerSpec.scala index 0c6cd141a..0088fe7db 100644 --- a/modules/api/src/test/scala/vinyldns/api/route/UpdateGroupInputSerializerSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/route/UpdateGroupInputSerializerSpec.scala @@ -20,11 +20,12 @@ import cats.scalatest.ValidatedMatchers import org.json4s.JsonDSL._ import org.json4s._ import org.json4s.jackson.JsonMethods._ -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.domain.membership.UserId class UpdateGroupInputSerializerSpec - extends WordSpec + extends AnyWordSpec with MembershipJsonProtocol with Matchers with ValidatedMatchers { diff --git a/modules/api/src/test/scala/vinyldns/api/route/VinylDNSAuthenticatorSpec.scala b/modules/api/src/test/scala/vinyldns/api/route/VinylDNSAuthenticatorSpec.scala index 3f17325e5..ac4620cf4 100644 --- a/modules/api/src/test/scala/vinyldns/api/route/VinylDNSAuthenticatorSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/route/VinylDNSAuthenticatorSpec.scala @@ -21,14 +21,15 @@ import akka.http.scaladsl.server.RequestContext import cats.effect._ import org.mockito.Matchers._ import org.mockito.Mockito._ -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.domain.auth.AuthPrincipalProvider import vinyldns.core.TestMembershipData._ import vinyldns.core.crypto.CryptoAlgebra import vinyldns.core.domain.auth.AuthPrincipal -class VinylDNSAuthenticatorSpec extends WordSpec with Matchers with MockitoSugar { +class VinylDNSAuthenticatorSpec extends AnyWordSpec with Matchers with MockitoSugar { private val mockAuthenticator = mock[Aws4Authenticator] private val mockAuthPrincipalProvider = mock[AuthPrincipalProvider] diff --git a/modules/api/src/test/scala/vinyldns/api/route/VinylDNSDirectivesSpec.scala b/modules/api/src/test/scala/vinyldns/api/route/VinylDNSDirectivesSpec.scala index a31e6af36..d3928e102 100644 --- a/modules/api/src/test/scala/vinyldns/api/route/VinylDNSDirectivesSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/route/VinylDNSDirectivesSpec.scala @@ -24,15 +24,17 @@ import akka.http.scaladsl.testkit.ScalatestRouteTest import nl.grons.metrics.scala.{Histogram, Meter} import org.mockito.Matchers._ import org.mockito.Mockito._ -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, Matchers, OneInstancePerTest, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.{BeforeAndAfterEach, OneInstancePerTest} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.domain.zone.ZoneServiceAlgebra import vinyldns.core.route.Monitor import scala.util.Failure class VinylDNSDirectivesSpec - extends WordSpec + extends AnyWordSpec with ScalatestRouteTest with Matchers with MockitoSugar diff --git a/modules/api/src/test/scala/vinyldns/api/route/VinylDNSJsonProtocolSpec.scala b/modules/api/src/test/scala/vinyldns/api/route/VinylDNSJsonProtocolSpec.scala index 47c3f64ca..64b8b3f8a 100644 --- a/modules/api/src/test/scala/vinyldns/api/route/VinylDNSJsonProtocolSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/route/VinylDNSJsonProtocolSpec.scala @@ -20,7 +20,8 @@ import cats.scalatest.ValidatedValues import org.joda.time.DateTime import org.json4s.JsonDSL._ import org.json4s._ -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.VinylDNSTestHelpers import vinyldns.core.domain.record._ import vinyldns.core.domain.zone.{CreateZoneInput, UpdateZoneInput, ZoneConnection} @@ -28,7 +29,7 @@ import vinyldns.core.TestRecordSetData._ import vinyldns.core.domain.Fqdn class VinylDNSJsonProtocolSpec - extends WordSpec + extends AnyWordSpec with Matchers with VinylDNSJsonProtocol with ValidatedValues diff --git a/modules/api/src/test/scala/vinyldns/api/route/VinylDNSRouteTestHelper.scala b/modules/api/src/test/scala/vinyldns/api/route/VinylDNSRouteTestHelper.scala index cda216a54..edc68f318 100644 --- a/modules/api/src/test/scala/vinyldns/api/route/VinylDNSRouteTestHelper.scala +++ b/modules/api/src/test/scala/vinyldns/api/route/VinylDNSRouteTestHelper.scala @@ -18,9 +18,15 @@ package vinyldns.api.route import akka.http.scaladsl.model.{ContentTypes, HttpEntity, HttpResponse, StatusCodes} import akka.http.scaladsl.server.Directives.{complete, extractUnmatchedPath} import akka.http.scaladsl.server.{MalformedRequestContentRejection, RejectionHandler} +import akka.http.scaladsl.testkit.ScalatestRouteTest import org.json4s.MappingException -trait VinylDNSRouteTestHelper { +trait VinylDNSRouteTestHelper { this: ScalatestRouteTest => + import scala.concurrent.duration._ + import akka.http.scaladsl.testkit.RouteTestTimeout + + implicit val testTimeout = RouteTestTimeout(10.seconds) + implicit def validationRejectionHandler: RejectionHandler = RejectionHandler .newBuilder() diff --git a/modules/api/src/test/scala/vinyldns/api/route/VinylDNSServiceSpec.scala b/modules/api/src/test/scala/vinyldns/api/route/VinylDNSServiceSpec.scala index 6a5e571bc..ad498347a 100644 --- a/modules/api/src/test/scala/vinyldns/api/route/VinylDNSServiceSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/route/VinylDNSServiceSpec.scala @@ -21,12 +21,14 @@ import akka.http.scaladsl.model._ import akka.http.scaladsl.model.headers.RawHeader import akka.http.scaladsl.server.Route import akka.http.scaladsl.server.directives.LogEntry -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{Matchers, OneInstancePerTest, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.OneInstancePerTest +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.domain.auth.AuthPrincipal class VinylDNSServiceSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with OneInstancePerTest diff --git a/modules/api/src/test/scala/vinyldns/api/route/ZoneRoutingSpec.scala b/modules/api/src/test/scala/vinyldns/api/route/ZoneRoutingSpec.scala index 06fd10e49..bc0f62edf 100644 --- a/modules/api/src/test/scala/vinyldns/api/route/ZoneRoutingSpec.scala +++ b/modules/api/src/test/scala/vinyldns/api/route/ZoneRoutingSpec.scala @@ -23,7 +23,9 @@ import akka.http.scaladsl.testkit.ScalatestRouteTest import org.json4s.JsonDSL._ import org.json4s._ import org.json4s.jackson.JsonMethods._ -import org.scalatest.{Matchers, OneInstancePerTest, WordSpec} +import org.scalatest.OneInstancePerTest +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.api.Interfaces._ import vinyldns.api.crypto.Crypto import vinyldns.api.domain.zone.{ZoneServiceAlgebra, _} @@ -34,7 +36,7 @@ import vinyldns.core.domain.record.RecordType import vinyldns.core.domain.zone._ class ZoneRoutingSpec - extends WordSpec + extends AnyWordSpec with ScalatestRouteTest with VinylDNSJsonProtocol with VinylDNSRouteTestHelper diff --git a/modules/core/src/test/scala/vinyldns/core/crypto/CryptoAlgebraSpec.scala b/modules/core/src/test/scala/vinyldns/core/crypto/CryptoAlgebraSpec.scala index 460ea3ba0..f0fff76f2 100644 --- a/modules/core/src/test/scala/vinyldns/core/crypto/CryptoAlgebraSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/crypto/CryptoAlgebraSpec.scala @@ -19,16 +19,17 @@ package vinyldns.core.crypto import java.lang.reflect.InvocationTargetException import com.typesafe.config.{Config, ConfigException, ConfigFactory} -import org.scalatest.{Matchers, WordSpec} import scala.collection.JavaConverters._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec class TestCrypto(config: Config) extends CryptoAlgebra { val testMe: String = config.getString("test-me") def encrypt(value: String): String = value def decrypt(value: String): String = value } -class CryptoAlgebraSpec extends WordSpec with Matchers { +class CryptoAlgebraSpec extends AnyWordSpec with Matchers { private val conf = """ diff --git a/modules/core/src/test/scala/vinyldns/core/crypto/JavaCryptoSpec.scala b/modules/core/src/test/scala/vinyldns/core/crypto/JavaCryptoSpec.scala index 81a0ca8b2..eb2455adf 100644 --- a/modules/core/src/test/scala/vinyldns/core/crypto/JavaCryptoSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/crypto/JavaCryptoSpec.scala @@ -17,9 +17,10 @@ package vinyldns.core.crypto import com.typesafe.config._ -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class JavaCryptoSpec extends WordSpec with Matchers { +class JavaCryptoSpec extends AnyWordSpec with Matchers { val unencryptedString = s"""Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore diff --git a/modules/core/src/test/scala/vinyldns/core/crypto/NoOpCryptoSpec.scala b/modules/core/src/test/scala/vinyldns/core/crypto/NoOpCryptoSpec.scala index 3d4bd6e9e..9c43ff504 100644 --- a/modules/core/src/test/scala/vinyldns/core/crypto/NoOpCryptoSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/crypto/NoOpCryptoSpec.scala @@ -17,9 +17,10 @@ package vinyldns.core.crypto import com.typesafe.config.ConfigFactory -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class NoOpCryptoSpec extends WordSpec with Matchers { +class NoOpCryptoSpec extends AnyWordSpec with Matchers { private val conf = """ diff --git a/modules/core/src/test/scala/vinyldns/core/domain/batch/BatchChangeSpec.scala b/modules/core/src/test/scala/vinyldns/core/domain/batch/BatchChangeSpec.scala index 2028a6192..cb4e2f1dd 100644 --- a/modules/core/src/test/scala/vinyldns/core/domain/batch/BatchChangeSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/domain/batch/BatchChangeSpec.scala @@ -17,10 +17,11 @@ package vinyldns.core.domain.batch import org.joda.time.DateTime -import org.scalatest.{Matchers, WordSpec} import vinyldns.core.domain.record.{AData, RecordType} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class BatchChangeSpec extends WordSpec with Matchers { +class BatchChangeSpec extends AnyWordSpec with Matchers { private val pendingChange = SingleAddChange( Some("zoneid"), Some("zonename"), diff --git a/modules/core/src/test/scala/vinyldns/core/domain/batch/BatchChangeSummarySpec.scala b/modules/core/src/test/scala/vinyldns/core/domain/batch/BatchChangeSummarySpec.scala index 4e21e3bf3..40e636ffb 100644 --- a/modules/core/src/test/scala/vinyldns/core/domain/batch/BatchChangeSummarySpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/domain/batch/BatchChangeSummarySpec.scala @@ -17,10 +17,11 @@ package vinyldns.core.domain.batch import org.joda.time.DateTime -import org.scalatest.{Matchers, WordSpec} import vinyldns.core.domain.record.{AData, RecordType} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class BatchChangeSummarySpec extends WordSpec with Matchers { +class BatchChangeSummarySpec extends AnyWordSpec with Matchers { private val pendingChange = SingleAddChange( Some("zoneid"), Some("zonename"), diff --git a/modules/core/src/test/scala/vinyldns/core/domain/membership/GroupSpec.scala b/modules/core/src/test/scala/vinyldns/core/domain/membership/GroupSpec.scala index 907a5afa1..64a265282 100644 --- a/modules/core/src/test/scala/vinyldns/core/domain/membership/GroupSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/domain/membership/GroupSpec.scala @@ -15,10 +15,11 @@ */ package vinyldns.core.domain.membership -import org.scalatest.{Matchers, WordSpec} import vinyldns.core.TestMembershipData._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class GroupSpec extends WordSpec with Matchers { +class GroupSpec extends AnyWordSpec with Matchers { "Group" should { "correctly adds a user as a member" in { val newGroup = emptyGroup.addMember(okUser) diff --git a/modules/core/src/test/scala/vinyldns/core/domain/membership/UserChangeSpec.scala b/modules/core/src/test/scala/vinyldns/core/domain/membership/UserChangeSpec.scala index cc69c9566..1cb853a1a 100644 --- a/modules/core/src/test/scala/vinyldns/core/domain/membership/UserChangeSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/domain/membership/UserChangeSpec.scala @@ -17,9 +17,11 @@ package vinyldns.core.domain.membership import cats.scalatest.EitherMatchers import org.joda.time.DateTime -import org.scalatest.{EitherValues, Matchers, WordSpec} +import org.scalatest.EitherValues +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class UserChangeSpec extends WordSpec with Matchers with EitherMatchers with EitherValues { +class UserChangeSpec extends AnyWordSpec with Matchers with EitherMatchers with EitherValues { private val newUser = User("foo", "key", "secret") private val currentDate = DateTime.now diff --git a/modules/core/src/test/scala/vinyldns/core/domain/membership/UserChangeTypeSpec.scala b/modules/core/src/test/scala/vinyldns/core/domain/membership/UserChangeTypeSpec.scala index 3733b8d82..b2fe3c2b6 100644 --- a/modules/core/src/test/scala/vinyldns/core/domain/membership/UserChangeTypeSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/domain/membership/UserChangeTypeSpec.scala @@ -15,10 +15,11 @@ */ package vinyldns.core.domain.membership -import org.scalatest.{Matchers, WordSpec} import vinyldns.core.domain.membership.UserChangeType.UnknownUserChangeType +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class UserChangeTypeSpec extends WordSpec with Matchers { +class UserChangeTypeSpec extends AnyWordSpec with Matchers { "fromString" should { "succeed for Create" in { UserChangeType.fromString("create") shouldBe Right(UserChangeType.Create) diff --git a/modules/core/src/test/scala/vinyldns/core/domain/record/ChangeSetSpec.scala b/modules/core/src/test/scala/vinyldns/core/domain/record/ChangeSetSpec.scala index e26ba5687..60880d946 100644 --- a/modules/core/src/test/scala/vinyldns/core/domain/record/ChangeSetSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/domain/record/ChangeSetSpec.scala @@ -16,9 +16,10 @@ package vinyldns.core.domain.record -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class ChangeSetSpec extends WordSpec with Matchers { +class ChangeSetSpec extends AnyWordSpec with Matchers { "ChangeSet" should { "convert status fromInt properly" in { diff --git a/modules/core/src/test/scala/vinyldns/core/domain/record/RecordDataSpec.scala b/modules/core/src/test/scala/vinyldns/core/domain/record/RecordDataSpec.scala index 97f568518..96d7a6b33 100644 --- a/modules/core/src/test/scala/vinyldns/core/domain/record/RecordDataSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/domain/record/RecordDataSpec.scala @@ -16,10 +16,11 @@ package vinyldns.core.domain.record -import org.scalatest.{Matchers, WordSpec} import vinyldns.core.domain.record.DnsSecAlgorithm._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class RecordDataSpec extends WordSpec with Matchers { +class RecordDataSpec extends AnyWordSpec with Matchers { "DigestType" should { "Properly convert from int" in { diff --git a/modules/core/src/test/scala/vinyldns/core/domain/record/RecordSetSpec.scala b/modules/core/src/test/scala/vinyldns/core/domain/record/RecordSetSpec.scala index 94ff0dd61..6953ce154 100644 --- a/modules/core/src/test/scala/vinyldns/core/domain/record/RecordSetSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/domain/record/RecordSetSpec.scala @@ -16,11 +16,12 @@ package vinyldns.core.domain.record -import org.scalatest.{Matchers, WordSpec} import vinyldns.core.TestRecordSetData._ import vinyldns.core.domain.Fqdn +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class RecordSetSpec extends WordSpec with Matchers { +class RecordSetSpec extends AnyWordSpec with Matchers { "RecordSetHelpers" should { "toString" should { diff --git a/modules/core/src/test/scala/vinyldns/core/domain/zone/ZoneACLSpec.scala b/modules/core/src/test/scala/vinyldns/core/domain/zone/ZoneACLSpec.scala index 05cac307f..dc23611ab 100644 --- a/modules/core/src/test/scala/vinyldns/core/domain/zone/ZoneACLSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/domain/zone/ZoneACLSpec.scala @@ -18,8 +18,10 @@ package vinyldns.core.domain.zone import org.scalatest._ import vinyldns.core.TestZoneData._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class ZoneACLSpec extends WordSpec with Matchers { +class ZoneACLSpec extends AnyWordSpec with Matchers { "ZoneACL" should { "add a new ACL rule" in { diff --git a/modules/core/src/test/scala/vinyldns/core/domain/zone/ZoneChangeSpec.scala b/modules/core/src/test/scala/vinyldns/core/domain/zone/ZoneChangeSpec.scala index 13a864351..76d70dd80 100644 --- a/modules/core/src/test/scala/vinyldns/core/domain/zone/ZoneChangeSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/domain/zone/ZoneChangeSpec.scala @@ -17,9 +17,10 @@ package vinyldns.core.domain.zone import org.joda.time.DateTime -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class ZoneChangeSpec extends WordSpec with Matchers { +class ZoneChangeSpec extends AnyWordSpec with Matchers { val zoneCreate: ZoneChange = ZoneChange( Zone("test", "test"), diff --git a/modules/core/src/test/scala/vinyldns/core/domain/zone/ZoneConnectionSpec.scala b/modules/core/src/test/scala/vinyldns/core/domain/zone/ZoneConnectionSpec.scala index 31da55a43..d536dfd0d 100644 --- a/modules/core/src/test/scala/vinyldns/core/domain/zone/ZoneConnectionSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/domain/zone/ZoneConnectionSpec.scala @@ -17,10 +17,11 @@ package vinyldns.core.domain.zone import cats.scalatest.EitherMatchers -import org.scalatest.{Matchers, WordSpec} import vinyldns.core.crypto.CryptoAlgebra +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class ZoneConnectionSpec extends WordSpec with Matchers with EitherMatchers { +class ZoneConnectionSpec extends AnyWordSpec with Matchers with EitherMatchers { val testCrypto = new CryptoAlgebra { def encrypt(value: String): String = "encrypted!" diff --git a/modules/core/src/test/scala/vinyldns/core/domain/zone/ZoneSpec.scala b/modules/core/src/test/scala/vinyldns/core/domain/zone/ZoneSpec.scala index a117c98d7..39a3584c2 100644 --- a/modules/core/src/test/scala/vinyldns/core/domain/zone/ZoneSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/domain/zone/ZoneSpec.scala @@ -17,10 +17,11 @@ package vinyldns.core.domain.zone import org.joda.time.DateTime -import org.scalatest.{Matchers, WordSpec} import vinyldns.core.TestZoneData._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class ZoneSpec extends WordSpec with Matchers { +class ZoneSpec extends AnyWordSpec with Matchers { "Zone" should { "toString should output a zone properly" in { diff --git a/modules/core/src/test/scala/vinyldns/core/health/HealthServiceSpec.scala b/modules/core/src/test/scala/vinyldns/core/health/HealthServiceSpec.scala index 0577379f1..dc887c516 100644 --- a/modules/core/src/test/scala/vinyldns/core/health/HealthServiceSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/health/HealthServiceSpec.scala @@ -17,10 +17,11 @@ package vinyldns.core.health import cats.effect._ -import org.scalatest.{Matchers, WordSpec} import vinyldns.core.health.HealthCheck._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class HealthServiceSpec extends WordSpec with Matchers { +class HealthServiceSpec extends AnyWordSpec with Matchers { "Checking Status" should { val successCheck: HealthCheck = IO.unit.attempt.asHealthCheck diff --git a/modules/core/src/test/scala/vinyldns/core/notifier/AllNotifiersSpec.scala b/modules/core/src/test/scala/vinyldns/core/notifier/AllNotifiersSpec.scala index 49ddbcba2..ca8aaf81e 100644 --- a/modules/core/src/test/scala/vinyldns/core/notifier/AllNotifiersSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/notifier/AllNotifiersSpec.scala @@ -17,15 +17,16 @@ package vinyldns.core.notifier import cats.scalatest.{EitherMatchers, EitherValues, ValidatedMatchers} -import org.scalatest.mockito._ -import org.scalatest.{Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar import org.mockito.Mockito._ import cats.effect.IO import org.scalatest.BeforeAndAfterEach import cats.effect.ContextShift +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec class AllNotifiersSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with EitherValues diff --git a/modules/core/src/test/scala/vinyldns/core/notifier/NotifierLoaderSpec.scala b/modules/core/src/test/scala/vinyldns/core/notifier/NotifierLoaderSpec.scala index ddbdf7ab2..849d46948 100644 --- a/modules/core/src/test/scala/vinyldns/core/notifier/NotifierLoaderSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/notifier/NotifierLoaderSpec.scala @@ -18,8 +18,7 @@ package vinyldns.core.notifier import cats.scalatest.{EitherMatchers, EitherValues, ValidatedMatchers} import com.typesafe.config.{Config, ConfigFactory} -import org.scalatest.mockito._ -import org.scalatest.{Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar import vinyldns.core.domain.membership.UserRepository import cats.effect.IO import org.mockito.Mockito._ @@ -27,6 +26,8 @@ import org.mockito.Mockito._ import scala.collection.JavaConverters._ import org.scalatest.BeforeAndAfterEach import cats.effect.ContextShift +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec object MockNotifierProvider extends MockitoSugar { @@ -48,7 +49,7 @@ class FailingProvider extends NotifierProvider { } class NotifierLoaderSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with EitherValues diff --git a/modules/core/src/test/scala/vinyldns/core/protobuf/BatchChangeProtobufConversionsSpec.scala b/modules/core/src/test/scala/vinyldns/core/protobuf/BatchChangeProtobufConversionsSpec.scala index c4f416440..902a4e9de 100644 --- a/modules/core/src/test/scala/vinyldns/core/protobuf/BatchChangeProtobufConversionsSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/protobuf/BatchChangeProtobufConversionsSpec.scala @@ -17,13 +17,15 @@ package vinyldns.core.protobuf import cats.scalatest.EitherMatchers -import org.scalatest.{EitherValues, Matchers, WordSpec} +import org.scalatest.EitherValues import vinyldns.core.domain.{HighValueDomainError, SingleChangeError, ZoneDiscoveryError} import vinyldns.core.domain.batch.{SingleAddChange, SingleChangeStatus, SingleDeleteRRSetChange} import vinyldns.core.domain.record.{AData, RecordType} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec class BatchChangeProtobufConversionsSpec - extends WordSpec + extends AnyWordSpec with Matchers with BatchChangeProtobufConversions with EitherMatchers diff --git a/modules/core/src/test/scala/vinyldns/core/protobuf/GroupProtobufConversionsSpec.scala b/modules/core/src/test/scala/vinyldns/core/protobuf/GroupProtobufConversionsSpec.scala index c9d7c3bf9..375acf792 100644 --- a/modules/core/src/test/scala/vinyldns/core/protobuf/GroupProtobufConversionsSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/protobuf/GroupProtobufConversionsSpec.scala @@ -16,10 +16,11 @@ package vinyldns.core.protobuf -import org.scalatest.{Matchers, WordSpec} import vinyldns.core.domain.membership.{Group, GroupChange, GroupChangeType} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class GroupProtobufConversionsSpec extends WordSpec with Matchers with GroupProtobufConversions { +class GroupProtobufConversionsSpec extends AnyWordSpec with Matchers with GroupProtobufConversions { "Converting groups to protobufs" should { "works with all fields present" in { diff --git a/modules/core/src/test/scala/vinyldns/core/protobuf/ProtobufConversionsSpec.scala b/modules/core/src/test/scala/vinyldns/core/protobuf/ProtobufConversionsSpec.scala index 45db4be65..63015254b 100644 --- a/modules/core/src/test/scala/vinyldns/core/protobuf/ProtobufConversionsSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/protobuf/ProtobufConversionsSpec.scala @@ -17,7 +17,7 @@ package vinyldns.core.protobuf import org.joda.time.DateTime -import org.scalatest.{Assertion, Matchers, OptionValues, WordSpec} +import org.scalatest.{Assertion, OptionValues} import vinyldns.core.TestRecordSetData.ds import vinyldns.core.domain.Fqdn import vinyldns.core.domain.membership.UserChange.{CreateUser, UpdateUser} @@ -27,9 +27,11 @@ import vinyldns.core.domain.zone._ import vinyldns.proto.VinylDNSProto import scala.collection.JavaConverters._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec class ProtobufConversionsSpec - extends WordSpec + extends AnyWordSpec with Matchers with ProtobufConversions with OptionValues { diff --git a/modules/core/src/test/scala/vinyldns/core/queue/MessageQueueLoaderSpec.scala b/modules/core/src/test/scala/vinyldns/core/queue/MessageQueueLoaderSpec.scala index 723fe6e14..a5ba010a7 100644 --- a/modules/core/src/test/scala/vinyldns/core/queue/MessageQueueLoaderSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/queue/MessageQueueLoaderSpec.scala @@ -18,10 +18,11 @@ package vinyldns.core.queue import cats.effect.IO import com.typesafe.config.{Config, ConfigFactory} -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar import scala.concurrent.duration._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec object MockMessageQueueProvider extends MockitoSugar { @@ -43,7 +44,7 @@ class FailMessageQueueProvider extends MessageQueueProvider { } -class MessageQueueLoaderSpec extends WordSpec with Matchers { +class MessageQueueLoaderSpec extends AnyWordSpec with Matchers { val placeholderConfig: Config = ConfigFactory.parseString("{}") private val pollingInterval = 250.millis diff --git a/modules/core/src/test/scala/vinyldns/core/repository/DataStoreLoaderSpec.scala b/modules/core/src/test/scala/vinyldns/core/repository/DataStoreLoaderSpec.scala index 3cf1ff285..2ca6f6aa9 100644 --- a/modules/core/src/test/scala/vinyldns/core/repository/DataStoreLoaderSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/repository/DataStoreLoaderSpec.scala @@ -20,17 +20,18 @@ import cats.data._ import cats.syntax.validated._ import cats.scalatest.{EitherMatchers, EitherValues, ValidatedMatchers} import com.typesafe.config.{Config, ConfigFactory} -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar import vinyldns.core.crypto.{CryptoAlgebra, NoOpCrypto} import vinyldns.core.domain.membership.UserRepository import vinyldns.core.repository.DataStoreLoader.DataLoaderResponse import vinyldns.core.repository.RepositoryName._ import scala.collection.JavaConverters._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec class DataStoreLoaderSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with EitherValues diff --git a/modules/core/src/test/scala/vinyldns/core/repository/MockDataStoreProvider.scala b/modules/core/src/test/scala/vinyldns/core/repository/MockDataStoreProvider.scala index f203e5d30..ff5f445d5 100644 --- a/modules/core/src/test/scala/vinyldns/core/repository/MockDataStoreProvider.scala +++ b/modules/core/src/test/scala/vinyldns/core/repository/MockDataStoreProvider.scala @@ -17,7 +17,7 @@ package vinyldns.core.repository import cats.effect.IO -import org.scalatest.mockito.MockitoSugar +import org.scalatestplus.mockito.MockitoSugar import vinyldns.core.crypto.CryptoAlgebra import vinyldns.core.domain.batch.BatchChangeRepository import vinyldns.core.domain.membership.{ diff --git a/modules/core/src/test/scala/vinyldns/core/route/MonitorSpec.scala b/modules/core/src/test/scala/vinyldns/core/route/MonitorSpec.scala index 04b892e5a..42ef31a28 100644 --- a/modules/core/src/test/scala/vinyldns/core/route/MonitorSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/route/MonitorSpec.scala @@ -22,13 +22,15 @@ import org.scalatest.concurrent.ScalaFutures import org.mockito.ArgumentCaptor import org.mockito.Matchers._ import org.mockito.Mockito._ -import org.scalatest.mockito.MockitoSugar +import org.scalatestplus.mockito.MockitoSugar import org.scalatest.time.{Millis, Seconds, Span} -import org.scalatest.{Matchers, OneInstancePerTest, WordSpec} +import org.scalatest.OneInstancePerTest import org.slf4j.Logger +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec class MonitorSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with OneInstancePerTest diff --git a/modules/core/src/test/scala/vinyldns/core/task/TaskSchedulerSpec.scala b/modules/core/src/test/scala/vinyldns/core/task/TaskSchedulerSpec.scala index 857d122c2..5971601c7 100644 --- a/modules/core/src/test/scala/vinyldns/core/task/TaskSchedulerSpec.scala +++ b/modules/core/src/test/scala/vinyldns/core/task/TaskSchedulerSpec.scala @@ -18,12 +18,18 @@ package vinyldns.core.task import cats.effect.{ContextShift, IO, Timer} import org.mockito.Mockito import org.mockito.Mockito._ -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.BeforeAndAfterEach import scala.concurrent.duration._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class TaskSchedulerSpec extends WordSpec with Matchers with MockitoSugar with BeforeAndAfterEach { +class TaskSchedulerSpec + extends AnyWordSpec + with Matchers + with MockitoSugar + with BeforeAndAfterEach { private implicit val cs: ContextShift[IO] = IO.contextShift(scala.concurrent.ExecutionContext.global) diff --git a/modules/dynamodb/src/it/scala/vinyldns/dynamodb/repository/DynamoDBDataStoreProviderIntegrationSpec.scala b/modules/dynamodb/src/it/scala/vinyldns/dynamodb/repository/DynamoDBDataStoreProviderIntegrationSpec.scala index e3ffd8e8a..69c96a9b6 100644 --- a/modules/dynamodb/src/it/scala/vinyldns/dynamodb/repository/DynamoDBDataStoreProviderIntegrationSpec.scala +++ b/modules/dynamodb/src/it/scala/vinyldns/dynamodb/repository/DynamoDBDataStoreProviderIntegrationSpec.scala @@ -27,6 +27,8 @@ import vinyldns.core.domain.record.{RecordChangeRepository, RecordSetRepository} import vinyldns.core.domain.zone.{ZoneChangeRepository, ZoneRepository} import vinyldns.core.repository.{DataStore, DataStoreConfig, LoadedDataStore} import vinyldns.core.repository.RepositoryName._ +import pureconfig._ +import pureconfig.generic.auto._ class DynamoDBDataStoreProviderIntegrationSpec extends DynamoDBIntegrationSpec { @@ -34,7 +36,8 @@ class DynamoDBDataStoreProviderIntegrationSpec extends DynamoDBIntegrationSpec { IO.contextShift(scala.concurrent.ExecutionContext.global) val config: Config = ConfigFactory.load() val dynamoDBConfig: DataStoreConfig = - pureconfig.loadConfigOrThrow[DataStoreConfig](config, "dynamodb") + ConfigSource.fromConfig(config).at("dynamodb").loadOrThrow[DataStoreConfig] + val provider: DynamoDBDataStoreProvider = new DynamoDBDataStoreProvider() val crypto: CryptoAlgebra = new NoOpCrypto() @@ -48,7 +51,7 @@ class DynamoDBDataStoreProviderIntegrationSpec extends DynamoDBIntegrationSpec { def tearDown(): Unit = { val deletes = dynamoDBConfig.repositories.configMap.map { case (_, config) => { - val asDynamo = pureconfig.loadConfigOrThrow[DynamoDBRepositorySettings](config) + val asDynamo = ConfigSource.fromConfig(config).loadOrThrow[DynamoDBRepositorySettings] val request = new DeleteTableRequest().withTableName(asDynamo.tableName) testDynamoDBHelper.deleteTable(request) } diff --git a/modules/dynamodb/src/it/scala/vinyldns/dynamodb/repository/DynamoDBIntegrationSpec.scala b/modules/dynamodb/src/it/scala/vinyldns/dynamodb/repository/DynamoDBIntegrationSpec.scala index 2af904fab..429825fa2 100644 --- a/modules/dynamodb/src/it/scala/vinyldns/dynamodb/repository/DynamoDBIntegrationSpec.scala +++ b/modules/dynamodb/src/it/scala/vinyldns/dynamodb/repository/DynamoDBIntegrationSpec.scala @@ -19,10 +19,12 @@ package vinyldns.dynamodb.repository import java.util.UUID import org.scalatest._ +import org.scalatest.wordspec.AnyWordSpec +import org.scalatest.matchers.should.Matchers import org.slf4j.{Logger, LoggerFactory} trait DynamoDBIntegrationSpec - extends WordSpec + extends AnyWordSpec with BeforeAndAfterAll with Matchers with Inspectors { diff --git a/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBDataStoreProvider.scala b/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBDataStoreProvider.scala index a74f9078d..873c761f2 100644 --- a/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBDataStoreProvider.scala +++ b/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBDataStoreProvider.scala @@ -20,7 +20,9 @@ import cats.implicits._ import cats.effect.{ContextShift, IO} import org.slf4j.LoggerFactory import vinyldns.core.repository._ -import pureconfig.module.catseffect.loadConfigF +import pureconfig._ +import pureconfig.generic.auto._ +import pureconfig.module.catseffect.syntax._ import vinyldns.core.crypto.CryptoAlgebra import vinyldns.core.domain.batch.BatchChangeRepository import vinyldns.core.domain.membership._ @@ -29,6 +31,8 @@ import vinyldns.core.domain.zone.{ZoneChangeRepository, ZoneRepository} import vinyldns.core.repository.RepositoryName._ import vinyldns.core.health.HealthCheck._ import vinyldns.core.task.TaskRepository +import pureconfig.ConfigSource +import cats.effect.Blocker class DynamoDBDataStoreProvider extends DataStoreProvider { @@ -40,7 +44,9 @@ class DynamoDBDataStoreProvider extends DataStoreProvider { def load(config: DataStoreConfig, crypto: CryptoAlgebra): IO[LoadedDataStore] = for { - settingsConfig <- loadConfigF[IO, DynamoDBDataStoreSettings](config.settings) + settingsConfig <- Blocker[IO].use( + ConfigSource.fromConfig(config.settings).loadF[IO, DynamoDBDataStoreSettings](_) + ) _ <- validateRepos(config.repositories) repoConfigs <- loadRepoConfigs(config.repositories) dataStore <- initializeRepos(settingsConfig, repoConfigs, crypto) @@ -65,7 +71,12 @@ class DynamoDBDataStoreProvider extends DataStoreProvider { repositoryName: RepositoryName ): Option[IO[(RepositoryName, DynamoDBRepositorySettings)]] = config.get(repositoryName).map { repoConf => - loadConfigF[IO, DynamoDBRepositorySettings](repoConf).map(repositoryName -> _) + Blocker[IO].use( + ConfigSource + .fromConfig(repoConf) + .loadF[IO, DynamoDBRepositorySettings](_) + .map(repositoryName -> _) + ) } val activeRepoSettings = RepositoryName.values.toList.flatMap(loadConfigIfDefined).parSequence diff --git a/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBGroupChangeRepository.scala b/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBGroupChangeRepository.scala index 240e7ac91..738cb7384 100644 --- a/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBGroupChangeRepository.scala +++ b/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBGroupChangeRepository.scala @@ -20,7 +20,6 @@ import java.nio.ByteBuffer import java.util.HashMap import cats.effect._ -import cats.implicits._ import com.amazonaws.services.dynamodbv2.model._ import org.joda.time.DateTime import org.slf4j.{Logger, LoggerFactory} diff --git a/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBMembershipRepository.scala b/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBMembershipRepository.scala index bbaccf0e4..f3821809c 100644 --- a/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBMembershipRepository.scala +++ b/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBMembershipRepository.scala @@ -19,7 +19,6 @@ package vinyldns.dynamodb.repository import java.util.{Collections, HashMap} import cats.effect._ -import cats.implicits._ import com.amazonaws.services.dynamodbv2.model._ import org.slf4j.{Logger, LoggerFactory} import vinyldns.core.domain.membership.MembershipRepository diff --git a/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBRecordChangeRepository.scala b/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBRecordChangeRepository.scala index fc8699516..2ccca444b 100644 --- a/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBRecordChangeRepository.scala +++ b/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBRecordChangeRepository.scala @@ -20,7 +20,6 @@ import java.nio.ByteBuffer import java.util.HashMap import cats.effect._ -import cats.implicits._ import com.amazonaws.services.dynamodbv2.model._ import org.joda.time.DateTime import org.slf4j.{Logger, LoggerFactory} diff --git a/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBRecordSetRepository.scala b/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBRecordSetRepository.scala index d1887053c..a1bc57949 100644 --- a/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBRecordSetRepository.scala +++ b/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBRecordSetRepository.scala @@ -19,7 +19,6 @@ package vinyldns.dynamodb.repository import java.util.HashMap import cats.effect._ -import cats.implicits._ import com.amazonaws.services.dynamodbv2.model._ import org.slf4j.{Logger, LoggerFactory} import vinyldns.core.domain.DomainHelpers.omitTrailingDot diff --git a/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBUserChangeRepository.scala b/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBUserChangeRepository.scala index ca579cd21..3d480a9d2 100644 --- a/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBUserChangeRepository.scala +++ b/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBUserChangeRepository.scala @@ -20,7 +20,6 @@ import java.util.HashMap import cats.data.OptionT import cats.effect.IO -import cats.implicits._ import com.amazonaws.services.dynamodbv2.model._ import org.joda.time.DateTime import org.slf4j.LoggerFactory diff --git a/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBZoneChangeRepository.scala b/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBZoneChangeRepository.scala index 3bdce54b3..c0fab1c92 100644 --- a/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBZoneChangeRepository.scala +++ b/modules/dynamodb/src/main/scala/vinyldns/dynamodb/repository/DynamoDBZoneChangeRepository.scala @@ -20,7 +20,6 @@ import java.nio.ByteBuffer import java.util.HashMap import cats.effect._ -import cats.implicits._ import com.amazonaws.services.dynamodbv2.model._ import org.joda.time.DateTime import org.slf4j.LoggerFactory diff --git a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/DynamoTestConfig.scala b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/DynamoTestConfig.scala index 4554bc1ff..ad8a7b3b3 100644 --- a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/DynamoTestConfig.scala +++ b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/DynamoTestConfig.scala @@ -19,20 +19,24 @@ package vinyldns.dynamodb import com.typesafe.config.{Config, ConfigFactory} import vinyldns.core.repository.{DataStoreConfig, RepositoriesConfig} import vinyldns.dynamodb.repository.DynamoDBRepositorySettings +import pureconfig._ +import pureconfig.generic.auto._ object DynamoTestConfig { lazy val config: Config = ConfigFactory.load() lazy val dynamoDBConfig: DataStoreConfig = - pureconfig.loadConfigOrThrow[DataStoreConfig](config, "dynamodb") + ConfigSource.fromConfig(config).at("dynamodb").loadOrThrow[DataStoreConfig] lazy val baseReposConfigs: RepositoriesConfig = dynamoDBConfig.repositories lazy val zoneChangeStoreConfig: DynamoDBRepositorySettings = - pureconfig.loadConfigOrThrow[DynamoDBRepositorySettings](baseReposConfigs.zoneChange.get) + ConfigSource.fromConfig(baseReposConfigs.zoneChange.get).loadOrThrow[DynamoDBRepositorySettings] lazy val recordChangeStoreConfig: DynamoDBRepositorySettings = - pureconfig.loadConfigOrThrow[DynamoDBRepositorySettings](baseReposConfigs.recordChange.get) + ConfigSource + .fromConfig(baseReposConfigs.recordChange.get) + .loadOrThrow[DynamoDBRepositorySettings] // Needed for testing DynamoDBUserRepository, but can't include in config directly due to not being implemented lazy val usertableConfig: Config = ConfigFactory.parseString(""" @@ -42,15 +46,16 @@ object DynamoTestConfig { """.stripMargin) lazy val usersStoreConfig: DynamoDBRepositorySettings = - pureconfig.loadConfigOrThrow[DynamoDBRepositorySettings](usertableConfig) + ConfigSource.fromConfig(usertableConfig).loadOrThrow[DynamoDBRepositorySettings] lazy val groupsStoreConfig: DynamoDBRepositorySettings = - pureconfig.loadConfigOrThrow[DynamoDBRepositorySettings](baseReposConfigs.group.get) + ConfigSource.fromConfig(baseReposConfigs.group.get).loadOrThrow[DynamoDBRepositorySettings] lazy val groupChangesStoreConfig: DynamoDBRepositorySettings = - pureconfig.loadConfigOrThrow[DynamoDBRepositorySettings](baseReposConfigs.groupChange.get) + ConfigSource + .fromConfig(baseReposConfigs.groupChange.get) + .loadOrThrow[DynamoDBRepositorySettings] lazy val membershipStoreConfig: DynamoDBRepositorySettings = - pureconfig.loadConfigOrThrow[DynamoDBRepositorySettings](baseReposConfigs.membership.get) - + ConfigSource.fromConfig(baseReposConfigs.membership.get).loadOrThrow[DynamoDBRepositorySettings] } diff --git a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBDataStoreProviderSpec.scala b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBDataStoreProviderSpec.scala index 20dd00949..16e8774b7 100644 --- a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBDataStoreProviderSpec.scala +++ b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBDataStoreProviderSpec.scala @@ -17,7 +17,8 @@ package vinyldns.dynamodb.repository import com.typesafe.config.{Config, ConfigFactory} -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.crypto.NoOpCrypto import vinyldns.core.repository.{ DataStoreConfig, @@ -26,8 +27,10 @@ import vinyldns.core.repository.{ RepositoryName } import vinyldns.dynamodb.DynamoTestConfig +import pureconfig._ +import pureconfig.generic.auto._ -class DynamoDBDataStoreProviderSpec extends WordSpec with Matchers { +class DynamoDBDataStoreProviderSpec extends AnyWordSpec with Matchers { private val underTest = new DynamoDBDataStoreProvider() private val crypto = new NoOpCrypto() @@ -54,7 +57,7 @@ class DynamoDBDataStoreProviderSpec extends WordSpec with Matchers { | """.stripMargin ) - val badSettings = pureconfig.loadConfigOrThrow[DataStoreConfig](badConfig) + val badSettings = ConfigSource.fromConfig(badConfig).loadOrThrow[DataStoreConfig] a[pureconfig.error.ConfigReaderException[DynamoDBDataStoreSettings]] should be thrownBy underTest .load(badSettings, crypto) diff --git a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBGroupChangeRepositorySpec.scala b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBGroupChangeRepositorySpec.scala index 59c9b26ed..75e6bff91 100644 --- a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBGroupChangeRepositorySpec.scala +++ b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBGroupChangeRepositorySpec.scala @@ -20,8 +20,10 @@ import com.amazonaws.services.dynamodbv2.model.{GetItemRequest, ResourceNotFound import org.mockito.Matchers._ import org.mockito.Mockito._ import org.scalatest.concurrent.ScalaFutures -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.BeforeAndAfterEach +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.TestMembershipData._ import scala.collection.JavaConverters._ @@ -29,7 +31,7 @@ import cats.effect._ import vinyldns.dynamodb.DynamoTestConfig class DynamoDBGroupChangeRepositorySpec - extends WordSpec + extends AnyWordSpec with MockitoSugar with Matchers with ScalaFutures diff --git a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBGroupRepositorySpec.scala b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBGroupRepositorySpec.scala index dee271635..23315f66b 100644 --- a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBGroupRepositorySpec.scala +++ b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBGroupRepositorySpec.scala @@ -20,8 +20,10 @@ import com.amazonaws.services.dynamodbv2.model.{GetItemRequest, ResourceNotFound import org.mockito.Matchers._ import org.mockito.Mockito._ import org.scalatest.concurrent.ScalaFutures -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.BeforeAndAfterEach +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.TestMembershipData._ import scala.collection.JavaConverters._ @@ -29,7 +31,7 @@ import cats.effect._ import vinyldns.dynamodb.DynamoTestConfig class DynamoDBGroupRepositorySpec - extends WordSpec + extends AnyWordSpec with MockitoSugar with Matchers with ScalaFutures diff --git a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBHelperSpec.scala b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBHelperSpec.scala index 6b1833553..e059c3c10 100644 --- a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBHelperSpec.scala +++ b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBHelperSpec.scala @@ -25,13 +25,15 @@ import com.codahale.metrics.Meter import org.mockito.Matchers._ import org.mockito.Mockito._ import org.scalatest.concurrent.{Eventually, PatienceConfiguration, ScalaFutures} -import org.scalatest.mockito.MockitoSugar +import org.scalatestplus.mockito.MockitoSugar import org.scalatest.time.{Seconds, Span} -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpecLike} +import org.scalatest.BeforeAndAfterEach +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpecLike import org.slf4j.Logger class DynamoDBHelperSpec - extends WordSpecLike + extends AnyWordSpecLike with Matchers with MockitoSugar with ScalaFutures diff --git a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBMembershipRepositorySpec.scala b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBMembershipRepositorySpec.scala index 05b14f001..a10ee23a0 100644 --- a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBMembershipRepositorySpec.scala +++ b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBMembershipRepositorySpec.scala @@ -21,8 +21,10 @@ import org.mockito.ArgumentCaptor import org.mockito.Matchers._ import org.mockito.Mockito._ import org.scalatest.concurrent.ScalaFutures -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.BeforeAndAfterEach +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.TestMembershipData._ import scala.collection.JavaConverters._ @@ -32,7 +34,7 @@ import vinyldns.dynamodb.DynamoTestConfig import scala.concurrent.duration.FiniteDuration class DynamoDBMembershipRepositorySpec - extends WordSpec + extends AnyWordSpec with MockitoSugar with Matchers with ScalaFutures diff --git a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBRecordChangeRepositorySpec.scala b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBRecordChangeRepositorySpec.scala index 5b5322ff6..5b9ee971f 100644 --- a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBRecordChangeRepositorySpec.scala +++ b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBRecordChangeRepositorySpec.scala @@ -21,18 +21,20 @@ import org.mockito.ArgumentCaptor import org.mockito.Matchers._ import org.mockito.Mockito._ import org.scalatest.concurrent.ScalaFutures -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.domain.record.ChangeSet import vinyldns.core.TestRecordSetData._ import vinyldns.core.TestZoneData._ import cats.effect._ +import org.scalatest.BeforeAndAfterEach import vinyldns.dynamodb.DynamoTestConfig import scala.concurrent.duration.FiniteDuration class DynamoDBRecordChangeRepositorySpec - extends WordSpec + extends AnyWordSpec with MockitoSugar with Matchers with ScalaFutures diff --git a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBRecordSetConversionsSpec.scala b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBRecordSetConversionsSpec.scala index 98615c457..228e8aa6e 100644 --- a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBRecordSetConversionsSpec.scala +++ b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBRecordSetConversionsSpec.scala @@ -20,8 +20,9 @@ import java.nio.ByteBuffer import com.amazonaws.services.dynamodbv2.model.AttributeValue import org.joda.time.DateTime -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.domain.record.{ RecordSet, RecordSetChange, @@ -37,7 +38,7 @@ import vinyldns.proto.VinylDNSProto import scala.collection.JavaConverters._ class DynamoDBRecordSetConversionsSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with ProtobufConversions { diff --git a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBRecordSetRepositorySpec.scala b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBRecordSetRepositorySpec.scala index 4486fee94..da8ec10d0 100644 --- a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBRecordSetRepositorySpec.scala +++ b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBRecordSetRepositorySpec.scala @@ -23,8 +23,10 @@ import org.mockito.ArgumentCaptor import org.mockito.Matchers._ import org.mockito.Mockito._ import org.scalatest.concurrent.ScalaFutures -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.BeforeAndAfterEach +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.domain.record.{ChangeSet, NameSort} import vinyldns.core.TestRecordSetData._ import cats.effect._ @@ -33,7 +35,7 @@ import vinyldns.dynamodb.DynamoTestConfig import scala.concurrent.duration.FiniteDuration class DynamoDBRecordSetRepositorySpec - extends WordSpec + extends AnyWordSpec with MockitoSugar with Matchers with ScalaFutures diff --git a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBUserRepositorySpec.scala b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBUserRepositorySpec.scala index 6e6aba527..6b3e5f4c1 100644 --- a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBUserRepositorySpec.scala +++ b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBUserRepositorySpec.scala @@ -23,8 +23,10 @@ import org.mockito.ArgumentCaptor import org.mockito.Matchers._ import org.mockito.Mockito._ import org.scalatest.concurrent.ScalaFutures -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.BeforeAndAfterEach +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.TestMembershipData._ import scala.collection.JavaConverters._ @@ -35,7 +37,7 @@ import vinyldns.core.domain.membership.LockStatus import vinyldns.dynamodb.DynamoTestConfig class DynamoDBUserRepositorySpec - extends WordSpec + extends AnyWordSpec with MockitoSugar with Matchers with ScalaFutures diff --git a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBZoneChangeRepositorySpec.scala b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBZoneChangeRepositorySpec.scala index 072a5a4a7..961dbbec4 100644 --- a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBZoneChangeRepositorySpec.scala +++ b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/DynamoDBZoneChangeRepositorySpec.scala @@ -20,15 +20,17 @@ import com.amazonaws.services.dynamodbv2.model._ import org.mockito.Matchers._ import org.mockito.Mockito._ import org.scalatest.concurrent.ScalaFutures -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.BeforeAndAfterEach +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.domain.zone.{ZoneChange, ZoneChangeStatus, ZoneChangeType} import cats.effect._ import vinyldns.dynamodb.DynamoTestConfig import vinyldns.core.TestZoneData._ class DynamoDBZoneChangeRepositorySpec - extends WordSpec + extends AnyWordSpec with MockitoSugar with Matchers with ScalaFutures diff --git a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/QueryHelperSpec.scala b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/QueryHelperSpec.scala index f9e9a7d12..54c579053 100644 --- a/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/QueryHelperSpec.scala +++ b/modules/dynamodb/src/test/scala/vinyldns/dynamodb/repository/QueryHelperSpec.scala @@ -22,14 +22,16 @@ import com.amazonaws.services.dynamodbv2.model.{AttributeValue, _} import org.mockito.Matchers._ import org.mockito.Mockito._ import org.scalatest.concurrent.ScalaFutures -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar +import org.scalatest.BeforeAndAfterEach +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import scala.collection.JavaConverters._ import cats.effect._ class QueryHelperSpec - extends WordSpec + extends AnyWordSpec with MockitoSugar with Matchers with ScalaFutures diff --git a/modules/mysql/src/it/scala/vinyldns/mysql/MySqlIntegrationSpec.scala b/modules/mysql/src/it/scala/vinyldns/mysql/MySqlIntegrationSpec.scala index 23b1cecb5..0a8736ac4 100644 --- a/modules/mysql/src/it/scala/vinyldns/mysql/MySqlIntegrationSpec.scala +++ b/modules/mysql/src/it/scala/vinyldns/mysql/MySqlIntegrationSpec.scala @@ -25,12 +25,14 @@ import vinyldns.core.domain.record.{RecordChangeRepository, RecordSetRepository} import vinyldns.core.repository.{DataStore, DataStoreConfig, LoadedDataStore, RepositoryName} import vinyldns.core.task.TaskRepository import vinyldns.mysql.repository.MySqlDataStoreProvider +import pureconfig._ +import pureconfig.generic.auto._ trait MySqlIntegrationSpec { def mysqlConfig: Config lazy val dataStoreConfig: DataStoreConfig = - pureconfig.loadConfigOrThrow[DataStoreConfig](mysqlConfig) + ConfigSource.fromConfig(mysqlConfig).loadOrThrow[DataStoreConfig] lazy val provider = new MySqlDataStoreProvider() diff --git a/modules/mysql/src/it/scala/vinyldns/mysql/queue/MySqlMessageQueueIntegrationSpec.scala b/modules/mysql/src/it/scala/vinyldns/mysql/queue/MySqlMessageQueueIntegrationSpec.scala index 713ac7fb9..54b0b38a2 100644 --- a/modules/mysql/src/it/scala/vinyldns/mysql/queue/MySqlMessageQueueIntegrationSpec.scala +++ b/modules/mysql/src/it/scala/vinyldns/mysql/queue/MySqlMessageQueueIntegrationSpec.scala @@ -23,6 +23,10 @@ import cats.scalatest.EitherMatchers import com.typesafe.config.{Config, ConfigFactory} import org.joda.time.DateTime import org.scalatest._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec +import pureconfig._ +import pureconfig.generic.auto._ import scalikejdbc._ import vinyldns.core.domain.batch.BatchChangeCommand import vinyldns.core.domain.record.RecordSetChange @@ -57,7 +61,7 @@ final case class InvalidMessage(command: ZoneCommand) extends CommandMessage { } class MySqlMessageQueueIntegrationSpec - extends WordSpec + extends AnyWordSpec with Matchers with BeforeAndAfterEach with EitherMatchers @@ -71,7 +75,7 @@ class MySqlMessageQueueIntegrationSpec private val config: Config = ConfigFactory.load().getConfig("queue") lazy val queueConfig: MessageQueueConfig = - pureconfig.loadConfigOrThrow[MessageQueueConfig](config) + ConfigSource.fromConfig(config).loadOrThrow[MessageQueueConfig] private val underTest = MessageQueueLoader.load(queueConfig).map(_.asInstanceOf[MySqlMessageQueue]).unsafeRunSync() diff --git a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlBatchChangeRepositoryIntegrationSpec.scala b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlBatchChangeRepositoryIntegrationSpec.scala index e45667bbb..4ff2c349f 100644 --- a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlBatchChangeRepositoryIntegrationSpec.scala +++ b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlBatchChangeRepositoryIntegrationSpec.scala @@ -21,6 +21,8 @@ import java.util.UUID import cats.effect._ import org.joda.time.DateTime import org.scalatest._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import scalikejdbc.DB import vinyldns.core.domain.record.{AAAAData, AData, RecordData, RecordType} import vinyldns.core.domain.batch._ @@ -30,7 +32,7 @@ import vinyldns.core.domain.{SingleChangeError, ZoneDiscoveryError} import vinyldns.mysql.TestMySqlInstance class MySqlBatchChangeRepositoryIntegrationSpec - extends WordSpec + extends AnyWordSpec with BeforeAndAfterAll with BeforeAndAfterEach with Matchers diff --git a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlDataStoreProviderIntegrationSpec.scala b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlDataStoreProviderIntegrationSpec.scala index c118140df..8d41132be 100644 --- a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlDataStoreProviderIntegrationSpec.scala +++ b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlDataStoreProviderIntegrationSpec.scala @@ -17,10 +17,11 @@ package vinyldns.mysql.repository import cats.scalatest.EitherMatchers -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.mysql.TestMySqlInstance -class MySqlDataStoreProviderIntegrationSpec extends WordSpec with Matchers with EitherMatchers { +class MySqlDataStoreProviderIntegrationSpec extends AnyWordSpec with Matchers with EitherMatchers { "MySqlDataStoreProvider" should { "Successfully healthcheck" in { diff --git a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlGroupChangeRepositoryIntegrationSpec.scala b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlGroupChangeRepositoryIntegrationSpec.scala index a87d4892a..38147fea4 100644 --- a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlGroupChangeRepositoryIntegrationSpec.scala +++ b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlGroupChangeRepositoryIntegrationSpec.scala @@ -18,13 +18,15 @@ package vinyldns.mysql.repository import org.joda.time.DateTime import org.scalatest._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import scalikejdbc.DB import vinyldns.core.domain.membership.{Group, GroupChange, GroupChangeRepository, GroupChangeType} import vinyldns.mysql.TestMySqlInstance import org.joda.time.DateTime class MySqlGroupChangeRepositoryIntegrationSpec - extends WordSpec + extends AnyWordSpec with BeforeAndAfterAll with BeforeAndAfterEach with Matchers { diff --git a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlGroupRepositoryIntegrationSpec.scala b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlGroupRepositoryIntegrationSpec.scala index 0bc07ed4d..112d2d4dd 100644 --- a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlGroupRepositoryIntegrationSpec.scala +++ b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlGroupRepositoryIntegrationSpec.scala @@ -17,12 +17,14 @@ package vinyldns.mysql.repository import org.scalatest._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import scalikejdbc.DB import vinyldns.core.domain.membership.{Group, GroupRepository, GroupStatus} import vinyldns.mysql.TestMySqlInstance class MySqlGroupRepositoryIntegrationSpec - extends WordSpec + extends AnyWordSpec with BeforeAndAfterAll with BeforeAndAfterEach with Matchers diff --git a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlMembershipRepositoryIntegrationSpec.scala b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlMembershipRepositoryIntegrationSpec.scala index f360042cf..7bf6dffc9 100644 --- a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlMembershipRepositoryIntegrationSpec.scala +++ b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlMembershipRepositoryIntegrationSpec.scala @@ -17,12 +17,14 @@ package vinyldns.mysql.repository import org.scalatest._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import scalikejdbc.{DB, _} import vinyldns.core.domain.membership.MembershipRepository import vinyldns.mysql.TestMySqlInstance class MySqlMembershipRepositoryIntegrationSpec - extends WordSpec + extends AnyWordSpec with BeforeAndAfterAll with BeforeAndAfterEach with Matchers { diff --git a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlRecordChangeRepositoryIntegrationSpec.scala b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlRecordChangeRepositoryIntegrationSpec.scala index 8b3e70b73..12e71886b 100644 --- a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlRecordChangeRepositoryIntegrationSpec.scala +++ b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlRecordChangeRepositoryIntegrationSpec.scala @@ -19,7 +19,9 @@ package vinyldns.mysql.repository import java.util.UUID import cats.scalatest.EitherMatchers -import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import scalikejdbc._ import vinyldns.core.domain.record.{ ChangeSet, @@ -31,7 +33,7 @@ import vinyldns.core.domain.zone.Zone import vinyldns.mysql.TestMySqlInstance class MySqlRecordChangeRepositoryIntegrationSpec - extends WordSpec + extends AnyWordSpec with Matchers with BeforeAndAfterAll with BeforeAndAfterEach diff --git a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlRecordSetRepositoryIntegrationSpec.scala b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlRecordSetRepositoryIntegrationSpec.scala index def262b20..ccd28262f 100644 --- a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlRecordSetRepositoryIntegrationSpec.scala +++ b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlRecordSetRepositoryIntegrationSpec.scala @@ -20,6 +20,8 @@ import java.util.UUID import cats.scalatest.EitherMatchers import org.joda.time.DateTime import org.scalatest._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import scalikejdbc.DB import vinyldns.core.domain.record._ import vinyldns.core.domain.record.RecordType._ @@ -28,7 +30,7 @@ import vinyldns.mysql.TestMySqlInstance import vinyldns.mysql.repository.MySqlRecordSetRepository.PagingKey class MySqlRecordSetRepositoryIntegrationSpec - extends WordSpec + extends AnyWordSpec with BeforeAndAfterEach with BeforeAndAfterAll with Matchers @@ -51,7 +53,11 @@ class MySqlRecordSetRepositoryIntegrationSpec val newRecordSets = for { i <- 1 to count - } yield aaaa.copy(zoneId = zone.id, name = s"$i-${word}-apply-test", id = UUID.randomUUID().toString) + } yield aaaa.copy( + zoneId = zone.id, + name = s"$i-${word}-apply-test", + id = UUID.randomUUID().toString + ) newRecordSets.map(makeTestAddChange(_, zone)).toList } @@ -69,9 +75,8 @@ class MySqlRecordSetRepositoryIntegrationSpec () } - def recordSetWithFQDN(recordSet: RecordSet, zone: Zone): RecordSet = { + def recordSetWithFQDN(recordSet: RecordSet, zone: Zone): RecordSet = recordSet.copy(fqdn = Some(s"""${recordSet.name}.${zone.name}""")) - } "apply" should { "properly revert changes that fail processing" in { @@ -143,7 +148,10 @@ class MySqlRecordSetRepositoryIntegrationSpec ) repo.apply(ChangeSet(existingPending)).unsafeRunSync() repo.getRecordSet(failedChange.recordSet.id).unsafeRunSync() shouldBe - Some(existingPending.recordSet.copy(fqdn=Some(s"""${failedChange.recordSet.name}.${okZone.name}"""))) + Some( + existingPending.recordSet + .copy(fqdn = Some(s"""${failedChange.recordSet.name}.${okZone.name}""")) + ) repo.apply(ChangeSet(Seq(successfulChange, pendingChange, failedChange))).unsafeRunSync() @@ -164,13 +172,16 @@ class MySqlRecordSetRepositoryIntegrationSpec } "apply successful updates and revert records for failed updates" in { - val oldSuccess = aaaa.copy(zoneId = "test-update-converter", name="success", ttl = 100, id = "success") + val oldSuccess = + aaaa.copy(zoneId = "test-update-converter", name = "success", ttl = 100, id = "success") val updateSuccess = oldSuccess.copy(ttl = 200) - val oldPending = aaaa.copy(zoneId = "test-update-converter", name="pending", ttl = 100, id = "pending") + val oldPending = + aaaa.copy(zoneId = "test-update-converter", name = "pending", ttl = 100, id = "pending") val updatePending = oldPending.copy(ttl = 200, status = RecordSetStatus.PendingUpdate) - val oldFailure = aaaa.copy(zoneId = "test-update-converter", name="failure", ttl = 100, id = "failed") + val oldFailure = + aaaa.copy(zoneId = "test-update-converter", name = "failure", ttl = 100, id = "failed") val updateFailure = oldFailure.copy(ttl = 200, status = RecordSetStatus.Inactive) val successfulUpdate = makeCompleteTestUpdateChange(oldSuccess, updateSuccess) @@ -213,7 +224,12 @@ class MySqlRecordSetRepositoryIntegrationSpec repo .getRecordSet(failedUpdate.recordSet.id) .unsafeRunSync() shouldNot - be(Some(failedUpdate.recordSet.copy(fqdn=Some(s"""${successfulUpdate.recordSet.name}.${okZone.name}""")))) + be( + Some( + failedUpdate.recordSet + .copy(fqdn = Some(s"""${successfulUpdate.recordSet.name}.${okZone.name}""")) + ) + ) } "apply successful deletes, save pending deletes, and revert failed deletes" in { @@ -385,26 +401,40 @@ class MySqlRecordSetRepositoryIntegrationSpec "list record sets" should { "return all record sets in a zone when optional params are not set" in { val existing = insert(okZone, 10).map(_.recordSet) - val found = repo.listRecordSets(Some(okZone.id), None, None, None, None, None, NameSort.ASC).unsafeRunSync() - found.recordSets should contain theSameElementsAs existing.map(r => recordSetWithFQDN(r, okZone)) + val found = repo + .listRecordSets(Some(okZone.id), None, None, None, None, None, NameSort.ASC) + .unsafeRunSync() + found.recordSets should contain theSameElementsAs existing.map( + r => recordSetWithFQDN(r, okZone) + ) } "return record sets after the startFrom when set" in { // load 5, start after the 3rd, we should get back the last two val existing = insert(okZone, 5).map(_.recordSet).sortBy(_.name) val startFrom = Some(PagingKey.toNextId(existing(2), true)) - val found = repo.listRecordSets(Some(okZone.id), startFrom, None, None, None, None, NameSort.ASC).unsafeRunSync() + val found = repo + .listRecordSets(Some(okZone.id), startFrom, None, None, None, None, NameSort.ASC) + .unsafeRunSync() - (found.recordSets should contain).theSameElementsInOrderAs(existing.drop(3) - .map(r => recordSetWithFQDN(r, okZone))) + (found.recordSets should contain).theSameElementsInOrderAs( + existing + .drop(3) + .map(r => recordSetWithFQDN(r, okZone)) + ) } "return the record sets after the startFrom respecting maxItems" in { // load 5, start after the 2nd, take 2, we should get back the 3rd and 4th val existing = insert(okZone, 5).map(_.recordSet).sortBy(_.name) val startFrom = Some(PagingKey.toNextId(existing(1), true)) - val found = repo.listRecordSets(Some(okZone.id), startFrom, Some(2), None, None, None, NameSort.ASC).unsafeRunSync() + val found = repo + .listRecordSets(Some(okZone.id), startFrom, Some(2), None, None, None, NameSort.ASC) + .unsafeRunSync() - (found.recordSets should contain).theSameElementsInOrderAs(existing.slice(2, 4) - .map(r => recordSetWithFQDN(r, okZone))) + (found.recordSets should contain).theSameElementsInOrderAs( + existing + .slice(2, 4) + .map(r => recordSetWithFQDN(r, okZone)) + ) } "return the record sets after startFrom respecting maxItems and filter" in { val recordNames = @@ -420,9 +450,17 @@ class MySqlRecordSetRepositoryIntegrationSpec insert(changes) val startFrom = Some(PagingKey.toNextId(newRecordSets(1), true)) - val found = repo.listRecordSets( - Some(okZone.id), startFrom, Some(3), Some("*z*"), None, None, NameSort.ASC - ).unsafeRunSync() + val found = repo + .listRecordSets( + Some(okZone.id), + startFrom, + Some(3), + Some("*z*"), + None, + None, + NameSort.ASC + ) + .unsafeRunSync() (found.recordSets.map(_.name) should contain).theSameElementsInOrderAs(expectedNames) } "return record sets using starts with wildcard" in { @@ -437,7 +475,9 @@ class MySqlRecordSetRepositoryIntegrationSpec val changes = newRecordSets.map(makeTestAddChange(_, okZone)) insert(changes) - val found = repo.listRecordSets(Some(okZone.id), None, Some(3), Some("aa*"), None, None, NameSort.ASC).unsafeRunSync() + val found = repo + .listRecordSets(Some(okZone.id), None, Some(3), Some("aa*"), None, None, NameSort.ASC) + .unsafeRunSync() (found.recordSets.map(_.name) should contain).theSameElementsInOrderAs(expectedNames) } "return record sets using ends with wildcard" in { @@ -452,7 +492,9 @@ class MySqlRecordSetRepositoryIntegrationSpec val changes = newRecordSets.map(makeTestAddChange(_, okZone)) insert(changes) - val found = repo.listRecordSets(Some(okZone.id), None, Some(3), Some("*b"), None, None, NameSort.ASC).unsafeRunSync() + val found = repo + .listRecordSets(Some(okZone.id), None, Some(3), Some("*b"), None, None, NameSort.ASC) + .unsafeRunSync() (found.recordSets.map(_.name) should contain).theSameElementsInOrderAs(expectedNames) } "return record sets exact match with no wildcards" in { @@ -468,37 +510,60 @@ class MySqlRecordSetRepositoryIntegrationSpec val changes = newRecordSets.map(makeTestAddChange(_, okZone)) insert(changes) - val found = repo.listRecordSets(Some(okZone.id), None, Some(3), Some("aaa"), None, None, NameSort.ASC).unsafeRunSync() + val found = repo + .listRecordSets(Some(okZone.id), None, Some(3), Some("aaa"), None, None, NameSort.ASC) + .unsafeRunSync() (found.recordSets.map(_.name) should contain).theSameElementsInOrderAs(expectedNames) } "return select types of recordsets in a zone" in { insert(okZone, 10).map(_.recordSet) - val found = repo.listRecordSets(Some(okZone.id), None, None, None, Some(Set(CNAME)), None, NameSort.ASC).unsafeRunSync() + val found = repo + .listRecordSets(Some(okZone.id), None, None, None, Some(Set(CNAME)), None, NameSort.ASC) + .unsafeRunSync() found.recordSets shouldBe List() found.recordTypeFilter shouldBe Some(Set(CNAME)) } "return all recordsets in a zone in descending order" in { val existing = insert(okZone, 10).map(_.recordSet) - val found = repo.listRecordSets(Some(okZone.id), None, None, None, None, None, NameSort.DESC).unsafeRunSync() - found.recordSets should contain theSameElementsAs existing.map(r => recordSetWithFQDN(r, okZone)) + val found = repo + .listRecordSets(Some(okZone.id), None, None, None, None, None, NameSort.DESC) + .unsafeRunSync() + found.recordSets should contain theSameElementsAs existing.map( + r => recordSetWithFQDN(r, okZone) + ) found.nameSort shouldBe NameSort.DESC } "pages through the list properly" in { // load 5 records, pages of 2, last page should have 1 result and no next id val existing = insert(okZone, 5).map(_.recordSet).sortBy(_.name) - val page1 = repo.listRecordSets(Some(okZone.id), None, Some(2), None, None, None, NameSort.ASC).unsafeRunSync() - (page1.recordSets should contain).theSameElementsInOrderAs(existing.slice(0, 2) - .map(r => recordSetWithFQDN(r, okZone))) + val page1 = repo + .listRecordSets(Some(okZone.id), None, Some(2), None, None, None, NameSort.ASC) + .unsafeRunSync() + (page1.recordSets should contain).theSameElementsInOrderAs( + existing + .slice(0, 2) + .map(r => recordSetWithFQDN(r, okZone)) + ) page1.nextId shouldBe Some(PagingKey.toNextId(page1.recordSets(1), true)) - val page2 = repo.listRecordSets(Some(okZone.id), page1.nextId, Some(2), None, None, None, NameSort.ASC).unsafeRunSync() - (page2.recordSets should contain).theSameElementsInOrderAs(existing.slice(2, 4) - .map(r => recordSetWithFQDN(r, okZone))) + val page2 = repo + .listRecordSets(Some(okZone.id), page1.nextId, Some(2), None, None, None, NameSort.ASC) + .unsafeRunSync() + (page2.recordSets should contain).theSameElementsInOrderAs( + existing + .slice(2, 4) + .map(r => recordSetWithFQDN(r, okZone)) + ) page2.nextId shouldBe Some(PagingKey.toNextId(page2.recordSets(1), true)) - val page3 = repo.listRecordSets(Some(okZone.id), page2.nextId, Some(2), None, None, None, NameSort.ASC).unsafeRunSync() - (page3.recordSets should contain).theSameElementsInOrderAs(existing.slice(4, 5) - .map(r => recordSetWithFQDN(r, okZone))) + val page3 = repo + .listRecordSets(Some(okZone.id), page2.nextId, Some(2), None, None, None, NameSort.ASC) + .unsafeRunSync() + (page3.recordSets should contain).theSameElementsInOrderAs( + existing + .slice(4, 5) + .map(r => recordSetWithFQDN(r, okZone)) + ) page3.nextId shouldBe None } "page properly when records have the same name" in { @@ -514,40 +579,58 @@ class MySqlRecordSetRepositoryIntegrationSpec insert(editedChanges) val existing = editedChanges.map(_.recordSet) - val page1 = repo.listRecordSets(Some(okZone.id), None, Some(2), None, None, None, NameSort.ASC).unsafeRunSync() - (page1.recordSets should contain).theSameElementsInOrderAs(List( - recordSetWithFQDN(existing.head, okZone), - recordSetWithFQDN(existing(1), okZone))) + val page1 = repo + .listRecordSets(Some(okZone.id), None, Some(2), None, None, None, NameSort.ASC) + .unsafeRunSync() + (page1.recordSets should contain).theSameElementsInOrderAs( + List(recordSetWithFQDN(existing.head, okZone), recordSetWithFQDN(existing(1), okZone)) + ) page1.nextId shouldBe Some(PagingKey.toNextId(page1.recordSets.last, true)) - val page2 = repo.listRecordSets(Some(okZone.id), page1.nextId, Some(2), None, None, None, NameSort.ASC).unsafeRunSync() - (page2.recordSets should contain).theSameElementsInOrderAs(List( - recordSetWithFQDN(existing(2), okZone), recordSetWithFQDN(existing(3), okZone))) + val page2 = repo + .listRecordSets(Some(okZone.id), page1.nextId, Some(2), None, None, None, NameSort.ASC) + .unsafeRunSync() + (page2.recordSets should contain).theSameElementsInOrderAs( + List(recordSetWithFQDN(existing(2), okZone), recordSetWithFQDN(existing(3), okZone)) + ) page2.nextId shouldBe Some(PagingKey.toNextId(page2.recordSets.last, true)) - val page3 = repo.listRecordSets(Some(okZone.id), page2.nextId, Some(2), None, None, None, NameSort.ASC).unsafeRunSync() - (page3.recordSets should contain).theSameElementsInOrderAs(List(recordSetWithFQDN(existing(4), okZone))) + val page3 = repo + .listRecordSets(Some(okZone.id), page2.nextId, Some(2), None, None, None, NameSort.ASC) + .unsafeRunSync() + (page3.recordSets should contain) + .theSameElementsInOrderAs(List(recordSetWithFQDN(existing(4), okZone))) page3.nextId shouldBe None } "return applicable recordsets in ascending order when recordNameFilter is given" in { val existing = insert(okZone, 10).map(_.recordSet) - val found = repo.listRecordSets(None, None, None, Some("*.ok*"), None, None, NameSort.ASC).unsafeRunSync() - found.recordSets should contain theSameElementsAs existing.map(r => recordSetWithFQDN(r, okZone)) + val found = repo + .listRecordSets(None, None, None, Some("*.ok*"), None, None, NameSort.ASC) + .unsafeRunSync() + found.recordSets should contain theSameElementsAs existing.map( + r => recordSetWithFQDN(r, okZone) + ) } "return applicable recordsets in descending order when recordNameFilter is given and name sort is descending" in { val existing = insert(okZone, 10).map(_.recordSet) - val found = repo.listRecordSets(None, None, None, Some("*.ok*"), None, None, NameSort.DESC).unsafeRunSync() - found.recordSets should contain theSameElementsAs existing.map(r => recordSetWithFQDN(r, okZone)).reverse + val found = repo + .listRecordSets(None, None, None, Some("*.ok*"), None, None, NameSort.DESC) + .unsafeRunSync() + found.recordSets should contain theSameElementsAs existing + .map(r => recordSetWithFQDN(r, okZone)) + .reverse } "return no recordsets when no zoneId or recordNameFilter are given" in { - val found = repo.listRecordSets(None, None, None, None, None, None, NameSort.ASC).unsafeRunSync() + val found = + repo.listRecordSets(None, None, None, None, None, None, NameSort.ASC).unsafeRunSync() found.recordSets shouldBe empty } } "get record sets by name and type" should { "return a record set when there is a match" in { val existing = insert(okZone, 1).map(_.recordSet) - val results = repo.getRecordSets(okZone.id, existing.head.name, existing.head.typ).unsafeRunSync() + val results = + repo.getRecordSets(okZone.id, existing.head.name, existing.head.typ).unsafeRunSync() results.headOption shouldBe Some(recordSetWithFQDN(existing.head, okZone)) } "return none when there is no match" in { @@ -607,7 +690,8 @@ class MySqlRecordSetRepositoryIntegrationSpec val result = repo.getRecordSetsByFQDNs(Set("no-existo", fqdn1, fqdn2)).unsafeRunSync() result should contain theSameElementsAs List( recordSetWithFQDN(change1.recordSet, okZone), - recordSetWithFQDN(change2.recordSet, okZone)) + recordSetWithFQDN(change2.recordSet, okZone) + ) } "return records of different types with the same fqdn" in { @@ -621,7 +705,8 @@ class MySqlRecordSetRepositoryIntegrationSpec val result = repo.getRecordSetsByFQDNs(Set(fqdn)).unsafeRunSync() result should contain theSameElementsAs List( recordSetWithFQDN(aaaaChange.recordSet, okZone), - recordSetWithFQDN(mxChange.recordSet, okZone)) + recordSetWithFQDN(mxChange.recordSet, okZone) + ) } "return an empty list when given no ids" in { @@ -643,11 +728,13 @@ class MySqlRecordSetRepositoryIntegrationSpec val result1 = repo.getRecordSetsByFQDNs(Set(fqdn1)).unsafeRunSync() result1 should contain theSameElementsAs List( recordSetWithFQDN(change1.recordSet, okZone), - recordSetWithFQDN(change2.recordSet, okZone)) + recordSetWithFQDN(change2.recordSet, okZone) + ) val result2 = repo.getRecordSetsByFQDNs(Set(fqdn2)).unsafeRunSync() result2 should contain theSameElementsAs List( recordSetWithFQDN(change1.recordSet, okZone), - recordSetWithFQDN(change2.recordSet, okZone)) + recordSetWithFQDN(change2.recordSet, okZone) + ) } } diff --git a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlTaskRepositoryIntegrationSpec.scala b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlTaskRepositoryIntegrationSpec.scala index 866f079a1..ff03b01c2 100644 --- a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlTaskRepositoryIntegrationSpec.scala +++ b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlTaskRepositoryIntegrationSpec.scala @@ -20,13 +20,15 @@ import java.time.Instant import cats.effect.IO import org.scalatest._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import scalikejdbc.{DB, _} import vinyldns.mysql.TestMySqlInstance import scala.concurrent.duration._ class MySqlTaskRepositoryIntegrationSpec - extends WordSpec + extends AnyWordSpec with BeforeAndAfterAll with BeforeAndAfterEach with Matchers { diff --git a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlUserChangeRepositoryIntegrationSpec.scala b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlUserChangeRepositoryIntegrationSpec.scala index 701c0da8b..e9c5341c2 100644 --- a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlUserChangeRepositoryIntegrationSpec.scala +++ b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlUserChangeRepositoryIntegrationSpec.scala @@ -16,14 +16,16 @@ package vinyldns.mysql.repository -import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import scalikejdbc.DB import vinyldns.core.domain.membership.UserChange.{CreateUser, UpdateUser} import vinyldns.core.domain.membership.{User, UserChangeRepository} import vinyldns.mysql.TestMySqlInstance class MySqlUserChangeRepositoryIntegrationSpec - extends WordSpec + extends AnyWordSpec with BeforeAndAfterAll with BeforeAndAfterEach with Matchers { diff --git a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlUserRepositoryIntegrationSpec.scala b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlUserRepositoryIntegrationSpec.scala index d92a1f415..a4b739670 100644 --- a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlUserRepositoryIntegrationSpec.scala +++ b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlUserRepositoryIntegrationSpec.scala @@ -17,12 +17,14 @@ package vinyldns.mysql.repository import org.scalatest._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import scalikejdbc.DB import vinyldns.core.domain.membership.{LockStatus, User, UserRepository} import vinyldns.mysql.TestMySqlInstance class MySqlUserRepositoryIntegrationSpec - extends WordSpec + extends AnyWordSpec with BeforeAndAfterAll with BeforeAndAfterEach with Matchers diff --git a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlZoneChangeRepositoryIntegrationSpec.scala b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlZoneChangeRepositoryIntegrationSpec.scala index 3e09c5273..1a99cb7ad 100644 --- a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlZoneChangeRepositoryIntegrationSpec.scala +++ b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlZoneChangeRepositoryIntegrationSpec.scala @@ -22,6 +22,8 @@ import cats.effect.{ContextShift, IO} import cats.implicits._ import org.joda.time.DateTime import org.scalatest._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import scalikejdbc.DB import vinyldns.core.domain.membership.User import vinyldns.core.domain.zone.ZoneChangeStatus.ZoneChangeStatus @@ -34,7 +36,7 @@ import scala.concurrent.duration._ import scala.util.Random class MySqlZoneChangeRepositoryIntegrationSpec - extends WordSpec + extends AnyWordSpec with BeforeAndAfterAll with BeforeAndAfterEach with Matchers diff --git a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlZoneRepositoryIntegrationSpec.scala b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlZoneRepositoryIntegrationSpec.scala index 7293457de..314209155 100644 --- a/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlZoneRepositoryIntegrationSpec.scala +++ b/modules/mysql/src/it/scala/vinyldns/mysql/repository/MySqlZoneRepositoryIntegrationSpec.scala @@ -20,6 +20,8 @@ import java.util.UUID import cats.effect._ import org.scalatest._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import scalikejdbc.DB import vinyldns.core.domain.auth.AuthPrincipal import vinyldns.core.domain.membership.User @@ -30,7 +32,7 @@ import vinyldns.core.domain.zone.ZoneRepository.DuplicateZoneError import vinyldns.mysql.TestMySqlInstance class MySqlZoneRepositoryIntegrationSpec - extends WordSpec + extends AnyWordSpec with BeforeAndAfterAll with BeforeAndAfterEach with Matchers diff --git a/modules/mysql/src/main/scala/vinyldns/mysql/queue/MySqlMessageQueueProvider.scala b/modules/mysql/src/main/scala/vinyldns/mysql/queue/MySqlMessageQueueProvider.scala index acbe52c9e..3c913cb59 100644 --- a/modules/mysql/src/main/scala/vinyldns/mysql/queue/MySqlMessageQueueProvider.scala +++ b/modules/mysql/src/main/scala/vinyldns/mysql/queue/MySqlMessageQueueProvider.scala @@ -18,13 +18,16 @@ package vinyldns.mysql.queue import cats.effect.IO import org.slf4j.LoggerFactory -import pureconfig.ConfigReader -import pureconfig.module.catseffect.loadConfigF +import pureconfig._ +import pureconfig.generic.auto._ +import pureconfig.module.catseffect.syntax._ import scalikejdbc.{ConnectionPool, DataSourceConnectionPool} import scalikejdbc.config.DBs import vinyldns.core.queue.{MessageQueue, MessageQueueConfig, MessageQueueProvider} import vinyldns.mysql.{HikariCloser, MySqlConnectionConfig, MySqlDataSourceSettings} import vinyldns.mysql.MySqlConnector._ +import cats.effect.ContextShift +import cats.effect.Blocker class MySqlMessageQueueProvider extends MessageQueueProvider { @@ -33,9 +36,14 @@ class MySqlMessageQueueProvider extends MessageQueueProvider { implicit val mySqlPropertiesReader: ConfigReader[Map[String, AnyRef]] = MySqlConnectionConfig.mySqlPropertiesReader + private implicit val cs: ContextShift[IO] = + IO.contextShift(scala.concurrent.ExecutionContext.global) + def load(config: MessageQueueConfig): IO[MessageQueue] = for { - connectionSettings <- loadConfigF[IO, MySqlConnectionConfig](config.settings) + connectionSettings <- Blocker[IO].use( + ConfigSource.fromConfig(config.settings).loadF[IO, MySqlConnectionConfig](_) + ) _ <- runDBMigrations(connectionSettings) _ <- setupQueueConnection(connectionSettings) } yield new MySqlMessageQueue(config.maxRetries) diff --git a/modules/mysql/src/main/scala/vinyldns/mysql/repository/MySqlDataStoreProvider.scala b/modules/mysql/src/main/scala/vinyldns/mysql/repository/MySqlDataStoreProvider.scala index a2d75e83b..88b918299 100644 --- a/modules/mysql/src/main/scala/vinyldns/mysql/repository/MySqlDataStoreProvider.scala +++ b/modules/mysql/src/main/scala/vinyldns/mysql/repository/MySqlDataStoreProvider.scala @@ -19,8 +19,9 @@ package vinyldns.mysql.repository import cats.effect._ import cats.implicits._ import org.slf4j.LoggerFactory -import pureconfig.ConfigReader -import pureconfig.module.catseffect.loadConfigF +import pureconfig._ +import pureconfig.generic.auto._ +import pureconfig.module.catseffect.syntax._ import scalikejdbc.config.DBs import scalikejdbc._ import vinyldns.core.crypto.CryptoAlgebra @@ -36,9 +37,14 @@ class MySqlDataStoreProvider extends DataStoreProvider { implicit val mySqlPropertiesReader: ConfigReader[Map[String, AnyRef]] = MySqlConnectionConfig.mySqlPropertiesReader + private implicit val cs: ContextShift[IO] = + IO.contextShift(scala.concurrent.ExecutionContext.global) + def load(config: DataStoreConfig, cryptoAlgebra: CryptoAlgebra): IO[LoadedDataStore] = for { - settingsConfig <- loadConfigF[IO, MySqlConnectionConfig](config.settings) + settingsConfig <- Blocker[IO].use( + ConfigSource.fromConfig(config.settings).loadF[IO, MySqlConnectionConfig](_) + ) _ <- runDBMigrations(settingsConfig) _ <- setupDBConnection(settingsConfig) store <- initializeRepos(cryptoAlgebra) diff --git a/modules/mysql/src/main/scala/vinyldns/mysql/repository/MySqlRecordChangeRepository.scala b/modules/mysql/src/main/scala/vinyldns/mysql/repository/MySqlRecordChangeRepository.scala index c1c790e86..3f21114ce 100644 --- a/modules/mysql/src/main/scala/vinyldns/mysql/repository/MySqlRecordChangeRepository.scala +++ b/modules/mysql/src/main/scala/vinyldns/mysql/repository/MySqlRecordChangeRepository.scala @@ -17,7 +17,6 @@ package vinyldns.mysql.repository import cats.effect._ -import cats.implicits._ import scalikejdbc._ import vinyldns.core.domain.record.RecordSetChangeType.RecordSetChangeType import vinyldns.core.domain.record._ diff --git a/modules/mysql/src/test/scala/vinyldns/mysql/MySqlConnectionConfigSpec.scala b/modules/mysql/src/test/scala/vinyldns/mysql/MySqlConnectionConfigSpec.scala index 6b5ce29bd..a1af192c1 100644 --- a/modules/mysql/src/test/scala/vinyldns/mysql/MySqlConnectionConfigSpec.scala +++ b/modules/mysql/src/test/scala/vinyldns/mysql/MySqlConnectionConfigSpec.scala @@ -16,17 +16,17 @@ package vinyldns.mysql -import cats.effect.IO import com.typesafe.config.{Config, ConfigFactory} -import org.scalatest.{Matchers, WordSpec} -import pureconfig.ConfigReader -import pureconfig.module.catseffect.loadConfigF +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec +import pureconfig._ +import pureconfig.generic.auto._ import vinyldns.core.repository.DataStoreConfig -class MySqlConnectionConfigSpec extends WordSpec with Matchers { +class MySqlConnectionConfigSpec extends AnyWordSpec with Matchers { val mySqlConfig: Config = ConfigFactory.load().getConfig("mysql") val dataStoreSettings: DataStoreConfig = - pureconfig.loadConfigOrThrow[DataStoreConfig](mySqlConfig) + ConfigSource.fromConfig(mySqlConfig).loadOrThrow[DataStoreConfig] implicit val mySqlPropertiesReader: ConfigReader[Map[String, AnyRef]] = MySqlConnectionConfig.mySqlPropertiesReader @@ -41,8 +41,7 @@ class MySqlConnectionConfigSpec extends WordSpec with Matchers { ) val settingsConfig = - loadConfigF[IO, MySqlConnectionConfig](dataStoreSettings.settings).unsafeRunSync() - + ConfigSource.fromConfig(dataStoreSettings.settings).loadOrThrow[MySqlConnectionConfig] settingsConfig.mySqlProperties shouldBe configProperties } @@ -59,9 +58,7 @@ class MySqlConnectionConfigSpec extends WordSpec with Matchers { | } | """.stripMargin) - val settingsConfig = - loadConfigF[IO, MySqlConnectionConfig](conf).unsafeRunSync() - + val settingsConfig = ConfigSource.fromConfig(conf).loadOrThrow[MySqlConnectionConfig] settingsConfig.mySqlProperties shouldBe Map() } } diff --git a/modules/mysql/src/test/scala/vinyldns/mysql/queue/MySqlMessageQueueProviderSpec.scala b/modules/mysql/src/test/scala/vinyldns/mysql/queue/MySqlMessageQueueProviderSpec.scala index 482c5dd98..ad8ef19d0 100644 --- a/modules/mysql/src/test/scala/vinyldns/mysql/queue/MySqlMessageQueueProviderSpec.scala +++ b/modules/mysql/src/test/scala/vinyldns/mysql/queue/MySqlMessageQueueProviderSpec.scala @@ -17,11 +17,14 @@ package vinyldns.mysql.queue import com.typesafe.config.ConfigFactory -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.queue.MessageQueueConfig import vinyldns.mysql.MySqlConnectionConfig +import pureconfig._ +import pureconfig.generic.auto._ -class MySqlMessageQueueProviderSpec extends WordSpec with Matchers { +class MySqlMessageQueueProviderSpec extends AnyWordSpec with Matchers { val undertest = new MySqlMessageQueueProvider() @@ -42,7 +45,8 @@ class MySqlMessageQueueProviderSpec extends WordSpec with Matchers { | | """.stripMargin) - val badSettings = pureconfig.loadConfigOrThrow[MessageQueueConfig](badConfig) + val badSettings = + ConfigSource.fromConfig(badConfig).loadOrThrow[MessageQueueConfig] a[pureconfig.error.ConfigReaderException[MySqlConnectionConfig]] should be thrownBy undertest .load(badSettings) diff --git a/modules/mysql/src/test/scala/vinyldns/mysql/repository/MySqlDataStoreProviderSpec.scala b/modules/mysql/src/test/scala/vinyldns/mysql/repository/MySqlDataStoreProviderSpec.scala index cbe921142..7651f0e5f 100644 --- a/modules/mysql/src/test/scala/vinyldns/mysql/repository/MySqlDataStoreProviderSpec.scala +++ b/modules/mysql/src/test/scala/vinyldns/mysql/repository/MySqlDataStoreProviderSpec.scala @@ -17,16 +17,19 @@ package vinyldns.mysql.repository import com.typesafe.config.{Config, ConfigFactory} -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.crypto.{CryptoAlgebra, NoOpCrypto} import vinyldns.core.repository.DataStoreConfig import vinyldns.mysql.MySqlConnectionConfig +import pureconfig._ +import pureconfig.generic.auto._ -class MySqlDataStoreProviderSpec extends WordSpec with Matchers { +class MySqlDataStoreProviderSpec extends AnyWordSpec with Matchers { val mySqlConfig: Config = ConfigFactory.load().getConfig("mysql") val dataStoreSettings: DataStoreConfig = - pureconfig.loadConfigOrThrow[DataStoreConfig](mySqlConfig) + ConfigSource.fromConfig(mySqlConfig).loadOrThrow[DataStoreConfig] val underTest = new MySqlDataStoreProvider() @@ -56,7 +59,7 @@ class MySqlDataStoreProviderSpec extends WordSpec with Matchers { | """.stripMargin ) - val badSettings = pureconfig.loadConfigOrThrow[DataStoreConfig](badConfig) + val badSettings = ConfigSource.fromConfig(badConfig).loadOrThrow[DataStoreConfig] a[pureconfig.error.ConfigReaderException[MySqlConnectionConfig]] should be thrownBy underTest .load(badSettings, crypto) diff --git a/modules/mysql/src/test/scala/vinyldns/mysql/repository/MySqlRecordSetRepositorySpec.scala b/modules/mysql/src/test/scala/vinyldns/mysql/repository/MySqlRecordSetRepositorySpec.scala index 66b715bff..8cb22b1d7 100644 --- a/modules/mysql/src/test/scala/vinyldns/mysql/repository/MySqlRecordSetRepositorySpec.scala +++ b/modules/mysql/src/test/scala/vinyldns/mysql/repository/MySqlRecordSetRepositorySpec.scala @@ -15,11 +15,12 @@ */ package vinyldns.mysql.repository -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.domain.record.RecordType import vinyldns.core.TestRecordSetData.aaaa -class MySqlRecordSetRepositorySpec extends WordSpec with Matchers { +class MySqlRecordSetRepositorySpec extends AnyWordSpec with Matchers { import MySqlRecordSetRepository._ "fromRecordType" should { "support all record types" in { diff --git a/modules/mysql/src/test/scala/vinyldns/mysql/repository/MySqlZoneRepositorySpec.scala b/modules/mysql/src/test/scala/vinyldns/mysql/repository/MySqlZoneRepositorySpec.scala index 02ffa4c3d..8d2f5f6ff 100644 --- a/modules/mysql/src/test/scala/vinyldns/mysql/repository/MySqlZoneRepositorySpec.scala +++ b/modules/mysql/src/test/scala/vinyldns/mysql/repository/MySqlZoneRepositorySpec.scala @@ -17,17 +17,19 @@ package vinyldns.mysql.repository import cats.effect.IO -import org.scalatest.{BeforeAndAfterEach, Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec +import org.scalatest.BeforeAndAfterEach import org.mockito.Mockito._ import org.mockito.Matchers._ -import org.scalatest.mockito.MockitoSugar +import org.scalatestplus.mockito.MockitoSugar import vinyldns.core.domain.zone.ZoneRepository.DuplicateZoneError import vinyldns.core.domain.zone.{Zone, ZoneStatus} import scala.concurrent.duration._ class MySqlZoneRepositorySpec - extends WordSpec + extends AnyWordSpec with MockitoSugar with Matchers with BeforeAndAfterEach { diff --git a/modules/portal/app/controllers/OidcAuthenticator.scala b/modules/portal/app/controllers/OidcAuthenticator.scala index ee0ff1485..bca617993 100644 --- a/modules/portal/app/controllers/OidcAuthenticator.scala +++ b/modules/portal/app/controllers/OidcAuthenticator.scala @@ -40,10 +40,12 @@ import org.slf4j.{Logger, LoggerFactory} import play.api.Configuration import play.api.libs.ws.WSClient import play.api.mvc.RequestHeader +import pureconfig.generic.auto._ import scala.concurrent.ExecutionContext import scala.util.{Failure, Success, Try} import scala.collection.JavaConverters._ +import pureconfig.ConfigSource object OidcAuthenticator { final case class OidcConfig( @@ -79,7 +81,7 @@ class OidcAuthenticator @Inject() (wsClient: WSClient, configuration: Configurat private val logger: Logger = LoggerFactory.getLogger(classOf[OidcAuthenticator]) val oidcEnabled: Boolean = configuration.getOptional[Boolean]("oidc.enabled").getOrElse(false) lazy val oidcInfo: OidcConfig = - pureconfig.loadConfigOrThrow[OidcConfig](configuration.underlying, "oidc") + ConfigSource.fromConfig(configuration.underlying).at("oidc").loadOrThrow[OidcConfig] lazy val clientID = new ClientID(oidcInfo.clientId) lazy val clientSecret = new Secret(oidcInfo.secret) diff --git a/modules/portal/app/controllers/Settings.scala b/modules/portal/app/controllers/Settings.scala index 00de539d2..d6a1b3ae4 100644 --- a/modules/portal/app/controllers/Settings.scala +++ b/modules/portal/app/controllers/Settings.scala @@ -18,11 +18,13 @@ package controllers import java.net.URI -import cats.effect.{ContextShift, IO} +import cats.effect.{Blocker, ContextShift, IO} import cats.implicits._ import com.typesafe.config.{Config, ConfigFactory} import play.api.{ConfigLoader, Configuration} -import pureconfig.module.catseffect.loadConfigF +import pureconfig._ +import pureconfig.generic.auto._ +import pureconfig.module.catseffect.syntax._ import vinyldns.core.repository.DataStoreConfig import scala.collection.JavaConverters._ @@ -55,8 +57,18 @@ class Settings(private val config: Configuration) { val portalTestLogin: Boolean = config.getOptional[Boolean]("portal.test_login").getOrElse(false) val dataStoreConfigs: IO[List[DataStoreConfig]] = - loadConfigF[IO, List[String]](config.underlying, "data-stores").flatMap { lst => - lst.map(loadConfigF[IO, DataStoreConfig](config.underlying, _)).parSequence + Blocker[IO].use { blocker => + ConfigSource + .fromConfig(config.underlying) + .at("data-stores") + .loadF[IO, List[String]](blocker) + .flatMap { lst => + lst + .map( + ConfigSource.fromConfig(config.underlying).at(_).loadF[IO, DataStoreConfig](blocker) + ) + .parSequence + } } val cryptoConfig = IO(config.get[Config]("crypto")) diff --git a/modules/sqs/src/it/scala/vinyldns/sqs/queue/SqsMessageQueueIntegrationSpec.scala b/modules/sqs/src/it/scala/vinyldns/sqs/queue/SqsMessageQueueIntegrationSpec.scala index ab112bd7d..fd04d05d4 100644 --- a/modules/sqs/src/it/scala/vinyldns/sqs/queue/SqsMessageQueueIntegrationSpec.scala +++ b/modules/sqs/src/it/scala/vinyldns/sqs/queue/SqsMessageQueueIntegrationSpec.scala @@ -21,9 +21,10 @@ import java.util.concurrent.TimeUnit.SECONDS import cats.data.NonEmptyList import cats.scalatest.EitherMatchers import com.amazonaws.services.sqs.model._ -import com.typesafe.config.ConfigFactory import org.scalatest._ -import org.scalatest.mockito.MockitoSugar +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec +import org.scalatestplus.mockito.MockitoSugar import vinyldns.core.TestRecordSetData._ import vinyldns.core.TestZoneData._ import vinyldns.core.domain.record.RecordSetChange @@ -32,9 +33,11 @@ import vinyldns.core.queue.{MessageCount, MessageId, MessageQueueConfig} import vinyldns.sqs.queue.SqsMessageQueue.InvalidMessageTimeout import scala.concurrent.duration.FiniteDuration +import pureconfig._ +import pureconfig.generic.auto._ class SqsMessageQueueIntegrationSpec - extends WordSpec + extends AnyWordSpec with MockitoSugar with BeforeAndAfterAll with BeforeAndAfterEach @@ -44,7 +47,7 @@ class SqsMessageQueueIntegrationSpec with ProtobufConversions { private val sqsMessageQueueSettings: MessageQueueConfig = - pureconfig.loadConfigOrThrow[MessageQueueConfig](ConfigFactory.load().getConfig("sqs")) + ConfigSource.default.at("sqs").loadOrThrow[MessageQueueConfig] private val provider = new SqsMessageQueueProvider() private val queue: SqsMessageQueue = diff --git a/modules/sqs/src/it/scala/vinyldns/sqs/queue/SqsMessageQueueProviderIntegrationSpec.scala b/modules/sqs/src/it/scala/vinyldns/sqs/queue/SqsMessageQueueProviderIntegrationSpec.scala index c24111dda..4bafff86f 100644 --- a/modules/sqs/src/it/scala/vinyldns/sqs/queue/SqsMessageQueueProviderIntegrationSpec.scala +++ b/modules/sqs/src/it/scala/vinyldns/sqs/queue/SqsMessageQueueProviderIntegrationSpec.scala @@ -16,11 +16,14 @@ package vinyldns.sqs.queue import com.typesafe.config.ConfigFactory -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec import vinyldns.core.queue.{MessageQueueConfig, MessageQueueLoader} import vinyldns.sqs.queue.SqsMessageQueueProvider.InvalidQueueName +import pureconfig._ +import pureconfig.generic.auto._ -class SqsMessageQueueProviderIntegrationSpec extends WordSpec with Matchers { +class SqsMessageQueueProviderIntegrationSpec extends AnyWordSpec with Matchers { val undertest = new SqsMessageQueueProvider() "load" should { @@ -40,7 +43,7 @@ class SqsMessageQueueProviderIntegrationSpec extends WordSpec with Matchers { | } | """.stripMargin) - val badSettings = pureconfig.loadConfigOrThrow[MessageQueueConfig](badConfig) + val badSettings = ConfigSource.fromConfig(badConfig).loadOrThrow[MessageQueueConfig] a[pureconfig.error.ConfigReaderException[MessageQueueConfig]] should be thrownBy undertest .load(badSettings) @@ -64,7 +67,8 @@ class SqsMessageQueueProviderIntegrationSpec extends WordSpec with Matchers { | } | """.stripMargin) - val messageConfig = pureconfig.loadConfigOrThrow[MessageQueueConfig](nonExistentQueueConfig) + val messageConfig = + ConfigSource.fromConfig(nonExistentQueueConfig).loadOrThrow[MessageQueueConfig] val messageQueue = undertest.load(messageConfig).unsafeRunSync() noException should be thrownBy messageQueue @@ -90,7 +94,8 @@ class SqsMessageQueueProviderIntegrationSpec extends WordSpec with Matchers { | } | """.stripMargin) - val messageConfig = pureconfig.loadConfigOrThrow[MessageQueueConfig](invalidQueueNameConfig) + val messageConfig = + ConfigSource.fromConfig(invalidQueueNameConfig).loadOrThrow[MessageQueueConfig] assertThrows[InvalidQueueName](undertest.load(messageConfig).unsafeRunSync()) } @@ -111,7 +116,7 @@ class SqsMessageQueueProviderIntegrationSpec extends WordSpec with Matchers { | } | """.stripMargin) - val messageConfig = pureconfig.loadConfigOrThrow[MessageQueueConfig](fifoQueueName) + val messageConfig = ConfigSource.fromConfig(fifoQueueName).loadOrThrow[MessageQueueConfig] assertThrows[InvalidQueueName](undertest.load(messageConfig).unsafeRunSync()) } } @@ -134,7 +139,8 @@ class SqsMessageQueueProviderIntegrationSpec extends WordSpec with Matchers { | } | """.stripMargin) - val messageConfig = pureconfig.loadConfigOrThrow[MessageQueueConfig](nonExistentQueueConfig) + val messageConfig = + ConfigSource.fromConfig(nonExistentQueueConfig).loadOrThrow[MessageQueueConfig] val queue = MessageQueueLoader.load(messageConfig).unsafeRunSync() queue shouldBe a[SqsMessageQueue] diff --git a/modules/sqs/src/main/scala/vinyldns/sqs/queue/SqsMessageQueueProvider.scala b/modules/sqs/src/main/scala/vinyldns/sqs/queue/SqsMessageQueueProvider.scala index 704eeae5d..d7583a9ab 100644 --- a/modules/sqs/src/main/scala/vinyldns/sqs/queue/SqsMessageQueueProvider.scala +++ b/modules/sqs/src/main/scala/vinyldns/sqs/queue/SqsMessageQueueProvider.scala @@ -22,17 +22,26 @@ import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration import com.amazonaws.services.sqs.model.QueueDoesNotExistException import com.amazonaws.services.sqs.{AmazonSQSAsync, AmazonSQSAsyncClientBuilder} import org.slf4j.LoggerFactory -import pureconfig.module.catseffect.loadConfigF +import pureconfig._ +import pureconfig.generic.auto._ +import pureconfig.module.catseffect.syntax._ +import cats.effect.Blocker import vinyldns.core.queue.{MessageQueue, MessageQueueConfig, MessageQueueProvider} import scala.util.matching.Regex +import cats.effect.ContextShift class SqsMessageQueueProvider extends MessageQueueProvider { import SqsMessageQueueProvider._ + private implicit val cs: ContextShift[IO] = + IO.contextShift(scala.concurrent.ExecutionContext.global) + def load(config: MessageQueueConfig): IO[MessageQueue] = for { - settingsConfig <- loadConfigF[IO, SqsMessageQueueSettings](config.settings) + settingsConfig <- Blocker[IO].use( + ConfigSource.fromConfig(config.settings).loadF[IO, SqsMessageQueueSettings](_) + ) _ <- IO.fromEither(validateQueueName(settingsConfig.queueName)) client <- setupClient(settingsConfig) queueUrl <- setupQueue(client, settingsConfig.queueName) diff --git a/modules/sqs/src/test/scala/vinyldns/sqs/queue/SqsMessageQueueProviderSpec.scala b/modules/sqs/src/test/scala/vinyldns/sqs/queue/SqsMessageQueueProviderSpec.scala index f776d6cb0..04bd57978 100644 --- a/modules/sqs/src/test/scala/vinyldns/sqs/queue/SqsMessageQueueProviderSpec.scala +++ b/modules/sqs/src/test/scala/vinyldns/sqs/queue/SqsMessageQueueProviderSpec.scala @@ -15,9 +15,10 @@ */ package vinyldns.sqs.queue -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class SqsMessageQueueProviderSpec extends WordSpec with Matchers { +class SqsMessageQueueProviderSpec extends AnyWordSpec with Matchers { val undertest = new SqsMessageQueueProvider() import SqsMessageQueueProvider._ diff --git a/modules/sqs/src/test/scala/vinyldns/sqs/queue/SqsMessageQueueSpec.scala b/modules/sqs/src/test/scala/vinyldns/sqs/queue/SqsMessageQueueSpec.scala index d6aeb875a..ff7073f2f 100644 --- a/modules/sqs/src/test/scala/vinyldns/sqs/queue/SqsMessageQueueSpec.scala +++ b/modules/sqs/src/test/scala/vinyldns/sqs/queue/SqsMessageQueueSpec.scala @@ -21,8 +21,7 @@ import java.util.concurrent.TimeUnit.{HOURS, SECONDS} import cats.data.NonEmptyList import com.amazonaws.services.sqs.model._ -import org.scalatest.mockito.MockitoSugar -import org.scalatest.{Matchers, WordSpec} +import org.scalatestplus.mockito.MockitoSugar import vinyldns.core.TestRecordSetData._ import vinyldns.core.TestZoneData._ import vinyldns.core.domain.batch.BatchChangeCommand @@ -34,9 +33,11 @@ import vinyldns.sqs.queue.SqsMessageType._ import scala.collection.JavaConverters._ import scala.concurrent.ExecutionContext import scala.concurrent.duration.FiniteDuration +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec class SqsMessageQueueSpec - extends WordSpec + extends AnyWordSpec with Matchers with MockitoSugar with ProtobufConversions { diff --git a/modules/sqs/src/test/scala/vinyldns/sqs/queue/SqsMessageSpec.scala b/modules/sqs/src/test/scala/vinyldns/sqs/queue/SqsMessageSpec.scala index 3bee7537e..0b70ac428 100644 --- a/modules/sqs/src/test/scala/vinyldns/sqs/queue/SqsMessageSpec.scala +++ b/modules/sqs/src/test/scala/vinyldns/sqs/queue/SqsMessageSpec.scala @@ -18,7 +18,7 @@ package vinyldns.sqs.queue import java.util.Base64 import com.amazonaws.services.sqs.model.{Message, MessageAttributeValue} -import org.scalatest.{EitherValues, Matchers, WordSpec} +import org.scalatest.EitherValues import vinyldns.core.TestRecordSetData.pendingCreateAAAA import vinyldns.core.TestZoneData.zoneChangePending import vinyldns.core.domain.batch.BatchChangeCommand @@ -30,8 +30,10 @@ import vinyldns.sqs.queue.SqsMessageType.{ } import scala.collection.JavaConverters._ +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class SqsMessageSpec extends WordSpec with Matchers with EitherValues with ProtobufConversions { +class SqsMessageSpec extends AnyWordSpec with Matchers with EitherValues with ProtobufConversions { import SqsMessage._ "parseSqsMessage" should { diff --git a/modules/sqs/src/test/scala/vinyldns/sqs/queue/SqsMessageTypeSpec.scala b/modules/sqs/src/test/scala/vinyldns/sqs/queue/SqsMessageTypeSpec.scala index 27f79e1f3..c911149e1 100644 --- a/modules/sqs/src/test/scala/vinyldns/sqs/queue/SqsMessageTypeSpec.scala +++ b/modules/sqs/src/test/scala/vinyldns/sqs/queue/SqsMessageTypeSpec.scala @@ -16,9 +16,10 @@ package vinyldns.sqs.queue import com.amazonaws.services.sqs.model.Message -import org.scalatest.{Matchers, WordSpec} +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AnyWordSpec -class SqsMessageTypeSpec extends WordSpec with Matchers { +class SqsMessageTypeSpec extends AnyWordSpec with Matchers { import SqsMessageType._ "fromString" should { diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 83f514db8..40e425b39 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -1,22 +1,22 @@ import sbt._ object Dependencies { - lazy val akkaHttpV = "10.1.9" + lazy val akkaHttpV = "10.1.10" lazy val akkaV = "2.5.23" lazy val jettyV = "8.1.12.v20130726" - lazy val pureConfigV = "0.9.2" + lazy val pureConfigV = "0.12.3" lazy val metricsScalaV = "3.5.9" lazy val prometheusV = "0.4.0" - lazy val catsEffectV = "2.0.0" - lazy val configV = "1.3.2" + lazy val catsEffectV = "2.1.3" + lazy val configV = "1.4.0" lazy val scalikejdbcV = "3.3.1" - lazy val scalaTestV = "3.0.4" - lazy val scodecV = "1.1.5" - lazy val playV = "2.7.3" + lazy val scalaTestV = "3.1.1" + lazy val scodecV = "1.1.14" + lazy val playV = "2.7.4" lazy val awsV = "1.11.423" lazy val jaxbV = "2.3.0" lazy val ip4sV = "1.1.1" - lazy val fs2V = "2.0.1" + lazy val fs2V = "2.3.0" lazy val ficusV = "1.4.3" lazy val apiDependencies = Seq( @@ -71,7 +71,9 @@ object Dependencies { "com.sun.xml.bind" % "jaxb-impl" % jaxbV, "ch.qos.logback" % "logback-classic" % "1.0.7", "io.dropwizard.metrics" % "metrics-jvm" % "3.2.2", - "co.fs2" %% "fs2-core" % "1.0.0" + "co.fs2" %% "fs2-core" % "2.3.0", + "javax.xml.bind" % "jaxb-api" % "2.3.0", + "javax.activation" % "activation" % "1.1.1" ) lazy val dynamoDBDependencies = Seq( @@ -94,9 +96,11 @@ object Dependencies { lazy val commonTestDependencies = Seq( "org.scalatest" %% "scalatest" % scalaTestV, - "org.scalacheck" %% "scalacheck" % "1.13.4", - "com.ironcorelabs" %% "cats-scalatest" % "2.3.1", - "org.mockito" % "mockito-core" % "1.10.19" + "org.scalacheck" %% "scalacheck" % "1.14.3", + "com.ironcorelabs" %% "cats-scalatest" % "3.0.5", + "org.mockito" % "mockito-core" % "1.10.19", + "org.scalatestplus" %% "scalatestplus-mockito" % "1.0.0-M2", + "org.scalatestplus" %% "scalatestplus-scalacheck" % "3.1.0.0-RC2" ) lazy val apiTestDependencies = commonTestDependencies ++ Seq( diff --git a/project/Resolvers.scala b/project/Resolvers.scala index f814f117d..76f79021f 100644 --- a/project/Resolvers.scala +++ b/project/Resolvers.scala @@ -3,7 +3,6 @@ import sbt._ object Resolvers { lazy val additionalResolvers = Seq( - "spray" at "http://repo.spray.io/", "dnvriend at bintray" at "https://dl.bintray.com/dnvriend/maven", "bintray" at "https://jcenter.bintray.com", "DynamoDBLocal" at "https://s3-us-west-2.amazonaws.com/dynamodb-local/release" diff --git a/project/build.properties b/project/build.properties index c0bab0494..06703e34d 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.2.8 +sbt.version=1.3.9 diff --git a/project/plugins.sbt b/project/plugins.sbt index baacf46ff..41d3a92ca 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,9 +2,7 @@ logLevel := Level.Warn resolvers += "Flyway" at "https://flywaydb.org/repo" -resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven" - -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0") addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1") @@ -12,7 +10,7 @@ addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.0") addSbtPlugin("io.github.davidmweber" % "flyway-sbt" % "5.0.0") -addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.3.7") +addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.4.5") addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.25") @@ -22,13 +20,11 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.2") addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.8") -addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.0.0") +addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.5.0") -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.3") +addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.7.4") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.2.1") - -addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.4") addSbtPlugin("com.typesafe.sbt" % "sbt-license-report" % "1.2.0") @@ -37,5 +33,3 @@ addSbtPlugin("com.47deg" % "sbt-microsites" % "0.7.24") addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3") addSbtPlugin("io.crashbox" % "sbt-gpg" % "0.2.0") - -addSbtPlugin("io.get-coursier" % "sbt-coursier" % "2.0.0-RC4-1") diff --git a/scalastyle-config.xml b/scalastyle-config.xml deleted file mode 100644 index e1ab572bc..000000000 --- a/scalastyle-config.xml +++ /dev/null @@ -1,79 +0,0 @@ - - Circe Configuration - - - FOR - IF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - \ No newline at end of file diff --git a/scalastyle-test-config.xml b/scalastyle-test-config.xml deleted file mode 100644 index 1cad17fb2..000000000 --- a/scalastyle-test-config.xml +++ /dev/null @@ -1,81 +0,0 @@ - - Circe Configuration - - - FOR - IF - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - - - \ No newline at end of file