From db11a65fbf2ba26daae6c08e25f541d295dd9691 Mon Sep 17 00:00:00 2001 From: spinnakerbot Date: Tue, 5 Dec 2023 16:36:15 -0500 Subject: [PATCH 1/3] chore(dependencies): Autobump korkVersion (#1748) Co-authored-by: root --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 43dc14a7c3..a06c5e954c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ enablePublishing=false fiatVersion=1.42.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 From e01e687df7e3bc755193d8bbf423adb15a044194 Mon Sep 17 00:00:00 2001 From: spinnakerbot Date: Tue, 12 Dec 2023 04:59:18 -0500 Subject: [PATCH 2/3] chore(dependencies): Autobump fiatVersion (#1749) Co-authored-by: root --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index a06c5e954c..17394ffd4b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ enablePublishing=false -fiatVersion=1.42.0 +fiatVersion=1.43.0 includeProviders=basic,iap,ldap,oauth2,saml,x509 korkVersion=7.206.0 kotlinVersion=1.5.32 From ba6c51bdcebc24a0cff975bcbdf98c1f7751bd5d Mon Sep 17 00:00:00 2001 From: dzhengg <53837320+dzhengg@users.noreply.github.com> Date: Thu, 14 Dec 2023 11:25:56 -0800 Subject: [PATCH 3/3] fix(requests): Properly handle optional request parameters (#1750) * test(web): Define the behavior of the /type/{accountType} endpoint * fix(request): Properly declare optional request parameters Optional is not the right way to declare that a particular request parameter is not required. There was a similar issue in the corresponding clouddriver endpoint that was fixed by https://github.com/spinnaker/clouddriver/pull/6067 --------- Co-authored-by: Daniel Zheng --- .../controllers/CredentialsController.groovy | 6 +-- .../CredentialsControllerSpec.groovy | 41 ++++++++++++++++++- 2 files changed, 43 insertions(+), 4 deletions(-) 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" + } }