diff --git a/CHANGELOG.md b/CHANGELOG.md index 09e0442c2..ee5cfc851 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ please see [changelog_updates.md](docs/dev/changelog_updates.md). #### Patch Changes - Improve database performance by removing duplicate indexes +- The data address is now correctly updated when editing an asset. ### Deployment Migration Notes diff --git a/docs/api/sovity-edc-api-wrapper.yaml b/docs/api/sovity-edc-api-wrapper.yaml index 638cf6556..ef2167e31 100644 --- a/docs/api/sovity-edc-api-wrapper.yaml +++ b/docs/api/sovity-edc-api-wrapper.yaml @@ -603,11 +603,11 @@ components: DataSourceType: type: string description: Supported Data Source Types by UiDataSource - default: CUSTOM enum: - HTTP_DATA - ON_REQUEST - CUSTOM + default: CUSTOM SecretValue: type: object properties: @@ -815,7 +815,6 @@ components: UiDataSourceHttpDataMethod: type: string description: Supported HTTP Methods by UiDataSource - default: GET enum: - GET - POST @@ -823,6 +822,7 @@ components: - PATCH - DELETE - OPTIONS + default: GET UiDataSourceOnRequest: required: - contactEmail diff --git a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/asset/AssetApiService.java b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/asset/AssetApiService.java index d4ba7ea02..d2266f393 100644 --- a/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/asset/AssetApiService.java +++ b/extensions/wrapper/wrapper/src/main/java/de/sovity/edc/ext/wrapper/api/ui/pages/asset/AssetApiService.java @@ -62,6 +62,7 @@ public IdResponseDto editAsset(String assetId, UiAssetEditRequest request) { Objects.requireNonNull(foundAsset, "Asset with ID %s not found".formatted(assetId)); val editedAsset = assetMapper.editAsset(foundAsset, request); val updatedAsset = assetService.update(editedAsset).orElseThrow(ServiceException::new); + assetService.update(editedAsset.getId(), editedAsset.getDataAddress()); return new IdResponseDto(updatedAsset.getId()); } diff --git a/tests/src/test/java/de/sovity/edc/e2e/UiApiWrapperTest.java b/tests/src/test/java/de/sovity/edc/e2e/UiApiWrapperTest.java index 0e833b35b..19dd2cbc1 100644 --- a/tests/src/test/java/de/sovity/edc/e2e/UiApiWrapperTest.java +++ b/tests/src/test/java/de/sovity/edc/e2e/UiApiWrapperTest.java @@ -18,6 +18,7 @@ import de.sovity.edc.client.gen.model.ContractDefinitionRequest; import de.sovity.edc.client.gen.model.ContractNegotiationRequest; import de.sovity.edc.client.gen.model.ContractNegotiationSimplifiedState; +import de.sovity.edc.client.gen.model.DataSourceAvailability; import de.sovity.edc.client.gen.model.DataSourceType; import de.sovity.edc.client.gen.model.InitiateCustomTransferRequest; import de.sovity.edc.client.gen.model.InitiateTransferRequest; @@ -35,6 +36,8 @@ import de.sovity.edc.client.gen.model.UiDataOffer; import de.sovity.edc.client.gen.model.UiDataSource; import de.sovity.edc.client.gen.model.UiDataSourceHttpData; +import de.sovity.edc.client.gen.model.UiDataSourceHttpDataMethod; +import de.sovity.edc.client.gen.model.UiDataSourceOnRequest; import de.sovity.edc.client.gen.model.UiPolicyConstraint; import de.sovity.edc.client.gen.model.UiPolicyExpression; import de.sovity.edc.client.gen.model.UiPolicyExpressionType; @@ -591,6 +594,7 @@ void checkIdAvailability(E2eScenario scenario, @Provider EdcClient providerClien assertThat(posContractDefinitionResponse.getAvailable()).isTrue(); } + @DisabledOnGithub @Test void retrieveSingleContractAgreement( E2eScenario scenario, @@ -632,6 +636,46 @@ void retrieveSingleContractAgreement( .isEqualTo(alternativePolicy.getPolicyJsonLd()); } + @Test + void canMakeAnOnDemandDataSourceAvailable( + E2eScenario scenario, + @Provider EdcClient providerClient + ) { + // arrange + val assetId = scenario.createAsset(UiAssetCreateRequest.builder() + .dataSource(UiDataSource.builder() + .type(DataSourceType.ON_REQUEST) + .onRequest(UiDataSourceOnRequest.builder() + .contactEmail("whatever@example.com") + .contactPreferredEmailSubject("Subject") + .build()) + .build()) + .id("asset") + .title("foo") + .build()); + + // act + + providerClient.uiApi().editAsset(assetId, UiAssetEditRequest.builder() + .dataSourceOverrideOrNull(UiDataSource.builder() + .type(DataSourceType.HTTP_DATA) + .httpData(UiDataSourceHttpData.builder() + .method(UiDataSourceHttpDataMethod.GET) + .baseUrl("http://example.com/baseUrl") + .build()) + .build()) + .build()); + + val asset = + providerClient.uiApi().getAssetPage().getAssets().stream().filter(it -> it.getAssetId().equals(assetId)).findFirst().get(); + + // assert + assertThat(asset.getDataSourceAvailability()).isEqualTo(DataSourceAvailability.LIVE); + assertThatJson(asset.getAssetJsonLd()) + .inPath("$.[\"https://w3id.org/edc/v0.0.1/ns/dataAddress\"][\"https://w3id.org/edc/v0.0.1/ns/baseUrl\"]") + .isEqualTo("\"http://example.com/baseUrl\""); + } + private UiContractNegotiation negotiate( EdcClient consumerClient, ConnectorRemote consumerConnector,