From 11d3e485aed0c25465e6bcb75cb3839fc613cc91 Mon Sep 17 00:00:00 2001 From: Richard Treier Date: Fri, 7 Jul 2023 16:59:57 +0200 Subject: [PATCH] fix: parameterization issues due to parameterization logic in core edc --- docs/getting-started/docker-compose.yaml | 23 ++++++- fake-backend/json/contractAgreementPage.json | 4 +- package-lock.json | 8 +-- package.json | 2 +- src/app/core/services/asset-properties.ts | 14 ----- .../core/services/asset-property-mapper.ts | 8 --- .../services/http-params-mapper.service.ts | 34 +++++------ src/app/core/services/models/asset.ts | 2 - .../services/models/http-request-params.ts | 10 +--- .../asset-create-dialog.component.html | 60 ++++++++----------- ...t-agreement-transfer-dialog.component.html | 12 ++-- ...act-agreement-transfer-dialog.component.ts | 13 +--- 12 files changed, 78 insertions(+), 112 deletions(-) diff --git a/docs/getting-started/docker-compose.yaml b/docs/getting-started/docker-compose.yaml index 97a82e900..34305a563 100644 --- a/docs/getting-started/docker-compose.yaml +++ b/docs/getting-started/docker-compose.yaml @@ -12,10 +12,12 @@ services: - EDC_UI_CATALOG_URLS=http://edc:11003/api/v1/ids/data edc: image: ghcr.io/sovity/edc-dev:latest + depends_on: + - postgresql environment: MY_EDC_NAME_KEBAB_CASE: 'example-connector' MY_EDC_TITLE: 'EDC Connector' - MY_EDC_DESCRIPTION: 'Community Edition EDC Connector by sovity' + MY_EDC_DESCRIPTION: 'sovity Community Edition EDC Connector' MY_EDC_CURATOR_URL: 'https://example.com' MY_EDC_CURATOR_NAME: 'Example GmbH' MY_EDC_MAINTAINER_URL: 'https://sovity.de' @@ -27,6 +29,10 @@ services: MY_EDC_FQDN: 'edc' MY_EDC_PROTOCOL: 'http://' MY_EDC_IDS_BASE_URL: 'http://edc:11003' # adds missing port + + MY_EDC_JDBC_URL: jdbc:postgresql://postgresql:5432/edc + MY_EDC_JDBC_USER: edc + MY_EDC_JDBC_PASSWORD: edc EDC_WEB_REST_CORS_ENABLED: 'true' EDC_WEB_REST_CORS_HEADERS: 'origin,content-type,accept,authorization,x-api-key' EDC_WEB_REST_CORS_ORIGINS: '*' @@ -36,5 +42,18 @@ services: - '11003:11003' - '11004:11004' - '11005:5005' + postgresql: + image: docker.io/bitnami/postgresql:11 + restart: always + environment: + POSTGRESQL_USERNAME: edc + POSTGRESQL_PASSWORD: edc + POSTGRESQL_DATABASE: edc + ports: + - '54321:5432' volumes: - - ./secrets:/secrets + - 'postgresql:/bitnami/postgresql' + +volumes: + postgresql: + driver: local diff --git a/fake-backend/json/contractAgreementPage.json b/fake-backend/json/contractAgreementPage.json index c3315baaa..e9fe699cc 100644 --- a/fake-backend/json/contractAgreementPage.json +++ b/fake-backend/json/contractAgreementPage.json @@ -211,9 +211,7 @@ "asset:prop:datasource:http:hints:proxyMethod": "true", "asset:prop:datasource:http:hints:proxyPath": "true", "asset:prop:datasource:http:hints:proxyQueryParams": "true", - "asset:prop:datasource:http:hints:proxyBody": "true", - "asset:prop:datasource:http:hints:defaultMethod": "GET", - "asset:prop:datasource:http:hints:defaultPath": "/" + "asset:prop:datasource:http:hints:proxyBody": "true" } }, "contractPolicy": { diff --git a/package-lock.json b/package-lock.json index 3e168f152..bd4e71802 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "@ng-apimock/core": "^3.6.0", "@ngxs/store": "^3.8.1", "@sovity.de/broker-server-client": "0.20230703.152001-main-d1ec5276", - "@sovity.de/edc-client": "0.20230629.150330-main-aaa2fa41", + "@sovity.de/edc-client": "0.20230706.64046-main-d2fd35a8", "clean-deep": "^3.4.0", "date-fns": "^2.29.3", "dotenv": "^16.0.3", @@ -3443,9 +3443,9 @@ "integrity": "sha512-3azcUFMg0tLHrCqPG/vw8vIYqShLrJnAQDhtH0VyHvYyyt+waokdS6Pf0nGvL0RzWEBQZY81pFt2TvE56AS5ug==" }, "node_modules/@sovity.de/edc-client": { - "version": "0.20230629.150330-main-aaa2fa41", - "resolved": "https://registry.npmjs.org/@sovity.de/edc-client/-/edc-client-0.20230629.150330-main-aaa2fa41.tgz", - "integrity": "sha512-6oaHKaqeZUYMAylOUk4h0Dfl2WTpw86XqSuMhU3ItdXoWo0Z5Xz6HlYaEczut4v3au1o4inwkwvRkwLTRpB61w==" + "version": "0.20230706.64046-main-d2fd35a8", + "resolved": "https://registry.npmjs.org/@sovity.de/edc-client/-/edc-client-0.20230706.64046-main-d2fd35a8.tgz", + "integrity": "sha512-IfOXrR6C+EArXTX0z1XWBx57WVPszVgEmjaJGwyEiX5gh+mHtv/oU+K42rpPBTFhaBOdteK4IUx1pts8J3CoiQ==" }, "node_modules/@tootallnate/once": { "version": "2.0.0", diff --git a/package.json b/package.json index 217c85c0e..90b40e4e9 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,7 @@ "@ng-apimock/core": "^3.6.0", "@ngxs/store": "^3.8.1", "@sovity.de/broker-server-client": "0.20230703.152001-main-d1ec5276", - "@sovity.de/edc-client": "0.20230629.150330-main-aaa2fa41", + "@sovity.de/edc-client": "0.20230706.64046-main-d2fd35a8", "clean-deep": "^3.4.0", "date-fns": "^2.29.3", "dotenv": "^16.0.3", diff --git a/src/app/core/services/asset-properties.ts b/src/app/core/services/asset-properties.ts index e69c31d65..64731baaa 100644 --- a/src/app/core/services/asset-properties.ts +++ b/src/app/core/services/asset-properties.ts @@ -57,20 +57,6 @@ export const AssetProperties = { */ httpProxyBody: 'asset:prop:datasource:http:hints:proxyBody', - /** - * If this asset supports HTTP Method parameterization, this is the default method - * - * Example values: "GET", "POST", "PUT", "DELETE" - */ - httpDefaultMethod: 'asset:prop:datasource:http:hints:defaultMethod', - - /** - * If this asset supports HTTP Path parameterization, this is the default path (appended after base path) - * - * Example values: /my-endpoint - */ - httpDefaultPath: 'asset:prop:datasource:http:hints:defaultPath', - /** * @deprecated use {@link AssetProperties.curatorOrganizationName} instead */ diff --git a/src/app/core/services/asset-property-mapper.ts b/src/app/core/services/asset-property-mapper.ts index 0a68871ac..87365679d 100644 --- a/src/app/core/services/asset-property-mapper.ts +++ b/src/app/core/services/asset-property-mapper.ts @@ -88,8 +88,6 @@ export class AssetPropertyMapper { props[AssetProperties.httpProxyQueryParams], ), httpProxyBody: this._parseBoolean(props[AssetProperties.httpProxyBody]), - httpDefaultPath: props[AssetProperties.httpDefaultPath], - httpDefaultMethod: props[AssetProperties.httpDefaultMethod], additionalProperties, }; } @@ -158,12 +156,6 @@ export class AssetPropertyMapper { props[AssetProperties.httpProxyBody] = this._encodeBoolean( datasource?.httpProxyBody, ); - props[AssetProperties.httpDefaultMethod] = datasource?.httpProxyMethod - ? datasource?.httpMethod ?? null - : null; - props[AssetProperties.httpDefaultPath] = datasource?.httpProxyPath - ? datasource?.httpDefaultPath ?? null - : null; } return removeNullValues(props); diff --git a/src/app/core/services/http-params-mapper.service.ts b/src/app/core/services/http-params-mapper.service.ts index a4f388322..3d432ca58 100644 --- a/src/app/core/services/http-params-mapper.service.ts +++ b/src/app/core/services/http-params-mapper.service.ts @@ -26,12 +26,12 @@ export class HttpRequestParamsMapper { value: ContractAgreementTransferDialogFormValue, ): Record { const method = value.httpProxiedMethod?.trim() ?? ''; - const {baseUrl: pathSegments, queryParams} = this.getUrlAndQueryParams( + const {url: pathSegments, queryParams} = this.getUrlAndQueryParams( value.httpProxiedPath, value.httpProxiedQueryParams, ); - const body = value.httpProxiedBody?.trim() ?? ''; - const contentType = value.httpProxiedBodyContentType?.trim() ?? ''; + const body = value.httpProxiedBody?.trim() || null; + const contentType = value.httpProxiedBodyContentType?.trim() || null; let proxyMethod = value.showAllHttpParameterizationFields || asset.httpProxyMethod; @@ -66,7 +66,6 @@ export class HttpRequestParamsMapper { proxyQueryParams: httpRequestParams.proxyQueryParams ? 'true' : null, proxyBody: httpRequestParams.proxyBody ? 'true' : null, queryParams: httpRequestParams.queryParams, - path: httpRequestParams.defaultPath, ...Object.fromEntries( Object.entries(httpRequestParams.headers).map( ([headerName, headerValue]) => [`header:${headerName}`, headerValue], @@ -87,20 +86,18 @@ export class HttpRequestParamsMapper { let {authHeaderName, authHeaderValue, authHeaderSecretName} = this.getAuthFields(formValue); - let defaultPath: string | null = null; - if (proxyPath) { - defaultPath = formValue?.httpDefaultPath?.trim() || null; + let method = formValue?.httpMethod?.trim().toUpperCase() || null; + if (proxyMethod) { + method = null; } - let method = formValue?.httpMethod?.trim().toUpperCase() ?? ''; - let {baseUrl, queryParams} = this.getUrlAndQueryParams( + let {url: baseUrl, queryParams} = this.getUrlAndQueryParams( formValue?.httpUrl, formValue?.httpQueryParams, ); return { - baseUrl, - defaultPath, + baseUrl: baseUrl!!, method, authHeaderName, authHeaderValue, @@ -141,21 +138,24 @@ export class HttpRequestParamsMapper { rawUrl: string | null | undefined, rawQueryParams: HttpDatasourceQueryParamFormValue[] | null | undefined, ): { - baseUrl: string; - queryParams: string; + url: string | null; + queryParams: string | null; } { - let url = rawUrl?.trim() ?? ''; + let rawUrlTrimmed = rawUrl?.trim() ?? ''; - let baseUrl = everythingBefore('?', url); + let url = everythingBefore('?', rawUrlTrimmed); let queryParamSegments = (rawQueryParams ?? []).map((param) => this.encodeQueryParam(param), ); - let queryParams = [everythingAfter('?', url), ...queryParamSegments] + let queryParams = [ + everythingAfter('?', rawUrlTrimmed), + ...queryParamSegments, + ] .filter((it) => !!it) .join('&'); - return {baseUrl, queryParams}; + return {url: url || null, queryParams: queryParams || null}; } private encodeQueryParam(param: HttpDatasourceQueryParamFormValue): string { diff --git a/src/app/core/services/models/asset.ts b/src/app/core/services/models/asset.ts index fd9aa65ef..e3b131692 100644 --- a/src/app/core/services/models/asset.ts +++ b/src/app/core/services/models/asset.ts @@ -35,8 +35,6 @@ export interface Asset { httpProxyPath: boolean | null; httpProxyQueryParams: boolean | null; httpProxyBody: boolean | null; - httpDefaultPath: string | null; - httpDefaultMethod: string | null; // Unhandled Additional Properties additionalProperties: AdditionalAssetProperty[]; diff --git a/src/app/core/services/models/http-request-params.ts b/src/app/core/services/models/http-request-params.ts index f70660127..03c13a06e 100644 --- a/src/app/core/services/models/http-request-params.ts +++ b/src/app/core/services/models/http-request-params.ts @@ -4,16 +4,10 @@ export interface HttpRequestParams { */ baseUrl: string; - /** - * If proxy path is set, this - */ - - defaultPath: string | null; - /** * Http-method */ - method: string; + method: string | null; /** * Header-Name ("Authorization"), where the secrets are passed into @@ -38,7 +32,7 @@ export interface HttpRequestParams { /** * Query Parameters */ - queryParams: string; + queryParams: string | null; proxyMethod: boolean; proxyPath: boolean; proxyQueryParams: boolean; diff --git a/src/app/routes/connector-ui/asset-page/asset-create-dialog/asset-create-dialog.component.html b/src/app/routes/connector-ui/asset-page/asset-create-dialog/asset-create-dialog.component.html index 574992f4d..3d25beb08 100644 --- a/src/app/routes/connector-ui/asset-page/asset-create-dialog/asset-create-dialog.component.html +++ b/src/app/routes/connector-ui/asset-page/asset-create-dialog/asset-create-dialog.component.html @@ -198,25 +198,27 @@

