Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated keyId #616

Merged
merged 5 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading