From fcd693f3953673de94590e39a0ce78786532c3fd Mon Sep 17 00:00:00 2001 From: Christian Freitas Date: Mon, 5 Dec 2022 11:36:17 -0500 Subject: [PATCH 1/5] WX-842 Add Pact Dependency for Cromwell --- .../blob/BlobFileSystemContractSpec.scala | 20 +++++++++++++++++++ project/Dependencies.scala | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 filesystems/blob/src/test/scala/cromwell/filesystems/blob/BlobFileSystemContractSpec.scala diff --git a/filesystems/blob/src/test/scala/cromwell/filesystems/blob/BlobFileSystemContractSpec.scala b/filesystems/blob/src/test/scala/cromwell/filesystems/blob/BlobFileSystemContractSpec.scala new file mode 100644 index 00000000000..5b6640dd12a --- /dev/null +++ b/filesystems/blob/src/test/scala/cromwell/filesystems/blob/BlobFileSystemContractSpec.scala @@ -0,0 +1,20 @@ +package cromwell.filesystems.blob + +import au.com.dius.pact.consumer.PactTestExecutionContext +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers + +import pact4s.scalatest.RequestResponsePactForger +import au.com.dius.pact.core.model.RequestResponsePact + +class BlobFileSystemContractSpec extends AnyFlatSpec with Matchers with RequestResponsePactForger { + + override def pact: RequestResponsePact = ??? + + /* + we can define the folder that the pact contracts get written to upon completion of this test suite. + */ + override val pactTestExecutionContext: PactTestExecutionContext = new PactTestExecutionContext( + "./example/resources/pacts" + ) +} diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 42e6ee7bf79..ddc3b002f00 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -595,7 +595,9 @@ object Dependencies { "org.scalatest" %% "scalatest" % scalatestV, // Use mockito Java DSL directly instead of the numerous and often hard to keep updated Scala DSLs. // See also scaladoc in common.mock.MockSugar and that trait's various usages. - "org.mockito" % "mockito-core" % mockitoV + "org.mockito" % "mockito-core" % mockitoV, + "io.github.jbwheatley" %% "pact4s-scalatest" % "0.7.0", + "io.github.jbwheatley" %% "pact4s-circe" % "0.7.0" ) ++ slf4jBindingDependencies // During testing, add an slf4j binding for _all_ libraries. val kindProjectorPlugin = "org.typelevel" % "kind-projector" % kindProjectorV cross CrossVersion.full From d8d85a9c102dee35a297c92928b972d2598a7f27 Mon Sep 17 00:00:00 2001 From: Christian Freitas Date: Mon, 5 Dec 2022 16:04:45 -0500 Subject: [PATCH 2/5] Remove incomplete test spec --- .../blob/BlobFileSystemContractSpec.scala | 20 ------------------- 1 file changed, 20 deletions(-) delete mode 100644 filesystems/blob/src/test/scala/cromwell/filesystems/blob/BlobFileSystemContractSpec.scala diff --git a/filesystems/blob/src/test/scala/cromwell/filesystems/blob/BlobFileSystemContractSpec.scala b/filesystems/blob/src/test/scala/cromwell/filesystems/blob/BlobFileSystemContractSpec.scala deleted file mode 100644 index 5b6640dd12a..00000000000 --- a/filesystems/blob/src/test/scala/cromwell/filesystems/blob/BlobFileSystemContractSpec.scala +++ /dev/null @@ -1,20 +0,0 @@ -package cromwell.filesystems.blob - -import au.com.dius.pact.consumer.PactTestExecutionContext -import org.scalatest.flatspec.AnyFlatSpec -import org.scalatest.matchers.should.Matchers - -import pact4s.scalatest.RequestResponsePactForger -import au.com.dius.pact.core.model.RequestResponsePact - -class BlobFileSystemContractSpec extends AnyFlatSpec with Matchers with RequestResponsePactForger { - - override def pact: RequestResponsePact = ??? - - /* - we can define the folder that the pact contracts get written to upon completion of this test suite. - */ - override val pactTestExecutionContext: PactTestExecutionContext = new PactTestExecutionContext( - "./example/resources/pacts" - ) -} From f7d8db3f1732099768b7b9ab95f4c129f14de814 Mon Sep 17 00:00:00 2001 From: Christian Freitas Date: Tue, 6 Dec 2022 16:00:19 -0500 Subject: [PATCH 3/5] Initial Pact Test --- .../blob/BlobFileSystemContractSpec.scala | 42 +++++++++++++++++++ .../Repo template_ CromIAM.run.xml | 1 + 2 files changed, 43 insertions(+) create mode 100644 filesystems/blob/src/test/scala/cromwell/filesystems/blob/BlobFileSystemContractSpec.scala diff --git a/filesystems/blob/src/test/scala/cromwell/filesystems/blob/BlobFileSystemContractSpec.scala b/filesystems/blob/src/test/scala/cromwell/filesystems/blob/BlobFileSystemContractSpec.scala new file mode 100644 index 00000000000..60ca573f55f --- /dev/null +++ b/filesystems/blob/src/test/scala/cromwell/filesystems/blob/BlobFileSystemContractSpec.scala @@ -0,0 +1,42 @@ +package cromwell.filesystems.blob + +import au.com.dius.pact.consumer.PactTestExecutionContext +import org.scalatest.flatspec.AnyFlatSpec +import org.scalatest.matchers.should.Matchers + +import pact4s.scalatest.RequestResponsePactForger +import au.com.dius.pact.core.model.RequestResponsePact +import au.com.dius.pact.consumer.ConsumerPactBuilder +import io.circe.Json + +class BlobFileSystemContractSpec extends AnyFlatSpec with Matchers with RequestResponsePactForger { + + /** + * we can define the folder that the pact contracts get written to upon completion of this test suite. + */ + override val pactTestExecutionContext: PactTestExecutionContext = new PactTestExecutionContext( + "./filesystems/blob/target/pacts" + ) + + override def pact: RequestResponsePact = ConsumerPactBuilder + .consumer("cromwell-blob-filesystem-consumer") + .hasPactWith("wsm-provider") + .`given`( + "resource exists", + Map("id" -> resourceId, "value" -> 123) // we can use parameters to specify details about the provider state + ) + .`given`( + "workspace exists", + Map("id" -> workspaceId, "value" -> 123) // we can use parameters to specify details about the provider state + ) + .uponReceiving("Request to fetch SAS Token") + .method("POST") + .path(s"/api/workspaces/v1/${workspaceId}/resources/controlled/azure/storageContainer/${resourceId}/getSasToken") + .headers("Authorization" -> AzureCredentials.getAccessToken()) + .willRespondWith() + .status(200) + .body( + Json.obj("id" -> testID.asJson, "value" -> 123.asJson) + ) + +} diff --git a/runConfigurations/Repo template_ CromIAM.run.xml b/runConfigurations/Repo template_ CromIAM.run.xml index 420ee26cae1..60e5f4e3aee 100644 --- a/runConfigurations/Repo template_ CromIAM.run.xml +++ b/runConfigurations/Repo template_ CromIAM.run.xml @@ -5,6 +5,7 @@