Skip to content
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
49 changes: 49 additions & 0 deletions openapi/openapi-component_catalog-v1.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,55 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/RestErrorMessage'
delete:
tags:
- Project-components
summary: Delete the parameters of a project component given both its project key and component ID in the Bitbucket repository.
description: >
Deletes the parameters of a project component given both its project key and component ID in the Bitbucket repository.
operationId: deleteProjectComponentParameters
parameters:
- name: projectKey
in: path
description: project key.
required: true
schema:
type: string
- name: componentId
in: path
description: component ID.
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
type: array
items:
type: string
responses:
"204":
description: Parameters deleted from the project component.
"401":
description: Invalid client token on the request.
content:
application/json:
schema:
$ref: '#/components/schemas/RestErrorMessage'
"403":
description: Insufficient permissions for the client to access the resource.
content:
application/json:
schema:
$ref: '#/components/schemas/RestErrorMessage'
"500":
description: Server error.
content:
application/json:
schema:
$ref: '#/components/schemas/RestErrorMessage'

/catalog-descriptors:
get:
Expand Down
49 changes: 49 additions & 0 deletions openapi/openapi-component_provisioner-v1.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,55 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/RestErrorMessage'
delete:
tags:
- Project-components
summary: Delete the parameters of a project component given both its project key and component ID in the Bitbucket repository.
description: >
Deletes the parameters of a project component given both its project key and component ID in the Bitbucket repository.
operationId: deleteProjectComponentParameters
parameters:
- name: projectKey
in: path
description: project key.
required: true
schema:
type: string
- name: componentId
in: path
description: component ID.
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
type: array
items:
type: string
responses:
"204":
description: Parameters deleted from the project component.
"401":
description: Invalid client token on the request.
content:
application/json:
schema:
$ref: '#/components/schemas/RestErrorMessage'
"403":
description: Insufficient permissions for the client to access the resource.
content:
application/json:
schema:
$ref: '#/components/schemas/RestErrorMessage'
"500":
description: Server error.
content:
application/json:
schema:
$ref: '#/components/schemas/RestErrorMessage'

components:
securitySchemes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,13 @@ public ResponseEntity<Void> updateProjectComponentParameters(String projectKey,

return ResponseEntity.status(HttpStatus.CREATED).build();
}

@Override
public ResponseEntity<Void> deleteProjectComponentParameters(String projectKey, String componentId, List<String> requestBody) {
log.debug("deleteProjectComponentParameters called with projectKey: {}, componentId: {}, requestBody: {}", projectKey, componentId, requestBody);

projectComponentsApiFacade.deleteProjectComponentParameters(projectKey, componentId, requestBody);

return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,10 @@ public void updateProjectComponentParameters(String projectKey, String component

componentCatalogService.updateProjectComponentParameters(accessToken, projectKey, componentId, requestBody);
}

public void deleteProjectComponentParameters(String projectKey, String componentId, List<String> requestBody) {
var accessToken = authenticationProvider.getAccessToken();

componentCatalogService.deleteProjectComponentParameters(accessToken, projectKey, componentId, requestBody);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,11 @@ public void updateProjectComponentParameters(String accessToken, String projectK

componentsApi.updateProjectComponentParameters(projectKey, componentId, requestBody);
}

public void deleteProjectComponentParameters(String accessToken, String projectKey, String componentId, List<String> requestBody) {
var apiClient = apiClientsBuilder.componentCatalogApiClient(accessToken, componentCatalogServiceProps.getBaseRestUrl().toString());
var componentsApi = apiClientsBuilder.projectComponentsApi(apiClient);

componentsApi.deleteProjectComponentParameters(projectKey, componentId, requestBody);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -54,4 +55,35 @@ void givenNullRequestBody_whenUpdateProjectComponentParameters_thenDelegatesNull
assertThat(result.getBody()).isNull();
verify(projectComponentsApiFacade).updateProjectComponentParameters(projectKey, componentId, null);
}

@Test
void givenProjectKeyComponentIdAndParameterNames_whenDeleteProjectComponentParameters_thenDelegatesAndReturnsNoContent() {
// given
var projectKey = "TEST";
var componentId = "comp-123";
List<String> requestBody = Arrays.asList("param1", "param2");

// when
ResponseEntity<Void> result = controller.deleteProjectComponentParameters(projectKey, componentId, requestBody);

// then
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
assertThat(result.getBody()).isNull();
verify(projectComponentsApiFacade).deleteProjectComponentParameters(projectKey, componentId, requestBody);
}

@Test
void givenNullRequestBodyForDelete_whenDeleteProjectComponentParameters_thenDelegatesNullBody() {
// given
var projectKey = "TEST";
var componentId = "comp-123";

// when
ResponseEntity<Void> result = controller.deleteProjectComponentParameters(projectKey, componentId, null);

// then
assertThat(result.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
assertThat(result.getBody()).isNull();
verify(projectComponentsApiFacade).deleteProjectComponentParameters(projectKey, componentId, null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,22 @@ void givenProjectKeyComponentIdAndParameters_whenUpdateProjectComponentParameter
verify(componentCatalogService).updateProjectComponentParameters(accessToken, projectKey, componentId, requestBody);
}

@Test
void givenProjectKeyComponentIdAndParameterNames_whenDeleteProjectComponentParameters_thenDelegatesToComponentCatalogService() {
// given
var projectKey = "test-project";
var componentId = "test-component-id";
var accessToken = "test-token";
List<String> requestBody = List.of("param1", "param2");

when(authenticationProvider.getAccessToken()).thenReturn(accessToken);

// when
projectComponentsApiFacade.deleteProjectComponentParameters(projectKey, componentId, requestBody);

// then
verify(authenticationProvider).getAccessToken();
verify(componentCatalogService).deleteProjectComponentParameters(accessToken, projectKey, componentId, requestBody);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,36 @@ void givenRestClientException_whenGetPaginatedComponents_thenExceptionPropagates
).isInstanceOf(RestClientException.class);
}

@Test
void givenProjectKeyComponentIdAndParameterNames_whenDeleteProjectComponentParameters_thenInvokesProjectComponentsApi() throws Exception {
// given
var accessToken = "token";
var projectKey = "PRJ";
var componentId = "CID";
List<String> requestBody = List.of("param1", "param2");

URL baseUrl = URI.create("http://component-catalog").toURL();

when(componentCatalogServiceProps.getBaseRestUrl()).thenReturn(baseUrl);
when(apiClientsBuilder.componentCatalogApiClient(accessToken, baseUrl.toString()))
.thenReturn(componentCatalogApiClient);
when(apiClientsBuilder.projectComponentsApi(componentCatalogApiClient))
.thenReturn(projectComponentsApi);

// when
componentCatalogService.deleteProjectComponentParameters(accessToken, projectKey, componentId, requestBody);

// then
verify(apiClientsBuilder)
.componentCatalogApiClient(accessToken, baseUrl.toString());
verify(apiClientsBuilder)
.projectComponentsApi(componentCatalogApiClient);
verify(projectComponentsApi)
.deleteProjectComponentParameters(projectKey, componentId, requestBody);

verifyNoMoreInteractions(projectComponentsApi);
}



}
Loading