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

PIN-5661 - Create consumer delegation #1197

Open
wants to merge 27 commits into
base: feature/incaricato
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6fb335c
Improving bruno calls
ecamellini Nov 12, 2024
a0d1422
Adding consumer delegation creation route in delegation process
ecamellini Nov 12, 2024
c20adc3
Adding scaffolding for consumer delegation service and router
ecamellini Nov 12, 2024
87b62a4
Moving to commons file the retrieve methods and improving errors
ecamellini Nov 12, 2024
c44e2aa
Implementing
ecamellini Nov 12, 2024
90b25c1
Fixing build
ecamellini Nov 12, 2024
461969e
Merge branch 'feature/incaricato' into PIN-5661-post-consumer-delegat…
ecamellini Nov 12, 2024
f6f3fea
Merge branch 'feature/incaricato' into PIN-5661-post-consumer-delegat…
ecamellini Nov 15, 2024
2507337
Adding correlationId param where missing in API spec
ecamellini Nov 15, 2024
52f8100
removing whitespaces
ecamellini Nov 15, 2024
4202f57
Rejection reason
ecamellini Nov 15, 2024
da1990e
Removing useless file
ecamellini Nov 15, 2024
059265b
Removing check IPA
ecamellini Nov 15, 2024
7fdff46
Adding missing param in components
ecamellini Nov 15, 2024
47014aa
Adding tests
ecamellini Nov 15, 2024
f46ab29
Fixing tests
ecamellini Nov 15, 2024
f8a7cba
Improving error mapping
ecamellini Nov 15, 2024
e4823a3
Error mapping
ecamellini Nov 15, 2024
f6d318e
Removing unused import
ecamellini Nov 15, 2024
04a658f
Fixing linting
ecamellini Nov 15, 2024
3db5d4c
Adding to router
ecamellini Nov 15, 2024
eafef64
Adding tests
ecamellini Nov 15, 2024
30ca48c
Adding bruno call
ecamellini Nov 15, 2024
cc0a591
Adding missing readmodel test
ecamellini Nov 18, 2024
652b16f
Adding check IPA for delegator and delegate
ecamellini Nov 18, 2024
88f7d38
Adding also to consumer delegation
ecamellini Nov 18, 2024
d456f1b
Fixing tests description
ecamellini Nov 18, 2024
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
1 change: 1 addition & 0 deletions collections/collection.bru
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
vars:pre-request {
tenantId: 69e2865e-65ab-4e48-a638-2037a9ee2ee7
tenantId2: 0cf1db41-3085-43a6-9e4c-57e0fb81a916
userId1: f07ddb8f-17f9-47d4-b31e-35d1ac10e521
userId2: 2a1614d7-c1aa-4148-895f-dcadb75b6660
keyEncodedPem: LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlHZk1BMEdDU3FHU0liM0RRRUJBUVVBQTRHTkFEQ0JpUUtCZ1FETUVrdEZVVyszY2VWN01FT2RBVG5ZYWc3eQpJc3JtRDZ6eVBTZHhJTDlJczNmdnlGREMvbnVCWVFpa3Izampjc21aREdTN0RGKzNWRUJ3UXFYUldGM3NObElRCnFIc21Td2x2NjZ2ZDQ0OHEzSXpSb1JBWktGMGc3c3BGcUJ5bi9DTXZaM0RET2xVK2V0c2xDYWRNa084UktyM1YKd2xqQjFJdk90TWtCd2lLTU53SURBUUFCCi0tLS0tRU5EIFBVQkxJQyBLRVktLS0tLQo=
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
meta {
name: List producer delegations
name: List delegations
type: http
seq: 1
}
Expand All @@ -24,3 +24,7 @@ headers {
Authorization: {{JWT}}
X-Correlation-Id: {{correlation-id}}
}

vars:post-response {
delegationId: res.body.results.at(-1).id
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ get {
}

params:path {
delegationId: 123e4567-e89b-12d3-a456-426614174000
delegationId: {{delegationId}}
}

headers {
Expand Down
27 changes: 27 additions & 0 deletions collections/delegation/consumer/Delegation Creation.bru
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
meta {
name: Delegation Creation
type: http
seq: 1
}

post {
url: {{host-delegation}}/consumer/delegations
body: json
auth: none
}

headers {
Authorization: {{JWT}}
X-Correlation-Id: {{correlation-id}}
}

body:json {
{
"eserviceId": "{{eserviceId}}",
"delegateId": "{{tenantId2}}"
}
}

vars:post-response {
delegationId: res.body.id
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
meta {
name: Approves a delegation
type: http
seq: 4
seq: 2
}

post {
Expand All @@ -11,10 +11,10 @@ post {
}

params:path {
delegationId:
delegationId: {{delegationId}}
}

headers {
Authorization: {{JWT}}
Authorization: {{JWT2}}
X-Correlation-Id: {{correlation-id}}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
meta {
name: Delegation Creation
type: http
seq: 3
seq: 1
}

post {
Expand All @@ -17,7 +17,11 @@ headers {

body:json {
{
"eserviceId": "",
"delegateId": ""
"eserviceId": "{{eserviceId}}",
"delegateId": "{{tenantId2}}"
}
}

vars:post-response {
delegationId: res.body.id
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
meta {
name: Rejects a delegation
type: http
seq: 5
seq: 3
}

post {
Expand All @@ -11,16 +11,16 @@ post {
}

params:path {
delegationId:
delegationId: {{delegationId}}
}

headers {
Authorization: {{JWT}}
Authorization: {{JWT2}}
X-Correlation-Id: {{correlation-id}}
}

body:json {
{
"rejectionReason": ""
"rejectionReason": "test rejection reason"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
meta {
name: Revoke a delegation
type: http
seq: 6
seq: 4
}

delete {
Expand All @@ -10,6 +10,10 @@ delete {
auth: none
}

params:path {
delegationId: {{delegationId}}
}

headers {
Authorization: {{JWT}}
X-Correlation-Id: {{correlation-id}}
Expand Down
1 change: 1 addition & 0 deletions collections/environments/PagoPA local.bru
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ vars {
host-delegation: http://localhost:3800
host-api-gw: http://localhost:3700/api-gateway/0.0
JWT-M2M: Bearer {{process.env.JWT-M2M}}
JWT2: Bearer {{process.env.JWT2}}
ecamellini marked this conversation as resolved.
Show resolved Hide resolved
}
122 changes: 90 additions & 32 deletions packages/api-clients/open-api/delegationApi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ tags:
url: http://swagger.io
paths:
/delegations:
parameters:
- $ref: "#/components/parameters/CorrelationIdHeader"
get:
description: List delegations
summary: List delegations
Expand Down Expand Up @@ -118,19 +120,21 @@ paths:
schema:
$ref: "#/components/schemas/Problem"
/delegations/{delegationId}:
parameters:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we add the CorrelationIdHeader too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should! Apparently, it's missing everywhere in this spec, I added it in 2507337

- $ref: "#/components/parameters/CorrelationIdHeader"
- name: delegationId
in: path
description: The delegation id
required: true
schema:
type: string
format: uuid
get:
description: Retrieves a delegation
summary: Retrieves a delegation
tags:
- delegation
operationId: getDelegation
parameters:
- name: delegationId
in: path
description: The delegation id
required: true
schema:
type: string
responses:
"200":
description: Delegation retrieved
Expand All @@ -156,10 +160,53 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/Problem"
/consumer/delegations:
parameters:
- $ref: "#/components/parameters/CorrelationIdHeader"
post:
description: Creates a consumer delegation
summary: Consumer Delegation Creation
tags:
- consumer
operationId: createConsumerDelegation
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/DelegationSeed"
description: Payload for delegation creation
required: true
responses:
"200":
description: Delegation created.
content:
application/json:
schema:
$ref: "#/components/schemas/Delegation"
"400":
description: Bad Request
content:
application/json:
schema:
$ref: "#/components/schemas/Problem"
"401":
description: Unauthorized
content:
application/json:
schema:
$ref: "#/components/schemas/Problem"
"403":
description: Forbidden
content:
application/json:
schema:
$ref: "#/components/schemas/Problem"
/producer/delegations:
parameters:
- $ref: "#/components/parameters/CorrelationIdHeader"
post:
description: creates the delegation
summary: Delegation Creation
description: Creates a producer delegation
summary: Producer delegation creation
tags:
- producer
operationId: createProducerDelegation
Expand All @@ -168,7 +215,7 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/DelegationSeed"
description: payload for delegation creation
description: Payload for delegation creation
required: true
responses:
"200":
Expand Down Expand Up @@ -196,20 +243,21 @@ paths:
schema:
$ref: "#/components/schemas/Problem"
/producer/delegations/{delegationId}/approve:
parameters:
- $ref: "#/components/parameters/CorrelationIdHeader"
- name: delegationId
in: path
description: The delegation id
required: true
schema:
type: string
format: uuid
post:
description: Approves a delegation
summary: Approves a delegation
description: Approves a producer delegation
summary: Producer delegation approval
tags:
- producer
operationId: approveProducerDelegation
parameters:
- name: delegationId
in: path
description: The delegation id
required: true
schema:
type: string
format: uuid
responses:
"204":
description: Delegation approved
Expand Down Expand Up @@ -238,9 +286,18 @@ paths:
schema:
$ref: "#/components/schemas/Problem"
/producer/delegations/{delegationId}/reject:
parameters:
- $ref: "#/components/parameters/CorrelationIdHeader"
- name: delegationId
in: path
description: The delegation id
required: true
schema:
type: string
format: uuid
post:
description: Rejects a delegation
summary: Rejects a delegation
description: Rejects a producer delegation
summary: Producer delegation rejection
tags:
- producer
operationId: rejectProducerDelegation
Expand All @@ -251,14 +308,6 @@ paths:
$ref: "#/components/schemas/RejectDelegationPayload"
required: true
description: payload for delegation rejection
parameters:
- name: delegationId
in: path
description: The delegation id
required: true
schema:
type: string
format: uuid
responses:
"204":
description: Delegation rejected
Expand Down Expand Up @@ -288,15 +337,17 @@ paths:
$ref: "#/components/schemas/Problem"
/producer/delegations/{delegationId}:
parameters:
- $ref: "#/components/parameters/CorrelationIdHeader"
- name: delegationId
in: path
description: The delegation id
required: true
schema:
type: string
format: uuid
delete:
description: Revokes a delegation
summary: Revokes a delegation
description: Revokes a producer delegation
summary: Producer delegation revocation
tags:
- producer
operationId: revokeProducerDelegation
Expand Down Expand Up @@ -337,6 +388,13 @@ paths:
schema:
$ref: "#/components/schemas/Problem"
components:
parameters:
CorrelationIdHeader:
in: header
name: X-Correlation-Id
required: true
schema:
type: string
schemas:
Delegations:
type: object
Expand Down
Loading