diff --git a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/CredentialsController.groovy b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/CredentialsController.groovy index 1b7093b79b..a0944f3a84 100644 --- a/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/CredentialsController.groovy +++ b/gate-web/src/main/groovy/com/netflix/spinnaker/gate/controllers/CredentialsController.groovy @@ -97,11 +97,11 @@ class CredentialsController { @ApiParam(value = 'Value of the "@type" key for accounts to search for.', example = 'kubernetes') @PathVariable String accountType, @ApiParam('Maximum number of entries to return in results. Used for pagination.') - @RequestParam OptionalInt limit, + @RequestParam(required = false) Integer limit, @ApiParam('Account name to start account definition listing from. Used for pagination.') - @RequestParam Optional startingAccountName + @RequestParam(required = false) String startingAccountName ) { - clouddriverService.getAccountDefinitionsByType(accountType, limit.isPresent() ? limit.getAsInt() : null, startingAccountName.orElse(null)) + clouddriverService.getAccountDefinitionsByType(accountType, limit, startingAccountName) } @PostMapping diff --git a/gate-web/src/test/groovy/com/netflix/spinnaker/gate/controllers/CredentialsControllerSpec.groovy b/gate-web/src/test/groovy/com/netflix/spinnaker/gate/controllers/CredentialsControllerSpec.groovy index a072882437..2205bde4ff 100644 --- a/gate-web/src/test/groovy/com/netflix/spinnaker/gate/controllers/CredentialsControllerSpec.groovy +++ b/gate-web/src/test/groovy/com/netflix/spinnaker/gate/controllers/CredentialsControllerSpec.groovy @@ -58,7 +58,11 @@ class CredentialsControllerSpec extends Specification { contentNegotiationManagerFactoryBean.addMediaType("json", MediaType.APPLICATION_JSON) contentNegotiationManagerFactoryBean.favorPathExtension = false mockMvc = MockMvcBuilders - .standaloneSetup(new CredentialsController(accountLookupService: accountLookupService, allowedAccountsSupport: allowedAccountsSupport)) + .standaloneSetup(new CredentialsController( + accountLookupService: accountLookupService, + allowedAccountsSupport: allowedAccountsSupport, + clouddriverService: clouddriverService + )) .setContentNegotiationManager(contentNegotiationManagerFactoryBean.build()) .build() } @@ -78,4 +82,39 @@ class CredentialsControllerSpec extends Specification { "test" || "test" "test.com" || "test.com" } + + @Unroll + void "listing credentials by type should succeed when optional arguments are not provided"() { + when: + MockHttpServletResponse response = mockMvc.perform(get("/credentials/type/${accountType}") + .accept(MediaType.APPLICATION_JSON)).andReturn().response + + then: + response.status == 200 + 1 * clouddriverService.getAccountDefinitionsByType(accountType, _, _) + + where: + accountType | _ + "type1" | _ + "type2" | _ + } + + @Unroll + void "listing credentials by type should succeed when optional arguments are provided"() { + when: + MockHttpServletResponse response = mockMvc.perform( + get("/credentials/type/${accountType}") + .param("limit", "${limit}") + .param("startingAccountName", startingAccountName) + .accept(MediaType.APPLICATION_JSON)).andReturn().response + + then: + response.status == 200 + 1 * clouddriverService.getAccountDefinitionsByType(accountType, limit, startingAccountName) + + where: + accountType | limit | startingAccountName + "type1" | 2 | "account1" + "type2" | 500 | "account2" + } } diff --git a/gradle.properties b/gradle.properties index 43dc14a7c3..17394ffd4b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ enablePublishing=false -fiatVersion=1.42.0 +fiatVersion=1.43.0 includeProviders=basic,iap,ldap,oauth2,saml,x509 -korkVersion=7.205.0 +korkVersion=7.206.0 kotlinVersion=1.5.32 org.gradle.parallel=true spinnakerGradleVersion=8.32.1