Skip to content

Commit

Permalink
Merge branch 'master' into cdevents_artifacts_params
Browse files Browse the repository at this point in the history
  • Loading branch information
rjalander authored Dec 15, 2023
2 parents 9548559 + ba6c51b commit bd17c88
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> startingAccountName
@RequestParam(required = false) String startingAccountName
) {
clouddriverService.getAccountDefinitionsByType(accountType, limit.isPresent() ? limit.getAsInt() : null, startingAccountName.orElse(null))
clouddriverService.getAccountDefinitionsByType(accountType, limit, startingAccountName)
}

@PostMapping
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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"
}
}

0 comments on commit bd17c88

Please sign in to comment.