From a8810986e6091a240de02fc80f40e5d816ce2bee Mon Sep 17 00:00:00 2001 From: Bria Morgan Date: Thu, 19 Oct 2023 08:53:55 -0400 Subject: [PATCH] AJ-1369 verify pet token pact (#1205) * pet token pact * Fix webhook logic. --------- Co-authored-by: Ivan Co-authored-by: ichengchang <50877414+ichengchang@users.noreply.github.com> --- .github/workflows/verify_consumer_pacts.yml | 8 ++++---- .../workbench/sam/provider/SamProviderSpec.scala | 12 +++++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/verify_consumer_pacts.yml b/.github/workflows/verify_consumer_pacts.yml index 70edaf3a1..663b1afb8 100644 --- a/.github/workflows/verify_consumer_pacts.yml +++ b/.github/workflows/verify_consumer_pacts.yml @@ -139,16 +139,16 @@ jobs: fi git fetch if [[ ! -z "${{ env.CHECKOUT_BRANCH }}" ]] && [[ ! -z "${{ env.CHECKOUT_SHA }}" ]]; then - echo "git checkout ${{ env.CHECKOUT_BRANCH }} ${{ env.CHECKOUT_SHA }}" - git checkout ${{ env.CHECKOUT_BRANCH }} ${{ env.CHECKOUT_SHA }} + echo "git checkout -b ${{ env.CHECKOUT_BRANCH }} ${{ env.CHECKOUT_SHA }}" + git checkout -b ${{ env.CHECKOUT_BRANCH }} ${{ env.CHECKOUT_SHA }} || echo "already in ${{ env.CHECKOUT_BRANCH }}" echo "git branch" git branch else - if [[ "${{ github.event_name }}" == "push" ]]; then + if [[ "${{ github.event_name }}" == "push" ]] || [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then echo "git checkout ${{ env.CURRENT_BRANCH }}" git checkout ${{ env.CURRENT_BRANCH }} else - echo "git checkout ${{ env.CURRENT_BRANCH }} ${{ env.CURRENT_SHA }}" + echo "git checkout -b ${{ env.CURRENT_BRANCH }} ${{ env.CURRENT_SHA }}" git checkout -b ${{ env.CURRENT_BRANCH }} ${{ env.CURRENT_SHA }} fi fi diff --git a/pact4s/src/test/scala/org/broadinstitute/dsde/workbench/sam/provider/SamProviderSpec.scala b/pact4s/src/test/scala/org/broadinstitute/dsde/workbench/sam/provider/SamProviderSpec.scala index e6af93b82..52fd70079 100644 --- a/pact4s/src/test/scala/org/broadinstitute/dsde/workbench/sam/provider/SamProviderSpec.scala +++ b/pact4s/src/test/scala/org/broadinstitute/dsde/workbench/sam/provider/SamProviderSpec.scala @@ -129,6 +129,16 @@ class SamProviderSpec }) } yield () + private def mockGetArbitraryPetServiceAccountToken(): IO[Unit] = for { + _ <- IO( + when { + googleExt.getArbitraryPetServiceAccountToken(any[SamUser], any[Set[String]], any[SamRequestContext]) + } thenReturn { + Future.successful("aToken") + } + ) + } yield () + private def mockResourceActionPermission(action: ResourceAction, hasPermission: Boolean): IO[Unit] = for { _ <- IO( lenient() @@ -142,7 +152,7 @@ class SamProviderSpec private val providerStatesHandler: StateManagementFunction = StateManagementFunction { case ProviderState(States.UserExists, _) => - logger.debug(States.UserExists) + mockGetArbitraryPetServiceAccountToken().unsafeRunSync() case ProviderState(States.SamOK, _) => mockCriticalSubsystemsStatus(true).unsafeRunSync() case ProviderState(States.SamNotOK, _) =>