Skip to content

Commit 714af93

Browse files
committed
Merge branch 'PIN-6663_update-client-model' of https://github.com/pagopa/interop-be-monorepo into PIN-6663_update-client-model
2 parents efd8e92 + c355f21 commit 714af93

File tree

56 files changed

+2461
-890
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2461
-890
lines changed

.github/workflows/pr.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
9797
find_dockerfiles:
9898
name: Find Dockerfiles
9999
needs: [formatting, lint, check, test]
100-
if: ${{ github.base_ref == 'develop' || github.base_ref == 'main' }}
100+
if: ${{ github.base_ref == 'main' }}
101101
runs-on: ubuntu-latest
102102
outputs:
103103
packages: ${{ steps.set_packages_output.outputs.packages }}
@@ -112,7 +112,7 @@ jobs:
112112
docker_build:
113113
name: Build
114114
needs: [find_dockerfiles]
115-
if: ${{ github.base_ref == 'develop' || github.base_ref == 'main' }}
115+
if: ${{ github.base_ref == 'main' }}
116116
runs-on: ubuntu-latest
117117
environment: ecr-ro
118118
permissions:
@@ -151,7 +151,7 @@ jobs:
151151
check_build_result:
152152
name: Build Result
153153
needs: [docker_build]
154-
if: ${{ always() && (github.base_ref == 'develop' || github.base_ref == 'main') }}
154+
if: ${{ always() && github.base_ref == 'main' }}
155155
runs-on: ubuntu-latest
156156
steps:
157157
- name: Check build result

collections/delegation/consumer/Consumer delegation creation.bru

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ post {
1111
}
1212

1313
headers {
14-
Authorization: {{JWT}}
14+
Authorization: {{JWT-M2M-ADMIN}}
1515
X-Correlation-Id: {{correlation-id}}
1616
}
1717

collections/environments/PagoPA local.bru

