Skip to content

Commit

Permalink
Delegation process improvements in errors, tests, API spec (#1209)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecamellini authored Nov 20, 2024
1 parent ec0ad3e commit d2ed805
Show file tree
Hide file tree
Showing 22 changed files with 365 additions and 227 deletions.
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
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}}
}
83 changes: 50 additions & 33 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:
- $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 @@ -157,9 +161,11 @@ paths:
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 +174,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 +202,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 +245,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 @@ -250,15 +266,7 @@ paths:
schema:
$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
description: Payload for delegation rejection
responses:
"204":
description: Delegation rejected
Expand Down Expand Up @@ -288,15 +296,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 +347,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
10 changes: 6 additions & 4 deletions packages/commons-test/src/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import {
PurposeVersionId,
ProducerKeychain,
Delegation,
delegationKind,
DelegationId,
DelegationContractDocument,
DelegationContractId,
Expand All @@ -68,6 +67,7 @@ import {
PlatformStatesClientPK,
PlatformStatesClientEntry,
makePlatformStatesClientPK,
DelegationKind,
unsafeBrandId,
} from "pagopa-interop-models";
import { AuthData, dateToSeconds } from "pagopa-interop-commons";
Expand Down Expand Up @@ -369,7 +369,8 @@ export const getMockAuthData = (organizationId?: TenantId): AuthData => ({
selfcareId: generateId(),
});

export const getMockDelegationProducer = ({
export const getMockDelegation = ({
kind,
id = generateId<DelegationId>(),
delegatorId = generateId<TenantId>(),
delegateId = generateId<TenantId>(),
Expand All @@ -378,14 +379,15 @@ export const getMockDelegationProducer = ({
activationContract = undefined,
revocationContract = undefined,
}: {
kind: DelegationKind;
id?: DelegationId;
delegatorId?: TenantId;
delegateId?: TenantId;
eserviceId?: EServiceId;
state?: DelegationState;
activationContract?: DelegationContractDocument;
revocationContract?: DelegationContractDocument;
} = {}): Delegation => {
}): Delegation => {
const creationTime = new Date();

return {
Expand All @@ -398,7 +400,7 @@ export const getMockDelegationProducer = ({
state,
activationContract,
revocationContract,
kind: delegationKind.delegatedProducer,
kind,
stamps: {
submission: {
who: delegatorId,
Expand Down
Loading

0 comments on commit d2ed805

Please sign in to comment.