Create New Asset

-
- {{ form.proxyMethod ? 'Default' : '' }} Method +
Method
+ +
+ The consuming side must provide a Custom HTTP Method with + method parameterization enabled.
- - - {{ form.proxyMethod ? 'Default' : '' }} Method - - - {{ - method - }} - - - When no method override is set, this method will be used. - - + + + + {{ form.proxyMethod ? 'Default' : '' }} Method + + + {{ + method + }} + + +
Create New Asset
URL
+
+ The consuming side must provide a Custom HTTP Subpath with + method parameterization is enabled. The Custom HTTP Subpath will + be appended to the base path. +
+ - URL - Base URL + URL + Base URL {{ validationMessages.invalidUrlMessage }} - - - - Default Path - - When no path override is set, this path will be used. - - - -
Initiate Transfer >{{ method }} - - Default: {{ data.asset.httpDefaultMethod ?? 'Unknown' }} - + Requires "proxyMethod" to be "true". @@ -257,10 +255,7 @@

Initiate Transfer

matInput [formControl]="ctrl" [placeholder]="'sub-path/endpoint'" /> - - Default: - {{ data.asset.httpDefaultPath ?? 'Unknown' }} - + Requires "proxyPath" to be "true".
@@ -281,6 +276,7 @@

Initiate Transfer

