Skip to content

Commit

Permalink
fix(retrofit2): fix the missing calls related to retrofit2 and align …
Browse files Browse the repository at this point in the history
…the tests accordingly
  • Loading branch information
kirangodishala committed Feb 21, 2025
1 parent e1da03e commit 71c7a7a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class PipelineController {
@Operation(summary = "Delete a pipeline definition")
@DeleteMapping("/{application}/{pipelineName:.+}")
void deletePipeline(@PathVariable String application, @PathVariable String pipelineName) {
List<Map> pipelineConfigs = front50Service.getPipelineConfigsForApplication(application, null, true)
List<Map> pipelineConfigs = Retrofit2SyncCall.execute(front50Service.getPipelineConfigsForApplication(application, null, true))
if (pipelineConfigs!=null && !pipelineConfigs.isEmpty()){
Optional<Map> filterResult = pipelineConfigs.stream().filter({ pipeline -> ((String) pipeline.get("name")) != null && ((String) pipeline.get("name")).trim().equalsIgnoreCase(pipelineName) }).findFirst()
if (filterResult.isPresent()){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"() {
Expand Down

0 comments on commit 71c7a7a

Please sign in to comment.