Skip to content

Commit

Permalink
Merge branch 'release-1.29.x' into mergify/bp/release-1.29.x/pr-4469
Browse files Browse the repository at this point in the history
  • Loading branch information
link108 committed Jun 21, 2023
2 parents 9fb9c58 + 3e79820 commit aa5f180
Showing 1 changed file with 0 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1846,73 +1846,6 @@ object RunTaskHandlerTest : SubjectSpek<RunTaskHandler>({
}
}
}

describe("when a previous stage was a skipped manual judgment stage with auth propagated") {
given("a stage with a manual judgment type and auth propagated") {
val timeout = Duration.ofMinutes(5)
val lastModifiedUser = StageExecution.LastModifiedDetails()
lastModifiedUser.user = "user"
lastModifiedUser.allowedAccounts = listOf("user")

val pipeline = pipeline {
stage {
refId = "1"
type = manualJudgmentStage.type
manualJudgmentStage.plan(this)
status = SUCCEEDED
context["propagateAuthenticationContext"] = true
context["judgmentStatus"] = "continue"
lastModified = lastModifiedUser
}
}

val stageSkipped : StageExecution = stage {
refId = "2"
type = manualJudgmentStage.type
manualJudgmentStage.plan(this)
context["manualSkip"] = true
status = SKIPPED
requisiteStageRefIds = setOf("1")
}

val stageSpy = spy(stageSkipped)

val stageResult1 : com.netflix.spinnaker.orca.pipeline.util.StageNavigator.Result = mock()
whenever(stageResult1.stage) doReturn pipeline.stageByRef("1")
whenever(stageResult1.stageBuilder) doReturn manualJudgmentStage
val stageResult2 : com.netflix.spinnaker.orca.pipeline.util.StageNavigator.Result = mock()
whenever(stageResult2.stage) doReturn stageSpy
whenever(stageResult2.stageBuilder) doReturn manualJudgmentStage
pipeline.stages.add(stageSpy)

val stage = pipeline.stageByRef("2")
val message = RunTask(pipeline.type, pipeline.id, "foo", stage.id, "1", DummyTask::class.java)


beforeGroup {
tasks.forEach { whenever(it.extensionClass) doReturn it::class.java }
taskExecutionInterceptors.forEach { whenever(it.beforeTaskExecution(task, stage)) doReturn stage }
whenever(repository.retrieve(PIPELINE, message.executionId)) doReturn pipeline
whenever(task.getDynamicTimeout(any())) doReturn timeout.toMillis()
whenever(stageNavigator.ancestors(stage)) doReturn listOf(stageResult2, stageResult1)
}

afterGroup(::resetMocks)

action("the handler receives a message") {
subject.handle(message)
}

it("marks the task as skipped") {
verify(queue).push(CompleteTask(message, SKIPPED))
}

it("verify if last authenticated user was retrieved from candidate stage") {
assertEquals(stageSpy.lastModified, lastModifiedUser)
}

}
}
})

data class BackOff(
Expand Down

0 comments on commit aa5f180

Please sign in to comment.