Skip to content

Commit

Permalink
Merge branch 'master' into gate-saml2
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmcintosh authored Dec 22, 2023
2 parents caac3db + ba6c51b commit 5700cba
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 6 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"
}
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 5700cba

Please sign in to comment.