From 71c7a7ae99bcbfa931f8ee91a43881f35a245117 Mon Sep 17 00:00:00 2001 From: kirangodishala Date: Fri, 21 Feb 2025 03:59:46 +0530 Subject: [PATCH] fix(retrofit2): fix the missing calls related to retrofit2 and align the tests accordingly --- .../gate/security/oauth2/SpinnakerUserInfoTokenServices.groovy | 3 ++- .../security/oauth2/SpinnakerUserInfoTokenServicesSpec.groovy | 2 +- .../spinnaker/gate/controllers/PipelineController.groovy | 2 +- .../spinnaker/gate/controllers/PipelineControllerSpec.groovy | 3 +-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gate-oauth2/src/main/groovy/com/netflix/spinnaker/gate/security/oauth2/SpinnakerUserInfoTokenServices.groovy b/gate-oauth2/src/main/groovy/com/netflix/spinnaker/gate/security/oauth2/SpinnakerUserInfoTokenServices.groovy index 21713ad99f..19df4ede1a 100644 --- a/gate-oauth2/src/main/groovy/com/netflix/spinnaker/gate/security/oauth2/SpinnakerUserInfoTokenServices.groovy +++ b/gate-oauth2/src/main/groovy/com/netflix/spinnaker/gate/security/oauth2/SpinnakerUserInfoTokenServices.groovy @@ -24,6 +24,7 @@ import com.netflix.spinnaker.gate.services.CredentialsService import com.netflix.spinnaker.gate.services.PermissionService import com.netflix.spinnaker.gate.services.internal.Front50Service import com.netflix.spinnaker.kork.core.RetrySupport +import com.netflix.spinnaker.kork.retrofit.Retrofit2SyncCall import com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerServerException import com.netflix.spinnaker.security.User import groovy.json.JsonSlurper @@ -186,7 +187,7 @@ class SpinnakerUserInfoTokenServices implements ResourceServerTokenServices { return false } try { - def serviceAccounts = front50Service.getServiceAccounts() + def serviceAccounts = Retrofit2SyncCall.execute(front50Service.getServiceAccounts()) return serviceAccounts.find { email.equalsIgnoreCase(it.name) } } catch (SpinnakerServerException e) { log.warn("Could not get list of service accounts.", e) diff --git a/gate-oauth2/src/test/groovy/com/netflix/spinnaker/gate/security/oauth2/SpinnakerUserInfoTokenServicesSpec.groovy b/gate-oauth2/src/test/groovy/com/netflix/spinnaker/gate/security/oauth2/SpinnakerUserInfoTokenServicesSpec.groovy index 1915949d0e..ca564cbbf1 100644 --- a/gate-oauth2/src/test/groovy/com/netflix/spinnaker/gate/security/oauth2/SpinnakerUserInfoTokenServicesSpec.groovy +++ b/gate-oauth2/src/test/groovy/com/netflix/spinnaker/gate/security/oauth2/SpinnakerUserInfoTokenServicesSpec.groovy @@ -128,6 +128,6 @@ class SpinnakerUserInfoTokenServicesSpec extends Specification { def isServiceAccount = tokenServices.isServiceAccount(details) then: - thrown(MissingPropertyException) // TODO: fix the bug in isServiceAccount() where front50Service.getServiceAccounts() is not surrounded by Retrofit2SyncCall.execute() + isServiceAccount } } diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/PipelineController.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/PipelineController.groovy index ddea46e990..391cbfb175 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/PipelineController.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/PipelineController.groovy @@ -75,7 +75,7 @@ class PipelineController { @Operation(summary = "Delete a pipeline definition") @DeleteMapping("/{application}/{pipelineName:.+}") void deletePipeline(@PathVariable String application, @PathVariable String pipelineName) { - List pipelineConfigs = front50Service.getPipelineConfigsForApplication(application, null, true) + List pipelineConfigs = Retrofit2SyncCall.execute(front50Service.getPipelineConfigsForApplication(application, null, true)) if (pipelineConfigs!=null && !pipelineConfigs.isEmpty()){ Optional filterResult = pipelineConfigs.stream().filter({ pipeline -> ((String) pipeline.get("name")) != null && ((String) pipeline.get("name")).trim().equalsIgnoreCase(pipelineName) }).findFirst() if (filterResult.isPresent()){ diff --git a/gate-web/src/test/groovy/com/netflix/spinnaker/gate/controllers/PipelineControllerSpec.groovy b/gate-web/src/test/groovy/com/netflix/spinnaker/gate/controllers/PipelineControllerSpec.groovy index 5e07772894..9fe8c23e6c 100644 --- a/gate-web/src/test/groovy/com/netflix/spinnaker/gate/controllers/PipelineControllerSpec.groovy +++ b/gate-web/src/test/groovy/com/netflix/spinnaker/gate/controllers/PipelineControllerSpec.groovy @@ -26,7 +26,6 @@ import groovy.json.JsonSlurper import okhttp3.ResponseBody import org.springframework.http.MediaType import org.springframework.test.web.servlet.setup.MockMvcBuilders -import org.springframework.web.util.NestedServletException import retrofit2.Retrofit import retrofit2.converter.jackson.JacksonConverterFactory import retrofit2.mock.Calls; @@ -118,7 +117,7 @@ class PipelineControllerSpec extends Specification { ).andReturn().response then: - thrown(NestedServletException) // TODO: fix the bug in the controller where front50Service.getPipelineConfigsForApplication() is not surrounded by Retrofit2SyncCall.execute() + notThrown(Exception) } def "should propagate pipeline template errors"() {