required autocomplete="new-query-param-name" [formControl]="header.controls.paramName" /> + Requires "proxyQueryParams" to be "true". @@ -323,6 +319,7 @@

Initiate Transfer

autocomplete="new-content-type" [formControl]="form.all.controls.httpProxiedBodyContentType" [placeholder]="'application/json'" /> + Requires "proxyBody" to be "true". @@ -333,6 +330,7 @@

Initiate Transfer

placeholder='{"some": "request-body"}' autocomplete="new-request-body" [formControl]="ctrl"> + Requires "proxyBody" to be "true". diff --git a/src/app/routes/connector-ui/contract-agreement-page/contract-agreement-transfer-dialog/contract-agreement-transfer-dialog.component.ts b/src/app/routes/connector-ui/contract-agreement-page/contract-agreement-transfer-dialog/contract-agreement-transfer-dialog.component.ts index ea20e0346..d75e770b4 100644 --- a/src/app/routes/connector-ui/contract-agreement-page/contract-agreement-transfer-dialog/contract-agreement-transfer-dialog.component.ts +++ b/src/app/routes/connector-ui/contract-agreement-page/contract-agreement-transfer-dialog/contract-agreement-transfer-dialog.component.ts @@ -75,18 +75,7 @@ export class ContractAgreementTransferDialogComponent implements OnDestroy { private httpRequestParamsMapper: HttpRequestParamsMapper, private dataAddressMapper: DataAddressMapper, @Inject(MAT_DIALOG_DATA) public data: ContractAgreementTransferDialogData, - ) { - if (data.asset.httpDefaultMethod) { - this.form.all.controls.httpProxiedMethod.setValue( - data.asset.httpDefaultMethod, - ); - } - if (data.asset.httpDefaultPath) { - this.form.all.controls.httpProxiedPath.setValue( - data.asset.httpDefaultPath, - ); - } - } + ) {} onSave() { if (this.loading && !this.form.all.valid) {