+1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ vars {
1717
JWT2: Bearer {{process.env.JWT2}}
1818
host-template: http://localhost:3900
1919
JWT-API-SEC: Bearer {{process.env.JWT-API-SEC}}
20+
JWT-M2M-ADMIN: Bearer {{process.env.JWT-M2M-ADMIN}}
2021
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
meta {
2+
name: Consumer delegation creation
3+
type: http
4+
seq: 1
5+
}
6+
7+
post {
8+
url: {{host-m2m-gw}}/consumerDelegations
9+
body: json
10+
auth: none
11+
}
12+
13+
headers {
14+
Authorization: {{JWT-M2M-ADMIN}}
15+
}
16+
17+
body:json {
18+
{
19+
"eserviceId": "{{eserviceId}}",
20+
"delegateId": "{{tenantId2}}"
21+
}
22+
}
23+
24+
vars:post-response {
25+
delegationId: res.body.id
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
meta {
2+
name: consumerDelegations
3+
}

docker/docker-compose.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
version: "3"
44
name: pagopa-interop
5+
volumes:
6+
readmodel-volume:
7+
58
services:
69
# Event Store Postgres DB
710
event-store:
@@ -75,7 +78,7 @@ services:
7578
MONGO_INITDB_ROOT_USERNAME: root
7679
MONGO_INITDB_ROOT_PASSWORD: example
7780
volumes:
78-
- ./mongo-data:/data/db
81+
- readmodel-volume:/data/db
7982

8083
# Dynamo DB readmodel for token generation and privacy notices
8184
dynamodb-local:

packages/api-clients/open-api/delegationApi.yml

+14-3
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,9 @@ paths:
282282
- delegation
283283
operationId: getDelegation
284284
responses:
285+
headers:
286+
X-Metadata-Version:
287+
$ref: "#/components/headers/MetadataVersionHeader"
285288
"200":
286289
description: Delegation retrieved
287290
content:
@@ -369,6 +372,9 @@ paths:
369372
description: Payload for delegation creation
370373
required: true
371374
responses:
375+
headers:
376+
X-Metadata-Version:
377+
$ref: "#/components/headers/MetadataVersionHeader"
372378
"200":
373379
description: Delegation created.
374380
content:
@@ -570,6 +576,9 @@ paths:
570576
description: Payload for delegation creation
571577
required: true
572578
responses:
579+
headers:
580+
X-Metadata-Version:
581+
$ref: "#/components/headers/MetadataVersionHeader"
573582
"200":
574583
description: Delegation created.
575584
content:
@@ -770,6 +779,11 @@ paths:
770779
schema:
771780
$ref: "#/components/schemas/Problem"
772781
components:
782+
headers:
783+
MetadataVersionHeader:
784+
description: The version number of the resource in the read model
785+
schema:
786+
type: integer
773787
parameters:
774788
CorrelationIdHeader:
775789
in: header
@@ -872,9 +886,6 @@ components:
872886
format: date-time
873887
rejectionReason:
874888
type: string
875-
revokedAt:
876-
type: string
877-
format: date-time
878889
state:
879890
$ref: "#/components/schemas/DelegationState"
880891
kind:

packages/api-clients/open-api/m2mGatewayApi.yml

+10-80
Original file line numberDiff line numberDiff line change
@@ -3817,14 +3817,17 @@ components:
38173817
revokedAt:
38183818
type: string
38193819
format: date-time
3820+
submittedAt:
3821+
type: string
3822+
format: date-time
3823+
activatedAt:
3824+
type: string
3825+
format: date-time
3826+
rejectedAt:
3827+
type: string
3828+
format: date-time
38203829
state:
38213830
$ref: "#/components/schemas/DelegationState"
3822-
activationContract:
3823-
$ref: "#/components/schemas/DelegationContractDocument"
3824-
revocationContract:
3825-
$ref: "#/components/schemas/DelegationContractDocument"
3826-
stamps:
3827-
$ref: "#/components/schemas/DelegationStamps"
38283831
required:
38293832
- id
38303833
- delegatorId
@@ -3833,7 +3836,7 @@ components:
38333836
- createdAt
38343837
- state
38353838
- kind
3836-
- stamps
3839+
- submittedAt
38373840
ConsumerDelegations:
38383841
type: object
38393842
additionalProperties: false
@@ -3847,58 +3850,6 @@ components:
38473850
required:
38483851
- results
38493852
- pagination
3850-
DelegationContractDocument:
3851-
type: object
3852-
additionalProperties: false
3853-
properties:
3854-
id:
3855-
type: string
3856-
format: uuid
3857-
name:
3858-
type: string
3859-
prettyName:
3860-
type: string
3861-
contentType:
3862-
type: string
3863-
path:
3864-
type: string
3865-
createdAt:
3866-
type: string
3867-
format: date-time
3868-
required:
3869-
- id
3870-
- name
3871-
- prettyName
3872-
- contentType
3873-
- path
3874-
- createdAt
3875-
DelegationStamp:
3876-
type: object
3877-
additionalProperties: false
3878-
properties:
3879-
who:
3880-
type: string
3881-
format: uuid
3882-
when:
3883-
type: string
3884-
format: date-time
3885-
required:
3886-
- who
3887-
- when
3888-
DelegationStamps:
3889-
type: object
3890-
additionalProperties: false
3891-
properties:
3892-
submission:
3893-
$ref: "#/components/schemas/DelegationStamp"
3894-
activation:
3895-
$ref: "#/components/schemas/DelegationStamp"
3896-
rejection:
3897-
$ref: "#/components/schemas/DelegationStamp"
3898-
revocation:
3899-
$ref: "#/components/schemas/DelegationStamp"
3900-
required:
3901-
- submission
39023853
DelegationState:
39033854
type: string
39043855
enum:
@@ -4343,8 +4294,6 @@ components:
43434294
type: integer
43444295
format: int32
43454296
minimum: 0
4346-
riskAnalysisDocument:
4347-
$ref: "#/components/schemas/PurposeVersionDocument"
43484297
rejectionReason:
43494298
type: string
43504299
required:
@@ -4366,25 +4315,6 @@ components:
43664315
required:
43674316
- results
43684317
- pagination
4369-
PurposeVersionDocument:
4370-
type: object
4371-
additionalProperties: false
4372-
required:
4373-
- id
4374-
- contentType
4375-
- path
4376-
- createdAt
4377-
properties:
4378-
id:
4379-
type: string
4380-
format: uuid
4381-
contentType:
4382-
type: string
4383-
path:
4384-
type: string
4385-
createdAt:
4386-
type: string
4387-
format: date-time
43884318
PurposeVersionSeed:
43894319
type: object
43904320
additionalProperties: false

packages/attribute-registry-process/package.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"main": "dist",
66
"type": "module",
77
"scripts": {
8-
"test": "vitest",
8+
"test:api": "vitest --config vitest.api.config.ts",
9+
"test:integration": "vitest --config vitest.integration.config.ts",
910
"lint": "eslint . --ext .ts,.tsx",
1011
"lint:autofix": "eslint . --ext .ts,.tsx --fix",
1112
"format:check": "prettier --check src",
@@ -24,9 +25,13 @@
2425
"@protobuf-ts/runtime": "2.9.4",
2526
"@types/express": "4.17.21",
2627
"@types/node": "20.14.6",
28+
"@types/supertest": "6.0.2",
29+
"@types/jsonwebtoken": "^9.0.2",
2730
"pagopa-interop-commons-test": "workspace:*",
2831
"prettier": "2.8.8",
32+
"supertest": "7.0.0",
2933
"testcontainers": "10.9.0",
34+
"jsonwebtoken": "9.0.2",
3035
"tsx": "4.19.1",
3136
"typescript": "5.4.5",
3237
"vitest": "1.6.0"

packages/attribute-registry-process/src/app.ts

+25-12
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,34 @@ import { serviceName as modelsServiceName } from "pagopa-interop-models";
1212
import attributeRouter from "./routers/AttributeRouter.js";
1313
import healthRouter from "./routers/HealthRouter.js";
1414
import { config } from "./config/config.js";
15+
import { AttributeRegistryService } from "./services/attributeRegistryService.js";
1516

16-
const serviceName = modelsServiceName.ATTRIBUTE_REGISTRY_PROCESS;
17+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
18+
export async function createApp(service?: AttributeRegistryService) {
19+
const serviceName = modelsServiceName.ATTRIBUTE_REGISTRY_PROCESS;
1720

18-
const app = zodiosCtx.app();
21+
const router =
22+
service != null
23+
? attributeRouter(zodiosCtx, service)
24+
: attributeRouter(zodiosCtx);
1925

20-
// Disable the "X-Powered-By: Express" HTTP header for security reasons.
21-
// See https://cheatsheetseries.owasp.org/cheatsheets/HTTP_Headers_Cheat_Sheet.html#recommendation_16
22-
app.disable("x-powered-by");
26+
const app = zodiosCtx.app();
2327

24-
app.use(healthRouter);
25-
app.use(contextMiddleware(serviceName));
26-
app.use(await applicationAuditBeginMiddleware(serviceName, config));
27-
app.use(await applicationAuditEndMiddleware(serviceName, config));
28-
app.use(authenticationMiddleware(config));
29-
app.use(loggerMiddleware(serviceName));
30-
app.use(attributeRouter(zodiosCtx));
28+
// Disable the "X-Powered-By: Express" HTTP header for security reasons.
29+
// See https://cheatsheetseries.owasp.org/cheatsheets/HTTP_Headers_Cheat_Sheet.html#recommendation_16
30+
app.disable("x-powered-by");
31+
32+
app.use(healthRouter);
33+
app.use(contextMiddleware(serviceName));
34+
app.use(await applicationAuditBeginMiddleware(serviceName, config));
35+
app.use(await applicationAuditEndMiddleware(serviceName, config));
36+
app.use(authenticationMiddleware(config));
37+
app.use(loggerMiddleware(serviceName));
38+
app.use(router);
39+
40+
return app;
41+
}
42+
43+
const app = await createApp();
3144

3245
export default app;

packages/attribute-registry-process/src/routers/AttributeRouter.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ import {
1919
} from "../model/domain/apiConverter.js";
2020
import { config } from "../config/config.js";
2121
import { makeApiProblem } from "../model/domain/errors.js";
22-
import { attributeRegistryServiceBuilder } from "../services/attributeRegistryService.js";
22+
import {
23+
AttributeRegistryService,
24+
attributeRegistryServiceBuilder,
25+
} from "../services/attributeRegistryService.js";
2326
import {
2427
createCertifiedAttributesErrorMapper,
2528
createDeclaredAttributesErrorMapper,
@@ -32,7 +35,7 @@ import {
3235

3336
const readModelRepository = ReadModelRepository.init(config);
3437
const readModelService = readModelServiceBuilder(readModelRepository);
35-
const attributeRegistryService = attributeRegistryServiceBuilder(
38+
const defaultAttributeRegistryService = attributeRegistryServiceBuilder(
3639
initDB({
3740
username: config.eventStoreDbUsername,
3841
password: config.eventStoreDbPassword,
@@ -46,7 +49,8 @@ const attributeRegistryService = attributeRegistryServiceBuilder(
4649
);
4750

4851
const attributeRouter = (
49-
ctx: ZodiosContext
52+
ctx: ZodiosContext,
53+
attributeRegistryService: AttributeRegistryService = defaultAttributeRegistryService
5054
): ZodiosRouter<ZodiosEndpointDefinitions, ExpressContext> => {
5155
const attributeRouter = ctx.router(attributeRegistryApi.attributeApi.api, {
5256
validationErrorHandler: zodiosValidationErrorToApiProblem,

0 commit comments

Comments
 (0)