Skip to content

Commit

Permalink
Remove deprecated keyId (#616)
Browse files Browse the repository at this point in the history

Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
  • Loading branch information
pditommaso authored Oct 1, 2024
1 parent 884274d commit 64e5500
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ class TowerClient {
if (!pairingId)
throw new IllegalArgumentException("Missing encryptionKey argument")

// keep `keyId` only for backward compatibility
// it should be removed in a following version in favour of `pairingId`
def uri = "${checkEndpoint(towerEndpoint)}/credentials/$credentialsId/keys?pairingId=$pairingId&keyId=$pairingId"
def uri = "${checkEndpoint(towerEndpoint)}/credentials/$credentialsId/keys?pairingId=$pairingId"
if( workspaceId!=null )
uri += "&workspaceId=$workspaceId"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ class TowerClientHttpTest extends Specification{
}

@Get('/credentials/{credentialsId}/keys')
HttpResponse<GetCredentialsKeysResponse> getCredentialsKeys(@Header('Authorization')String authorization, String credentialsId, @QueryValue String keyId) {
HttpResponse<GetCredentialsKeysResponse> getCredentialsKeys(@Header('Authorization')String authorization, String credentialsId, @QueryValue String pairingId) {
if (authorization == 'Bearer foo') {
return HttpResponse.unauthorized()
}
if (authorization == 'Bearer refresh') {
return HttpResponse.unauthorized()
}
if (credentialsId == '1' && keyId == '1') {
if (credentialsId == '1' && pairingId == '1') {
return HttpResponse.ok(new GetCredentialsKeysResponse(keys: 'keys'))
} else {
throw new NotFoundException("Unable to find credentials with id: 1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ class TowerClientUrlCompositionTest extends Specification{
where:

endpoint | credsId | keyId | workspaceId || expected
'http://tower:8080' | '0' | '0' | null || 'http://tower:8080/credentials/0/keys?pairingId=0&keyId=0'
'http://tower:8080' | '1' | '1' | 100 || 'http://tower:8080/credentials/1/keys?pairingId=1&keyId=1&workspaceId=100'
'http://tower:8080/' | '1' | '2' | null || 'http://tower:8080/credentials/1/keys?pairingId=2&keyId=2'
'http://tower:8080/' | '1' | '3' | 100 || 'http://tower:8080/credentials/1/keys?pairingId=3&keyId=3&workspaceId=100'
'http://tower:8080/api' | '1' | '4' | null || 'http://tower:8080/api/credentials/1/keys?pairingId=4&keyId=4'
'http://tower:8080/api' | '1' | '5' | 100 || 'http://tower:8080/api/credentials/1/keys?pairingId=5&keyId=5&workspaceId=100'
'http://tower:8080/api/' | '1' | '6' | null || 'http://tower:8080/api/credentials/1/keys?pairingId=6&keyId=6'
'http://tower:8080/api/' | '1' | '7' | 0 || 'http://tower:8080/api/credentials/1/keys?pairingId=7&keyId=7&workspaceId=0'
'http://tower:8080' | '0' | '0' | null || 'http://tower:8080/credentials/0/keys?pairingId=0'
'http://tower:8080' | '1' | '1' | 100 || 'http://tower:8080/credentials/1/keys?pairingId=1&workspaceId=100'
'http://tower:8080/' | '1' | '2' | null || 'http://tower:8080/credentials/1/keys?pairingId=2'
'http://tower:8080/' | '1' | '3' | 100 || 'http://tower:8080/credentials/1/keys?pairingId=3&workspaceId=100'
'http://tower:8080/api' | '1' | '4' | null || 'http://tower:8080/api/credentials/1/keys?pairingId=4'
'http://tower:8080/api' | '1' | '5' | 100 || 'http://tower:8080/api/credentials/1/keys?pairingId=5&workspaceId=100'
'http://tower:8080/api/' | '1' | '6' | null || 'http://tower:8080/api/credentials/1/keys?pairingId=6'
'http://tower:8080/api/' | '1' | '7' | 0 || 'http://tower:8080/api/credentials/1/keys?pairingId=7&workspaceId=0'
}

def 'fail compose fetch credentials endpoint with invalid towerEndpoint or missing data'() {
Expand Down

0 comments on commit 64e5500

Please sign in to comment.