From 83a1a7f7501726c16af9ffcfd3ce86a5a2ec2148 Mon Sep 17 00:00:00 2001 From: Giulia Tremolada <124147597+giulia-tremolada@users.noreply.github.com> Date: Thu, 16 May 2024 09:02:40 +0200 Subject: [PATCH] [SELC-4886] refactor: update ms-core openapi and remove unused related methods (#444) --- app/src/main/resources/swagger/api-docs.json | 946 +--- .../connector/api/MsCoreConnector.java | 24 +- .../docs/openapi/api-selfcare-core-docs.json | 4879 ++++------------- .../connector/rest/CoreConnectorImpl.java | 293 +- .../rest/client/CoreUserApiRestClient.java | 8 - .../rest/config/MsCoreRestClientConfig.java | 7 +- .../rest/model/mapper/InstitutionMapper.java | 28 +- .../connector/rest/CoreConnectorImplTest.java | 998 +--- .../rest/MsCoreConnectorImplTest.java | 0 .../dashboard/core/InstitutionService.java | 30 +- .../core/InstitutionServiceImpl.java | 230 +- .../core/InstitutionServiceImplTest.java | 958 +--- .../web/config/MethodSecurityConfig.java | 19 +- .../web/controller/InstitutionController.java | 182 +- .../security/PartyAuthoritiesRetriever.java | 72 - .../security/SelfCarePermissionEvaluator.java | 96 - .../controller/InstitutionControllerTest.java | 298 +- .../PartyAuthoritiesRetrieverTest.java | 156 - .../SelfCarePermissionEvaluatorTest.java | 376 -- 19 files changed, 1294 insertions(+), 8306 deletions(-) delete mode 100644 connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/client/CoreUserApiRestClient.java delete mode 100644 connector/rest/src/test/java/it/pagopa/selfcare/dashboard/connector/rest/MsCoreConnectorImplTest.java delete mode 100644 web/src/main/java/it/pagopa/selfcare/dashboard/web/security/PartyAuthoritiesRetriever.java delete mode 100644 web/src/main/java/it/pagopa/selfcare/dashboard/web/security/SelfCarePermissionEvaluator.java delete mode 100644 web/src/test/java/it/pagopa/selfcare/dashboard/web/security/PartyAuthoritiesRetrieverTest.java delete mode 100644 web/src/test/java/it/pagopa/selfcare/dashboard/web/security/SelfCarePermissionEvaluatorTest.java diff --git a/app/src/main/resources/swagger/api-docs.json b/app/src/main/resources/swagger/api-docs.json index 11c8bc47e..5c4dfb6bf 100644 --- a/app/src/main/resources/swagger/api-docs.json +++ b/app/src/main/resources/swagger/api-docs.json @@ -116,113 +116,6 @@ } ] } }, - "/v1/institutions" : { - "get" : { - "tags" : [ "institutions" ], - "summary" : "getInstitutions", - "description" : "Service to get all the institutions related to logged user", - "operationId" : "getInstitutionsUsingGET", - "parameters" : [ { - "name" : "authenticated", - "in" : "query", - "required" : false, - "style" : "form", - "schema" : { - "type" : "boolean" - } - }, { - "name" : "authorities[0].authority", - "in" : "query", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "credentials", - "in" : "query", - "required" : false, - "style" : "form", - "schema" : { - "type" : "object" - } - }, { - "name" : "details", - "in" : "query", - "required" : false, - "style" : "form", - "schema" : { - "type" : "object" - } - }, { - "name" : "principal", - "in" : "query", - "required" : false, - "style" : "form", - "schema" : { - "type" : "object" - } - } ], - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/InstitutionBaseResource" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "401" : { - "description" : "Unauthorized", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, "/v1/institutions/products" : { "get" : { "tags" : [ "institutions" ], @@ -481,569 +374,9 @@ } } } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - }, - "put" : { - "tags" : [ "institutions" ], - "summary" : "updateInstitutionGeographicTaxonomy", - "description" : "Service to update the geographic taxonomy of an onboarded institution", - "operationId" : "updateInstitutionGeographicTaxonomyUsingPUT", - "parameters" : [ { - "name" : "institutionId", - "in" : "path", - "description" : "Institution's unique internal identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - } ], - "requestBody" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/GeographicTaxonomyListDto" - } - } - } - }, - "responses" : { - "200" : { - "description" : "OK" - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "401" : { - "description" : "Unauthorized", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/v1/institutions/{institutionId}/institutions" : { - "get" : { - "tags" : [ "institutions" ], - "summary" : "Retrieve list of delegation using to", - "description" : "Retrieve list of delegation using to", - "operationId" : "getDelegationsUsingToUsingGET", - "parameters" : [ { - "name" : "institutionId", - "in" : "path", - "description" : "Technical partner's identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - }, { - "name" : "productId", - "in" : "query", - "description" : "Product's identifier", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "search", - "in" : "query", - "description" : "Institution's name to search", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "taxCode", - "in" : "query", - "description" : "Institution's tax code", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "mode", - "in" : "query", - "description" : "Mode (full or normal) to retrieve institution's delegations", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string", - "enum" : [ "FULL", "NORMAL" ] - } - }, { - "name" : "order", - "in" : "query", - "description" : "Order to show response NONE, ASC, DESC", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string", - "enum" : [ "ASC", "DESC", "NONE" ] - } - }, { - "name" : "page", - "in" : "query", - "description" : "page", - "required" : false, - "style" : "form", - "schema" : { - "type" : "integer", - "format" : "int32" - } - }, { - "name" : "size", - "in" : "query", - "description" : "size", - "required" : false, - "style" : "form", - "schema" : { - "type" : "integer", - "format" : "int32" - } - } ], - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/DelegationResource" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "401" : { - "description" : "Unauthorized", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/v1/institutions/{institutionId}/logo" : { - "put" : { - "tags" : [ "institutions" ], - "summary" : "saveInstitutionLogo", - "description" : "Service to upload and store the institution's logo", - "operationId" : "saveInstitutionLogoUsingPUT", - "parameters" : [ { - "name" : "institutionId", - "in" : "path", - "description" : "Institution's unique internal identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - } ], - "requestBody" : { - "content" : { - "multipart/form-data" : { - "schema" : { - "required" : [ "logo" ], - "type" : "object", - "properties" : { - "logo" : { - "type" : "string", - "description" : "Institution's logo", - "format" : "binary" - } - } - } - } - } - }, - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "application/json" : { - "schema" : { - "type" : "object" - } - }, - "multipart/form-data" : { - "schema" : { - "type" : "object" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "401" : { - "description" : "Unauthorized", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/v1/institutions/{institutionId}/partners" : { - "get" : { - "tags" : [ "institutions" ], - "summary" : "Retrieve institution's delegations", - "description" : "Retrieve institution's delegations", - "operationId" : "getDelegationsUsingFromUsingGET", - "parameters" : [ { - "name" : "institutionId", - "in" : "path", - "description" : "Institution's identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - }, { - "name" : "productId", - "in" : "query", - "description" : "Product's identifier", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/DelegationResource" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "401" : { - "description" : "Unauthorized", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/v1/institutions/{institutionId}/products/{productId}/users" : { - "get" : { - "tags" : [ "institutions" ], - "summary" : "getInstitutionProductUsers", - "description" : "Service to get all the users related to a specific pair of institution-product", - "operationId" : "getInstitutionProductUsersUsingGET", - "parameters" : [ { - "name" : "institutionId", - "in" : "path", - "description" : "Institution's unique internal identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - }, { - "name" : "productId", - "in" : "path", - "description" : "Product's unique identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - }, { - "name" : "role", - "in" : "query", - "description" : "User's role", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string", - "enum" : [ "ADMIN", "LIMITED" ] - } - }, { - "name" : "productRoles", - "in" : "query", - "description" : "User's roles in product", - "required" : false, - "style" : "form", - "explode" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/ProductUserResource" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "401" : { - "description" : "Unauthorized", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "500" : { - "description" : "Internal Server Error", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - }, - "post" : { - "tags" : [ "institutions" ], - "summary" : "createInstitutionProductUser", - "description" : "Service to Create a user related to a specific pair of institution-product", - "operationId" : "createInstitutionProductUserUsingPOST", - "parameters" : [ { - "name" : "institutionId", - "in" : "path", - "description" : "Institution's unique internal identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - }, { - "name" : "productId", - "in" : "path", - "description" : "Product's unique identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - } ], - "requestBody" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/CreateUserDto" - } - } - } - }, - "responses" : { - "201" : { - "description" : "Created", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/UserIdResource" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "401" : { - "description" : "Unauthorized", + }, + "404" : { + "description" : "Not Found", "content" : { "application/problem+json" : { "schema" : { @@ -1066,14 +399,12 @@ "security" : [ { "bearerAuth" : [ "global" ] } ] - } - }, - "/v1/institutions/{institutionId}/products/{productId}/users/{userId}" : { + }, "put" : { "tags" : [ "institutions" ], - "summary" : "addUserProductRoles", - "description" : "Service to add a new role/product to a specific user", - "operationId" : "addUserProductRolesUsingPUT", + "summary" : "updateInstitutionGeographicTaxonomy", + "description" : "Service to update the geographic taxonomy of an onboarded institution", + "operationId" : "updateInstitutionGeographicTaxonomyUsingPUT", "parameters" : [ { "name" : "institutionId", "in" : "path", @@ -1083,37 +414,19 @@ "schema" : { "type" : "string" } - }, { - "name" : "productId", - "in" : "path", - "description" : "Product's unique identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - }, { - "name" : "userId", - "in" : "path", - "description" : "User's unique identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } } ], "requestBody" : { "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/UserProductRoles" + "$ref" : "#/components/schemas/GeographicTaxonomyListDto" } } } }, "responses" : { - "201" : { - "description" : "Created" + "200" : { + "description" : "OK" }, "400" : { "description" : "Bad Request", @@ -1151,16 +464,16 @@ } ] } }, - "/v1/institutions/{institutionId}/users" : { + "/v1/institutions/{institutionId}/institutions" : { "get" : { "tags" : [ "institutions" ], - "summary" : "getInstitutionUsers", - "description" : "Service to get all the users related to a specific institution", - "operationId" : "getInstitutionUsersUsingGET", + "summary" : "Retrieve list of delegation using to", + "description" : "Retrieve list of delegation using to", + "operationId" : "getDelegationsUsingToUsingGET", "parameters" : [ { "name" : "institutionId", "in" : "path", - "description" : "Institution's unique internal identifier", + "description" : "Technical partner's identifier", "required" : true, "style" : "simple", "schema" : { @@ -1169,32 +482,70 @@ }, { "name" : "productId", "in" : "query", - "description" : "Product's unique identifier", + "description" : "Product's identifier", "required" : false, "style" : "form", "schema" : { "type" : "string" } }, { - "name" : "role", + "name" : "search", "in" : "query", - "description" : "User's role", + "description" : "Institution's name to search", "required" : false, "style" : "form", "schema" : { - "type" : "string", - "enum" : [ "ADMIN", "LIMITED" ] + "type" : "string" } }, { - "name" : "productRoles", + "name" : "taxCode", "in" : "query", - "description" : "User's roles in product", + "description" : "Institution's tax code", "required" : false, "style" : "form", - "explode" : true, "schema" : { "type" : "string" } + }, { + "name" : "mode", + "in" : "query", + "description" : "Mode (full or normal) to retrieve institution's delegations", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string", + "enum" : [ "FULL", "NORMAL" ] + } + }, { + "name" : "order", + "in" : "query", + "description" : "Order to show response NONE, ASC, DESC", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string", + "enum" : [ "ASC", "DESC", "NONE" ] + } + }, { + "name" : "page", + "in" : "query", + "description" : "page", + "required" : false, + "style" : "form", + "schema" : { + "type" : "integer", + "format" : "int32" + } + }, { + "name" : "size", + "in" : "query", + "description" : "size", + "required" : false, + "style" : "form", + "schema" : { + "type" : "integer", + "format" : "int32" + } } ], "responses" : { "200" : { @@ -1204,7 +555,7 @@ "schema" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/InstitutionUserResource" + "$ref" : "#/components/schemas/DelegationResource" } } } @@ -1251,18 +602,17 @@ } } }, - "deprecated" : true, "security" : [ { "bearerAuth" : [ "global" ] } ] } }, - "/v1/institutions/{institutionId}/users/{userId}" : { - "get" : { + "/v1/institutions/{institutionId}/logo" : { + "put" : { "tags" : [ "institutions" ], - "summary" : "getInstitutionUser", - "description" : "Service to get the users with the given user id related to a specific institution", - "operationId" : "getInstitutionUserUsingGET", + "summary" : "saveInstitutionLogo", + "description" : "Service to upload and store the institution's logo", + "operationId" : "saveInstitutionLogoUsingPUT", "parameters" : [ { "name" : "institutionId", "in" : "path", @@ -1272,15 +622,100 @@ "schema" : { "type" : "string" } - }, { - "name" : "userId", + } ], + "requestBody" : { + "content" : { + "multipart/form-data" : { + "schema" : { + "required" : [ "logo" ], + "type" : "object", + "properties" : { + "logo" : { + "type" : "string", + "description" : "Institution's logo", + "format" : "binary" + } + } + } + } + } + }, + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "type" : "object" + } + }, + "multipart/form-data" : { + "schema" : { + "type" : "object" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "401" : { + "description" : "Unauthorized", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "500" : { + "description" : "Internal Server Error", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + } + }, + "security" : [ { + "bearerAuth" : [ "global" ] + } ] + } + }, + "/v1/institutions/{institutionId}/partners" : { + "get" : { + "tags" : [ "institutions" ], + "summary" : "Retrieve institution's delegations", + "description" : "Retrieve institution's delegations", + "operationId" : "getDelegationsUsingFromUsingGET", + "parameters" : [ { + "name" : "institutionId", "in" : "path", - "description" : "User's unique identifier", + "description" : "Institution's identifier", "required" : true, "style" : "simple", "schema" : { "type" : "string" } + }, { + "name" : "productId", + "in" : "query", + "description" : "Product's identifier", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string" + } } ], "responses" : { "200" : { @@ -1288,7 +723,10 @@ "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/InstitutionUserDetailsResource" + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/DelegationResource" + } } } } @@ -3436,6 +2874,15 @@ "schema" : { "type" : "string" } + }, { + "name" : "productRole", + "in" : "query", + "description" : "productRole", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string" + } } ], "responses" : { "204" : { @@ -3510,6 +2957,15 @@ "schema" : { "type" : "string" } + }, { + "name" : "productRole", + "in" : "query", + "description" : "productRole", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string" + } } ], "responses" : { "204" : { @@ -3584,6 +3040,15 @@ "schema" : { "type" : "string" } + }, { + "name" : "productRole", + "in" : "query", + "description" : "productRole", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string" + } } ], "responses" : { "204" : { @@ -4211,45 +3676,6 @@ } } }, - "InstitutionUserResource" : { - "title" : "InstitutionUserResource", - "type" : "object", - "properties" : { - "email" : { - "type" : "string", - "description" : "User's personal email" - }, - "id" : { - "type" : "string", - "description" : "User's unique identifier", - "format" : "uuid" - }, - "name" : { - "type" : "string", - "description" : "User's name" - }, - "products" : { - "type" : "array", - "description" : "Authorized user products", - "items" : { - "$ref" : "#/components/schemas/ProductInfoResource" - } - }, - "role" : { - "type" : "string", - "description" : "User's role", - "enum" : [ "ADMIN", "LIMITED" ] - }, - "status" : { - "type" : "string", - "description" : "User's status" - }, - "surname" : { - "type" : "string", - "description" : "User's surname" - } - } - }, "InvalidParam" : { "title" : "InvalidParam", "required" : [ "name", "reason" ], diff --git a/connector-api/src/main/java/it/pagopa/selfcare/dashboard/connector/api/MsCoreConnector.java b/connector-api/src/main/java/it/pagopa/selfcare/dashboard/connector/api/MsCoreConnector.java index 0a61b67dc..69cde2ad9 100644 --- a/connector-api/src/main/java/it/pagopa/selfcare/dashboard/connector/api/MsCoreConnector.java +++ b/connector-api/src/main/java/it/pagopa/selfcare/dashboard/connector/api/MsCoreConnector.java @@ -1,27 +1,22 @@ package it.pagopa.selfcare.dashboard.connector.api; -import it.pagopa.selfcare.dashboard.connector.model.auth.AuthInfo; import it.pagopa.selfcare.dashboard.connector.model.backoffice.BrokerInfo; import it.pagopa.selfcare.dashboard.connector.model.delegation.Delegation; import it.pagopa.selfcare.dashboard.connector.model.delegation.DelegationId; import it.pagopa.selfcare.dashboard.connector.model.delegation.DelegationRequest; import it.pagopa.selfcare.dashboard.connector.model.delegation.GetDelegationParameters; -import it.pagopa.selfcare.dashboard.connector.model.institution.*; +import it.pagopa.selfcare.dashboard.connector.model.institution.GeographicTaxonomy; +import it.pagopa.selfcare.dashboard.connector.model.institution.GeographicTaxonomyList; +import it.pagopa.selfcare.dashboard.connector.model.institution.Institution; +import it.pagopa.selfcare.dashboard.connector.model.institution.UpdateInstitutionResource; import it.pagopa.selfcare.dashboard.connector.model.product.PartyProduct; -import it.pagopa.selfcare.dashboard.connector.model.user.CreateUserDto; -import it.pagopa.selfcare.dashboard.connector.model.user.UserInfo; -import java.util.Collection; import java.util.List; public interface MsCoreConnector { - List getUserProducts(String userId); - List getInstitutionProducts(String institutionId); - Collection getAuthInfo(String institutionId); - Institution getInstitution(String institutionId); Institution updateInstitutionDescription(String institutionId, UpdateInstitutionResource updatePnPGInstitutionResource); @@ -32,19 +27,8 @@ public interface MsCoreConnector { List getDelegations(GetDelegationParameters delegationParameters); - void updateUser(String userId, String institutionId); - - InstitutionInfo getOnBoardedInstitution(String institutionId); - void updateInstitutionGeographicTaxonomy(String institutionId, GeographicTaxonomyList geographicTaxonomies); List getGeographicTaxonomyList(String institutionId); - UserInfo getUser(String relationshipId); - - void createUsers(String institutionId, String productId, String userId, CreateUserDto userDto, String productTitle); - - void checkExistingRelationshipRoles(String institutionId, String productId, CreateUserDto userDto, String userId); - - Collection getUsers(String institutionId, UserInfo.UserInfoFilter userInfoFilter); } diff --git a/connector/rest/docs/openapi/api-selfcare-core-docs.json b/connector/rest/docs/openapi/api-selfcare-core-docs.json index 59eff9e6f..92ec38aea 100644 --- a/connector/rest/docs/openapi/api-selfcare-core-docs.json +++ b/connector/rest/docs/openapi/api-selfcare-core-docs.json @@ -33,12 +33,6 @@ }, { "name" : "Onboarding", "description" : "Onboarding Controller" - }, { - "name" : "Persons", - "description" : "User Controller" - }, { - "name" : "Token", - "description" : "Token Controller" }, { "name" : "kafka", "description" : "Queue Notification Controller" @@ -354,6 +348,135 @@ } ] } }, + "/v2/delegations" : { + "get" : { + "tags" : [ "Delegation", "external-v2", "support" ], + "summary" : "Retrieve institution's delegations with pagination", + "description" : "Retrieve institution's delegations with pagination", + "operationId" : "getDelegationsUsingGET_1", + "parameters" : [ { + "name" : "institutionId", + "in" : "query", + "description" : "The internal identifier of the institution", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string" + } + }, { + "name" : "brokerId", + "in" : "query", + "description" : "The internal identifier of the institution", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string" + } + }, { + "name" : "productId", + "in" : "query", + "description" : "Product's unique identifier", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string" + } + }, { + "name" : "search", + "in" : "query", + "description" : "Description ente", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string" + } + }, { + "name" : "taxCode", + "in" : "query", + "description" : "Institution's tax code", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string" + } + }, { + "name" : "mode", + "in" : "query", + "description" : "Mode (full or normal) to retreieve institution's delegations", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string", + "enum" : [ "FULL", "NORMAL" ] + } + }, { + "name" : "order", + "in" : "query", + "description" : "Order to show response NONE, ASC, DESC", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string", + "enum" : [ "ASC", "DESC", "NONE" ] + } + }, { + "name" : "page", + "in" : "query", + "description" : "page", + "required" : false, + "style" : "form", + "schema" : { + "type" : "integer", + "format" : "int32" + } + }, { + "name" : "size", + "in" : "query", + "description" : "size", + "required" : false, + "style" : "form", + "schema" : { + "type" : "integer", + "format" : "int32" + } + } ], + "responses" : { + "200" : { + "description" : "OK", + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/DelegationWithPaginationResponse" + } + } + } + }, + "400" : { + "description" : "Bad Request", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + }, + "404" : { + "description" : "Not Found", + "content" : { + "application/problem+json" : { + "schema" : { + "$ref" : "#/components/schemas/Problem" + } + } + } + } + }, + "security" : [ { + "bearerAuth" : [ "global" ] + } ] + } + }, "/external/institutions" : { "get" : { "tags" : [ "External" ], @@ -708,27 +831,45 @@ } ] } }, - "/external/institutions/{externalId}/products/{productId}/manager" : { + "/institutions" : { "get" : { - "tags" : [ "External" ], - "summary" : "retrieves the manager related to the institution even if the current user is not related to the institution/product", - "description" : "retrieves the manager related to the institution even if the current user is not related to the institution/product", - "operationId" : "getManagerInstitutionByExternalIdUsingGET", + "tags" : [ "Institution", "external-v2", "support" ], + "summary" : "Gets institutions filtering by taxCode and/or subunitCode", + "description" : "Gets institutions filtering by taxCode and/or subunitCode", + "operationId" : "getInstitutionsUsingGET", "parameters" : [ { - "name" : "externalId", - "in" : "path", - "description" : "Institution's unique external identifier", - "required" : true, - "style" : "simple", + "name" : "taxCode", + "in" : "query", + "description" : "Institution's tax code", + "required" : false, + "style" : "form", "schema" : { "type" : "string" } }, { - "name" : "productId", - "in" : "path", - "description" : "Product's unique identifier", - "required" : true, - "style" : "simple", + "name" : "subunitCode", + "in" : "query", + "description" : "Institution's subunit code", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string" + } + }, { + "name" : "origin", + "in" : "query", + "description" : "origin", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string" + } + }, { + "name" : "originId", + "in" : "query", + "description" : "originId", + "required" : false, + "style" : "form", "schema" : { "type" : "string" } @@ -739,7 +880,7 @@ "content" : { "application/json" : { "schema" : { - "$ref" : "#/components/schemas/InstitutionManagerResponse" + "$ref" : "#/components/schemas/InstitutionsResponse" } } } @@ -768,215 +909,28 @@ "security" : [ { "bearerAuth" : [ "global" ] } ] - } - }, - "/external/institutions/{externalId}/relationships" : { - "get" : { - "tags" : [ "External" ], - "summary" : "returns the relationships related to the institution", - "description" : "returns the relationships related to the institution", - "operationId" : "getUserInstitutionRelationshipsByExternalIdUsingGET", - "parameters" : [ { - "name" : "externalId", - "in" : "path", - "description" : "Institution's unique external identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - }, { - "name" : "personId", - "in" : "query", - "description" : "personId", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "roles", - "in" : "query", - "description" : "roles", - "required" : false, - "style" : "form", - "explode" : true, - "schema" : { - "type" : "string", - "enum" : [ "DELEGATE", "MANAGER", "OPERATOR", "SUB_DELEGATE" ] - } - }, { - "name" : "states", - "in" : "query", - "description" : "states", - "required" : false, - "style" : "form", - "explode" : true, - "schema" : { - "type" : "string", - "enum" : [ "ACTIVE", "DELETED", "PENDING", "REJECTED", "SUSPENDED", "TOBEVALIDATED" ] - } - }, { - "name" : "products", - "in" : "query", - "description" : "products", - "required" : false, - "style" : "form", - "explode" : true, - "schema" : { - "type" : "string" - } - }, { - "name" : "productRoles", - "in" : "query", - "description" : "productRoles", - "required" : false, - "style" : "form", - "explode" : true, - "schema" : { - "type" : "string" + }, + "post" : { + "tags" : [ "Institution" ], + "summary" : "create an institution using external institution id without fetching data from party-registry or info-camere", + "description" : "create an institution using external institution id without fetching data from party-registry or info-camere", + "operationId" : "createInstitutionUsingPOST", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/InstitutionRequest" + } + } } - } ], + }, "responses" : { - "200" : { - "description" : "OK", + "201" : { + "description" : "Created", "content" : { "application/json" : { "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/RelationshipResult" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/institutions" : { - "get" : { - "tags" : [ "Institution", "external-v2", "support" ], - "summary" : "Gets institutions filtering by taxCode and/or subunitCode", - "description" : "Gets institutions filtering by taxCode and/or subunitCode", - "operationId" : "getInstitutionsUsingGET", - "parameters" : [ { - "name" : "taxCode", - "in" : "query", - "description" : "Institution's tax code", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "subunitCode", - "in" : "query", - "description" : "Institution's subunit code", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "origin", - "in" : "query", - "description" : "origin", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "originId", - "in" : "query", - "description" : "originId", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/InstitutionsResponse" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - }, - "post" : { - "tags" : [ "Institution" ], - "summary" : "create an institution using external institution id without fetching data from party-registry or info-camere", - "description" : "create an institution using external institution id without fetching data from party-registry or info-camere", - "operationId" : "createInstitutionUsingPOST", - "requestBody" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/InstitutionRequest" - } - } - } - }, - "responses" : { - "201" : { - "description" : "Created", - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/InstitutionResponse" + "$ref" : "#/components/schemas/InstitutionResponse" } } } @@ -1992,113 +1946,6 @@ } ] } }, - "/institutions/{id}/relationships" : { - "get" : { - "tags" : [ "Institution" ], - "summary" : "returns the relationships related to the institution", - "description" : "returns the relationships related to the institution", - "operationId" : "getUserInstitutionRelationshipsUsingGET", - "parameters" : [ { - "name" : "id", - "in" : "path", - "description" : "The internal identifier of the institution", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - }, { - "name" : "personId", - "in" : "query", - "description" : "personId", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "roles", - "in" : "query", - "description" : "roles", - "required" : false, - "style" : "form", - "explode" : true, - "schema" : { - "type" : "string", - "enum" : [ "DELEGATE", "MANAGER", "OPERATOR", "SUB_DELEGATE" ] - } - }, { - "name" : "states", - "in" : "query", - "description" : "states", - "required" : false, - "style" : "form", - "explode" : true, - "schema" : { - "type" : "string", - "enum" : [ "ACTIVE", "DELETED", "PENDING", "REJECTED", "SUSPENDED", "TOBEVALIDATED" ] - } - }, { - "name" : "products", - "in" : "query", - "description" : "products", - "required" : false, - "style" : "form", - "explode" : true, - "schema" : { - "type" : "string" - } - }, { - "name" : "productRoles", - "in" : "query", - "description" : "productRoles", - "required" : false, - "style" : "form", - "explode" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/RelationshipResult" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, "/institutions/{institutionId}/createdAt" : { "put" : { "tags" : [ "Institution" ], @@ -2226,21 +2073,31 @@ } ] } }, - "/institutions/{institutionId}/users" : { + "/institutions/{productId}/brokers/{institutionType}" : { "get" : { - "tags" : [ "Institution", "support" ], - "summary" : "getInstitutionUsers", - "description" : "Retrieve institution's users", - "operationId" : "getInstitutionUsersUsingGET", + "tags" : [ "Institution" ], + "summary" : "Retrieve institution brokers", + "description" : "Retrieve institution brokers", + "operationId" : "getInstitutionBrokersUsingGET", "parameters" : [ { - "name" : "institutionId", + "name" : "productId", "in" : "path", - "description" : "Institution's unique identifier", + "description" : "Product's unique identifier", "required" : true, "style" : "simple", "schema" : { "type" : "string" } + }, { + "name" : "institutionType", + "in" : "path", + "description" : "Institution's type", + "required" : true, + "style" : "simple", + "schema" : { + "type" : "string", + "enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP" ] + } } ], "responses" : { "200" : { @@ -2250,73 +2107,7 @@ "schema" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/UserInfoResponse" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/institutions/{productId}/brokers/{institutionType}" : { - "get" : { - "tags" : [ "Institution" ], - "summary" : "Retrieve institution brokers", - "description" : "Retrieve institution brokers", - "operationId" : "getInstitutionBrokersUsingGET", - "parameters" : [ { - "name" : "productId", - "in" : "path", - "description" : "Product's unique identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - }, { - "name" : "institutionType", - "in" : "path", - "description" : "Institution's type", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string", - "enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP" ] - } - } ], - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "application/json" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/BrokerResponse" + "$ref" : "#/components/schemas/BrokerResponse" } } } @@ -2367,7 +2158,7 @@ "200" : { "description" : "OK", "content" : { - "*/*" : { + "application/json" : { "schema" : { "$ref" : "#/components/schemas/BulkInstitutions" } @@ -2410,83 +2201,43 @@ } ] } }, - "/relationships" : { - "get" : { - "tags" : [ "Management" ], - "summary" : "Return a list of relationships", - "description" : "Return a list of relationships", - "operationId" : "getInstitutionRelationshipsUsingGET", + "/onboarding" : { + "head" : { + "tags" : [ "Onboarding" ], + "summary" : "verify if onboardedProduct is already onboarded for institution", + "description" : "verify if onboardedProduct is already onboarded for institution", + "operationId" : "verifyOnboardingInfoUsingHEAD", "parameters" : [ { - "name" : "from", - "in" : "query", - "description" : "from", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "to", + "name" : "taxCode", "in" : "query", - "description" : "to", - "required" : false, + "description" : "Institution's tax code", + "required" : true, "style" : "form", "schema" : { "type" : "string" } }, { - "name" : "roles", - "in" : "query", - "description" : "roles", - "required" : false, - "style" : "form", - "explode" : true, - "schema" : { - "type" : "string", - "enum" : [ "DELEGATE", "MANAGER", "OPERATOR", "SUB_DELEGATE" ] - } - }, { - "name" : "states", - "in" : "query", - "description" : "states", - "required" : false, - "style" : "form", - "explode" : true, - "schema" : { - "type" : "string", - "enum" : [ "ACTIVE", "DELETED", "PENDING", "REJECTED", "SUSPENDED", "TOBEVALIDATED" ] - } - }, { - "name" : "products", + "name" : "subunitCode", "in" : "query", - "description" : "products", + "description" : "Institution's subunit code", "required" : false, "style" : "form", - "explode" : true, "schema" : { "type" : "string" } }, { - "name" : "productRoles", + "name" : "productId", "in" : "query", - "description" : "productRoles", - "required" : false, + "description" : "Product's unique identifier", + "required" : true, "style" : "form", - "explode" : true, "schema" : { "type" : "string" } } ], "responses" : { "204" : { - "description" : "No Content", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/RelationshipsManagement" - } - } - } + "description" : "No Content" }, "400" : { "description" : "Bad Request", @@ -2509,42 +2260,32 @@ } } }, - "deprecated" : true, "security" : [ { "bearerAuth" : [ "global" ] } ] } }, - "/onboarding" : { + "/onboarding/institution/{externalId}/products/{productId}" : { "head" : { "tags" : [ "Onboarding" ], "summary" : "verify if onboardedProduct is already onboarded for institution", "description" : "verify if onboardedProduct is already onboarded for institution", - "operationId" : "verifyOnboardingInfoUsingHEAD", + "operationId" : "verifyOnboardingInfoUsingHEAD_1", "parameters" : [ { - "name" : "taxCode", - "in" : "query", - "description" : "Institution's tax code", + "name" : "externalId", + "in" : "path", + "description" : "Institution's unique external identifier", "required" : true, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "subunitCode", - "in" : "query", - "description" : "Institution's subunit code", - "required" : false, - "style" : "form", + "style" : "simple", "schema" : { "type" : "string" } }, { "name" : "productId", - "in" : "query", + "in" : "path", "description" : "Product's unique identifier", "required" : true, - "style" : "form", + "style" : "simple", "schema" : { "type" : "string" } @@ -2579,23 +2320,23 @@ } ] } }, - "/onboarding/info" : { - "get" : { + "/onboarding/verify" : { + "head" : { "tags" : [ "Onboarding" ], - "summary" : "returns onboarding info", - "description" : "returns onboarding info", - "operationId" : "onboardingInfoUsingGET", + "summary" : "verify if onboardedProduct is already onboarded for institution", + "description" : "verify if onboardedProduct is already onboarded for institution", + "operationId" : "verifyOnboardingInfoByFiltersUsingHEAD", "parameters" : [ { - "name" : "institutionId", + "name" : "productId", "in" : "query", - "description" : "The internal identifier of the institution", - "required" : false, + "description" : "Product's unique identifier", + "required" : true, "style" : "form", "schema" : { "type" : "string" } }, { - "name" : "institutionExternalId", + "name" : "externalId", "in" : "query", "description" : "Institution's unique external identifier", "required" : false, @@ -2604,26 +2345,45 @@ "type" : "string" } }, { - "name" : "states", + "name" : "taxCode", "in" : "query", - "description" : "List of Relationship state for filter products", + "description" : "Institution's tax code", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string" + } + }, { + "name" : "origin", + "in" : "query", + "description" : "Institution's origin", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string" + } + }, { + "name" : "originId", + "in" : "query", + "description" : "Institution's id in the relative origin open data", + "required" : false, + "style" : "form", + "schema" : { + "type" : "string" + } + }, { + "name" : "subunitCode", + "in" : "query", + "description" : "Institution's subunit code", "required" : false, "style" : "form", - "explode" : true, "schema" : { "type" : "string" } } ], "responses" : { - "200" : { - "description" : "OK", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/OnboardingInfoResponse" - } - } - } + "204" : { + "description" : "No Content" }, "400" : { "description" : "Bad Request", @@ -2651,34 +2411,34 @@ } ] } }, - "/onboarding/institution/{externalId}/products/{productId}" : { - "head" : { - "tags" : [ "Onboarding" ], - "summary" : "verify if onboardedProduct is already onboarded for institution", - "description" : "verify if onboardedProduct is already onboarded for institution", - "operationId" : "verifyOnboardingInfoUsingHEAD_1", + "/notification-event/contracts" : { + "put" : { + "tags" : [ "kafka" ], + "summary" : "resendContractsByInstitutionIdAndTokenId", + "description" : "Function to send a specific onboarding using institutionId and tokenId ", + "operationId" : "resendContractsByInstitutionIdAndTokenIdUsingPUT", "parameters" : [ { - "name" : "externalId", - "in" : "path", - "description" : "Institution's unique external identifier", + "name" : "tokenId", + "in" : "query", + "description" : "tokenId", "required" : true, - "style" : "simple", + "style" : "form", "schema" : { "type" : "string" } }, { - "name" : "productId", - "in" : "path", - "description" : "Product's unique identifier", + "name" : "institutionId", + "in" : "query", + "description" : "institutionId", "required" : true, - "style" : "simple", + "style" : "form", "schema" : { "type" : "string" } } ], "responses" : { - "204" : { - "description" : "No Content" + "200" : { + "description" : "OK" }, "400" : { "description" : "Bad Request", @@ -2690,53 +2450,8 @@ } } }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/onboarding/operators" : { - "post" : { - "tags" : [ "Onboarding" ], - "summary" : "performs operators onboarding on an already existing institution", - "description" : "performs operators onboarding on an already existing institution", - "operationId" : "onboardingInstitutionOperatorsUsingPOST", - "requestBody" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/OnboardingInstitutionOperatorsRequest" - } - } - } - }, - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "*/*" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/RelationshipResult" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", + "403" : { + "description" : "Forbidden", "content" : { "application/problem+json" : { "schema" : { @@ -2754,2698 +2469,183 @@ } } } - }, - "409" : { - "description" : "Conflict", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/onboarding/relationship/{relationshipId}/document" : { - "get" : { - "tags" : [ "Onboarding" ], - "summary" : "retrieve the contractDocument related to a relationship", - "description" : "retrieve the contractDocument related to a relationship", - "operationId" : "getOnboardingDocumentUsingGET", - "parameters" : [ { - "name" : "relationshipId", - "in" : "path", - "description" : "UserBinding's unique identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "*/*" : { - "schema" : { - "type" : "string", - "format" : "byte" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/onboarding/subdelegates" : { - "post" : { - "tags" : [ "Onboarding" ], - "summary" : "performs subdelegates onboarding on an already existing institution", - "description" : "performs subdelegates onboarding on an already existing institution", - "operationId" : "onboardingInstitutionSubDelegateUsingPOST", - "requestBody" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/OnboardingInstitutionOperatorsRequest" - } - } - } - }, - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "*/*" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/RelationshipResult" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "409" : { - "description" : "Conflict", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } } }, "security" : [ { "bearerAuth" : [ "global" ] } ] } - }, - "/onboarding/users" : { - "post" : { - "tags" : [ "Onboarding", "support" ], - "summary" : "The service adds users to the registry if they are not present and associates them with the institution and product contained in the body", - "description" : "The service adds users to the registry if they are not present and associates them with the institution and product contained in the body", - "operationId" : "onboardingInstitutionUsersUsingPOST", - "requestBody" : { - "content" : { - "application/json" : { - "schema" : { - "$ref" : "#/components/schemas/OnboardingInstitutionUsersRequest" - } - } - } - }, - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "*/*" : { - "schema" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/RelationshipResult" - } - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } + } + }, + "components" : { + "schemas" : { + "AdditionalInformations" : { + "title" : "AdditionalInformations", + "type" : "object", + "properties" : { + "agentOfPublicService" : { + "type" : "boolean" }, - "409" : { - "description" : "Conflict", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/onboarding/verify" : { - "head" : { - "tags" : [ "Onboarding" ], - "summary" : "verify if onboardedProduct is already onboarded for institution", - "description" : "verify if onboardedProduct is already onboarded for institution", - "operationId" : "verifyOnboardingInfoByFiltersUsingHEAD", - "parameters" : [ { - "name" : "productId", - "in" : "query", - "description" : "Product's unique identifier", - "required" : true, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "externalId", - "in" : "query", - "description" : "Institution's unique external identifier", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "taxCode", - "in" : "query", - "description" : "Institution's tax code", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "origin", - "in" : "query", - "description" : "Institution's origin", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "originId", - "in" : "query", - "description" : "Institution's id in the relative origin open data", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "subunitCode", - "in" : "query", - "description" : "Institution's subunit code", - "required" : false, - "style" : "form", - "schema" : { + "agentOfPublicServiceNote" : { "type" : "string" - } - } ], - "responses" : { - "204" : { - "description" : "No Content" - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/notification-event/contracts" : { - "put" : { - "tags" : [ "kafka" ], - "summary" : "resendContractsByInstitutionIdAndTokenId", - "description" : "Function to send a specific onboarding using institutionId and tokenId ", - "operationId" : "resendContractsByInstitutionIdAndTokenIdUsingPUT", - "parameters" : [ { - "name" : "tokenId", - "in" : "query", - "description" : "tokenId", - "required" : true, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "institutionId", - "in" : "query", - "description" : "institutionId", - "required" : true, - "style" : "form", - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "OK" - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "403" : { - "description" : "Forbidden", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - }, - "post" : { - "tags" : [ "kafka" ], - "summary" : "resendContracts", - "description" : "Service to resend contract notifications on SC-Contracts topic", - "operationId" : "resendContractsUsingPOST", - "parameters" : [ { - "name" : "size", - "in" : "query", - "description" : "size", - "required" : false, - "style" : "form", - "schema" : { - "type" : "integer", - "format" : "int32" - } - }, { - "name" : "productsFilter", - "in" : "query", - "description" : "productsFilter", - "required" : true, - "style" : "form", - "explode" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "OK" - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "409" : { - "description" : "Conflict", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/notification-event/users" : { - "post" : { - "tags" : [ "kafka" ], - "summary" : "resendUsers", - "description" : "Service to resend old user onboardings to the SCUsers kafka queue, it can send the onboardings of a single user or also retrieve all the users for a given set of products in a paged manner by passing page and size", - "operationId" : "resendUsersUsingPOST", - "parameters" : [ { - "name" : "size", - "in" : "query", - "description" : "size", - "required" : false, - "style" : "form", - "schema" : { - "type" : "integer", - "format" : "int32" - } - }, { - "name" : "page", - "in" : "query", - "description" : "page", - "required" : false, - "style" : "form", - "schema" : { - "type" : "integer", - "format" : "int32" - } - }, { - "name" : "productsFilter", - "in" : "query", - "description" : "productsFilter", - "required" : true, - "style" : "form", - "explode" : true, - "schema" : { - "type" : "string" - } - }, { - "name" : "userId", - "in" : "query", - "description" : "userId", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "OK" - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "409" : { - "description" : "Conflict", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/notification-event/users/count" : { - "get" : { - "tags" : [ "kafka" ], - "summary" : "countUsers", - "description" : "Users' Count for single product", - "operationId" : "countUsersUsingGET", - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/ProductCountResponse" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/tokens" : { - "get" : { - "tags" : [ "Token" ], - "summary" : "Retrieve all token relationships", - "description" : "Retrieve all token relationships", - "operationId" : "getAllTokensUsingGET", - "parameters" : [ { - "name" : "states", - "in" : "query", - "description" : "Token relationship's status", - "required" : false, - "style" : "form", - "explode" : true, - "schema" : { - "type" : "string", - "enum" : [ "ACTIVE", "DELETED", "PENDING", "REJECTED", "SUSPENDED", "TOBEVALIDATED" ] - } - }, { - "name" : "page", - "in" : "query", - "description" : "Page number", - "required" : false, - "style" : "form", - "schema" : { - "type" : "integer", - "format" : "int32" - } - }, { - "name" : "size", - "in" : "query", - "description" : "Page size", - "required" : false, - "style" : "form", - "schema" : { - "type" : "integer", - "format" : "int32" - } - }, { - "name" : "productId", - "in" : "query", - "description" : "productId", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/PaginatedTokenResponse" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/tokens/products/{productId}" : { - "get" : { - "tags" : [ "Token", "external-v2" ], - "summary" : "Retrieve all token from a product", - "description" : "Retrieve all token from a product", - "operationId" : "findFromProductUsingGET_1", - "parameters" : [ { - "name" : "productId", - "in" : "path", - "description" : "Product's unique identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - }, { - "name" : "page", - "in" : "query", - "description" : "Page number", - "required" : false, - "style" : "form", - "schema" : { - "type" : "integer", - "format" : "int32" - } - }, { - "name" : "size", - "in" : "query", - "description" : "Page size", - "required" : false, - "style" : "form", - "schema" : { - "type" : "integer", - "format" : "int32" - } - } ], - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/TokenListResponse" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/tokens/token" : { - "get" : { - "tags" : [ "Token" ], - "summary" : "Retrieve token given the institution's and product ids", - "operationId" : "getTokenUsingGET", - "parameters" : [ { - "name" : "institutionId", - "in" : "query", - "description" : "Institution's unique internal identifier", - "required" : true, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "productId", - "in" : "query", - "description" : "Product's unique identifier", - "required" : true, - "style" : "form", - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/TokenResource" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/onboarded-users" : { - "get" : { - "tags" : [ "Persons" ], - "summary" : "Retrieve onboarded users according to identifiers in input", - "description" : "Retrieve onboarded users according to identifiers in input", - "operationId" : "getOnboardedUsersUsingGET", - "parameters" : [ { - "name" : "ids", - "in" : "query", - "description" : "Users unique identifiers", - "required" : true, - "style" : "form", - "explode" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "204" : { - "description" : "No Content", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/OnboardedUsersResponse" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/relationships/{relationshipId}" : { - "get" : { - "tags" : [ "Persons" ], - "summary" : "Gets the corresponding relationship", - "description" : "Gets the corresponding relationship", - "operationId" : "getRelationshipUsingGET", - "parameters" : [ { - "name" : "relationshipId", - "in" : "path", - "description" : "UserBinding's unique identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/RelationshipResult" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - }, - "delete" : { - "tags" : [ "Persons" ], - "summary" : "Given a relationship identifier, it deletes the corresponding relationship", - "description" : "Given a relationship identifier, it deletes the corresponding relationship", - "operationId" : "deleteRelationshipUsingDELETE", - "parameters" : [ { - "name" : "relationshipId", - "in" : "path", - "description" : "UserBinding's unique identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "204" : { - "description" : "No Content" - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "409" : { - "description" : "Conflict", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/relationships/{relationshipId}/activate" : { - "post" : { - "tags" : [ "Persons" ], - "summary" : "Activate the relationship", - "description" : "Activate the relationship", - "operationId" : "activateRelationshipUsingPOST", - "parameters" : [ { - "name" : "relationshipId", - "in" : "path", - "description" : "UserBinding's unique identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "204" : { - "description" : "No Content" - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "409" : { - "description" : "Conflict", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/relationships/{relationshipId}/suspend" : { - "post" : { - "tags" : [ "Persons" ], - "summary" : "Suspend the relationship", - "description" : "Suspend the relationship", - "operationId" : "suspendRelationshipUsingPOST", - "parameters" : [ { - "name" : "relationshipId", - "in" : "path", - "description" : "UserBinding's unique identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "204" : { - "description" : "No Content" - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "409" : { - "description" : "Conflict", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/users" : { - "get" : { - "tags" : [ "Persons" ], - "summary" : "getUsers", - "description" : "Retrieve all users according to optional params in input", - "operationId" : "getUsersUsingGET", - "parameters" : [ { - "name" : "size", - "in" : "query", - "description" : "size", - "required" : false, - "style" : "form", - "schema" : { - "type" : "integer", - "format" : "int32" - } - }, { - "name" : "page", - "in" : "query", - "description" : "page", - "required" : false, - "style" : "form", - "schema" : { - "type" : "integer", - "format" : "int32" - } - }, { - "name" : "productId", - "in" : "query", - "description" : "productId", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/UsersNotificationResponse" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/users/{id}" : { - "get" : { - "tags" : [ "Persons", "external-v2", "support" ], - "summary" : "Retrieves user given userId and optional ProductId", - "description" : "Retrieves user given userId and optional ProductId", - "operationId" : "getUserInfoUsingGET", - "parameters" : [ { - "name" : "id", - "in" : "path", - "description" : "User's unique identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - }, { - "name" : "productId", - "in" : "query", - "description" : "Product's unique identifier", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "institutionId", - "in" : "query", - "description" : "The internal identifier of the institution", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/UserResponse" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/users/{id}/status" : { - "put" : { - "tags" : [ "support" ], - "summary" : "Update user status with optional filter for institution, product, role and productRole", - "description" : "Update user status with optional filter for institution, product, role and productRole", - "operationId" : "updateUserStatusUsingPUT", - "parameters" : [ { - "name" : "id", - "in" : "path", - "description" : "User's unique identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - }, { - "name" : "institutionId", - "in" : "query", - "description" : "The internal identifier of the institution", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "productId", - "in" : "query", - "description" : "Product's unique identifier", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "role", - "in" : "query", - "description" : "role", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string", - "enum" : [ "DELEGATE", "MANAGER", "OPERATOR", "SUB_DELEGATE" ] - } - }, { - "name" : "productRole", - "in" : "query", - "description" : "productRole", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "status", - "in" : "query", - "description" : "status", - "required" : true, - "style" : "form", - "schema" : { - "type" : "string", - "enum" : [ "ACTIVE", "DELETED", "PENDING", "REJECTED", "SUSPENDED", "TOBEVALIDATED" ] - } - } ], - "responses" : { - "204" : { - "description" : "No Content" - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "403" : { - "description" : "Forbidden", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/users/{id}/update" : { - "post" : { - "tags" : [ "Persons" ], - "summary" : "Service to send notification when user data get's updated", - "description" : "Service to send notification when user data get's updated", - "operationId" : "updateUserUsingPOST", - "parameters" : [ { - "name" : "id", - "in" : "path", - "description" : "User's unique identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - }, { - "name" : "institutionId", - "in" : "query", - "description" : "The internal identifier of the institution", - "required" : true, - "style" : "form", - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "204" : { - "description" : "No Content" - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "409" : { - "description" : "Conflict", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/users/{userId}/institution-products" : { - "get" : { - "tags" : [ "Persons" ], - "summary" : "returns onboarding info", - "description" : "returns onboarding info", - "operationId" : "getInstitutionProductsInfoUsingGET", - "parameters" : [ { - "name" : "userId", - "in" : "path", - "description" : "UserBinding's unique identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - }, { - "name" : "institutionId", - "in" : "query", - "description" : "The internal identifier of the institution", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "states", - "in" : "query", - "description" : "List of Relationship state for filter products", - "required" : false, - "style" : "form", - "explode" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/OnboardingInfoResponse" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/users/{userId}/institutions/{institutionId}/products/{productId}" : { - "delete" : { - "tags" : [ "Persons" ], - "summary" : "Delete logically the association institution and product", - "description" : "Delete logically the association institution and product", - "operationId" : "deleteProductsUsingDELETE", - "parameters" : [ { - "name" : "userId", - "in" : "path", - "description" : "UserBinding's unique identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - }, { - "name" : "institutionId", - "in" : "path", - "description" : "The internal identifier of the institution", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - }, { - "name" : "productId", - "in" : "path", - "description" : "Product's unique identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "OK" - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "409" : { - "description" : "Conflict", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - }, - "/users/{userId}/products" : { - "get" : { - "tags" : [ "Persons" ], - "summary" : "Retrieves products info and role which the user is enabled", - "description" : "Retrieves products info and role which the user is enabled", - "operationId" : "getUserProductsInfoUsingGET", - "parameters" : [ { - "name" : "userId", - "in" : "path", - "description" : "UserBinding's unique identifier", - "required" : true, - "style" : "simple", - "schema" : { - "type" : "string" - } - }, { - "name" : "institutionId", - "in" : "query", - "description" : "The internal identifier of the institution", - "required" : false, - "style" : "form", - "schema" : { - "type" : "string" - } - }, { - "name" : "states", - "in" : "query", - "description" : "List of Relationship state for filter products", - "required" : false, - "style" : "form", - "explode" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "200" : { - "description" : "OK", - "content" : { - "*/*" : { - "schema" : { - "$ref" : "#/components/schemas/UserProductsResponse" - } - } - } - }, - "400" : { - "description" : "Bad Request", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - }, - "404" : { - "description" : "Not Found", - "content" : { - "application/problem+json" : { - "schema" : { - "$ref" : "#/components/schemas/Problem" - } - } - } - } - }, - "security" : [ { - "bearerAuth" : [ "global" ] - } ] - } - } - }, - "components" : { - "schemas" : { - "AdditionalInformations" : { - "title" : "AdditionalInformations", - "type" : "object", - "properties" : { - "agentOfPublicService" : { - "type" : "boolean" - }, - "agentOfPublicServiceNote" : { - "type" : "string" - }, - "belongRegulatedMarket" : { - "type" : "boolean" - }, - "establishedByRegulatoryProvision" : { - "type" : "boolean" - }, - "establishedByRegulatoryProvisionNote" : { - "type" : "string" - }, - "ipa" : { - "type" : "boolean" - }, - "ipaCode" : { - "type" : "string" - }, - "otherNote" : { - "type" : "string" - }, - "regulatedMarketNote" : { - "type" : "string" - } - } - }, - "AttributesRequest" : { - "title" : "AttributesRequest", - "type" : "object", - "properties" : { - "code" : { - "type" : "string" - }, - "description" : { - "type" : "string" - }, - "origin" : { - "type" : "string" - } - } - }, - "AttributesResponse" : { - "title" : "AttributesResponse", - "type" : "object", - "properties" : { - "code" : { - "type" : "string" - }, - "description" : { - "type" : "string" - }, - "origin" : { - "type" : "string" - } - } - }, - "Billing" : { - "title" : "Billing", - "type" : "object", - "properties" : { - "publicServices" : { - "type" : "boolean" - }, - "recipientCode" : { - "type" : "string" - }, - "vatNumber" : { - "type" : "string" - } - } - }, - "BillingRequest" : { - "title" : "BillingRequest", - "type" : "object", - "properties" : { - "publicServices" : { - "type" : "boolean" - }, - "recipientCode" : { - "type" : "string" - }, - "vatNumber" : { - "type" : "string" - } - } - }, - "BillingResponse" : { - "title" : "BillingResponse", - "type" : "object", - "properties" : { - "publicServices" : { - "type" : "boolean" - }, - "recipientCode" : { - "type" : "string" - }, - "vatNumber" : { - "type" : "string" - } - } - }, - "BrokerResponse" : { - "title" : "BrokerResponse", - "type" : "object", - "properties" : { - "description" : { - "type" : "string" - }, - "id" : { - "type" : "string" - }, - "numberOfDelegations" : { - "type" : "integer", - "format" : "int32" - }, - "taxCode" : { - "type" : "string" - } - } - }, - "BulkInstitution" : { - "title" : "BulkInstitution", - "type" : "object", - "properties" : { - "address" : { - "type" : "string" - }, - "attributes" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/AttributesResponse" - } - }, - "description" : { - "type" : "string" - }, - "digitalAddress" : { - "type" : "string" - }, - "externalId" : { - "type" : "string" - }, - "id" : { - "type" : "string" - }, - "institutionType" : { - "type" : "string", - "enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP" ] - }, - "origin" : { - "type" : "string" - }, - "originId" : { - "type" : "string" - }, - "products" : { - "type" : "object", - "additionalProperties" : { - "$ref" : "#/components/schemas/BulkProduct" - } - }, - "taxCode" : { - "type" : "string" - }, - "zipCode" : { - "type" : "string" - } - } - }, - "BulkInstitutions" : { - "title" : "BulkInstitutions", - "type" : "object", - "properties" : { - "found" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/BulkInstitution" - } - }, - "notFound" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } - }, - "BulkPartiesSeed" : { - "title" : "BulkPartiesSeed", - "type" : "object", - "properties" : { - "partyIdentifiers" : { - "type" : "array", - "items" : { - "type" : "string" - } - } - } - }, - "BulkProduct" : { - "title" : "BulkProduct", - "type" : "object", - "properties" : { - "billing" : { - "$ref" : "#/components/schemas/BillingResponse" - }, - "pricingPlan" : { - "type" : "string" - }, - "product" : { - "type" : "string" - }, - "status" : { - "type" : "string", - "enum" : [ "ACTIVE", "DELETED", "PENDING", "REJECTED", "SUSPENDED", "TOBEVALIDATED" ] - } - } - }, - "BusinessData" : { - "title" : "BusinessData", - "type" : "object", - "properties" : { - "businessRegisterPlace" : { - "type" : "string" - }, - "rea" : { - "type" : "string" - }, - "shareCapital" : { - "type" : "string" - } - } - }, - "Contract" : { - "title" : "Contract", - "type" : "object", - "properties" : { - "path" : { - "type" : "string" - }, - "version" : { - "type" : "string" - } - } - }, - "CreatePgInstitutionRequest" : { - "title" : "CreatePgInstitutionRequest", - "type" : "object", - "properties" : { - "description" : { - "type" : "string" - }, - "existsInRegistry" : { - "type" : "boolean" - }, - "taxId" : { - "type" : "string" - } - } - }, - "CreatePnPgInstitutionRequest" : { - "title" : "CreatePnPgInstitutionRequest", - "type" : "object", - "properties" : { - "description" : { - "type" : "string" - }, - "taxId" : { - "type" : "string" - } - } - }, - "CreatedAtRequest" : { - "title" : "CreatedAtRequest", - "type" : "object", - "properties" : { - "activatedAt" : { - "type" : "string", - "format" : "date-time" - }, - "createdAt" : { - "type" : "string", - "format" : "date-time" - }, - "productId" : { - "type" : "string" - } - } - }, - "DataProtectionOfficer" : { - "title" : "DataProtectionOfficer", - "type" : "object", - "properties" : { - "address" : { - "type" : "string" - }, - "email" : { - "type" : "string" - }, - "pec" : { - "type" : "string" - } - } - }, - "DataProtectionOfficerRequest" : { - "title" : "DataProtectionOfficerRequest", - "type" : "object", - "properties" : { - "address" : { - "type" : "string" - }, - "email" : { - "type" : "string" - }, - "pec" : { - "type" : "string" - } - } - }, - "DataProtectionOfficerResponse" : { - "title" : "DataProtectionOfficerResponse", - "type" : "object", - "properties" : { - "address" : { - "type" : "string" - }, - "email" : { - "type" : "string" - }, - "pec" : { - "type" : "string" - } - } - }, - "DelegationRequest" : { - "title" : "DelegationRequest", - "type" : "object", - "properties" : { - "createdAt" : { - "type" : "string", - "format" : "date-time" - }, - "from" : { - "type" : "string" - }, - "institutionFromName" : { - "type" : "string" - }, - "institutionToName" : { - "type" : "string" - }, - "productId" : { - "type" : "string" - }, - "status" : { - "type" : "string", - "enum" : [ "ACTIVE", "DELETED" ] - }, - "to" : { - "type" : "string" - }, - "type" : { - "type" : "string", - "enum" : [ "AOO", "PT" ] - }, - "updatedAt" : { - "type" : "string", - "format" : "date-time" - } - } - }, - "DelegationRequestFromTaxcode" : { - "title" : "DelegationRequestFromTaxcode", - "type" : "object", - "properties" : { - "createdAt" : { - "type" : "string", - "format" : "date-time" - }, - "fromSubunitCode" : { - "type" : "string" - }, - "fromTaxCode" : { - "type" : "string" - }, - "institutionFromName" : { - "type" : "string" - }, - "institutionToName" : { - "type" : "string" - }, - "productId" : { - "type" : "string" - }, - "status" : { - "type" : "string", - "enum" : [ "ACTIVE", "DELETED" ] - }, - "toSubunitCode" : { - "type" : "string" - }, - "toTaxCode" : { - "type" : "string" - }, - "type" : { - "type" : "string", - "enum" : [ "AOO", "PT" ] - }, - "updatedAt" : { - "type" : "string", - "format" : "date-time" - } - } - }, - "DelegationResponse" : { - "title" : "DelegationResponse", - "type" : "object", - "properties" : { - "brokerId" : { - "type" : "string" - }, - "brokerName" : { - "type" : "string" - }, - "brokerTaxCode" : { - "type" : "string" - }, - "brokerType" : { - "type" : "string" - }, - "createdAt" : { - "type" : "string", - "format" : "date-time" - }, - "id" : { - "type" : "string" - }, - "institutionId" : { - "type" : "string" - }, - "institutionName" : { - "type" : "string" - }, - "institutionRootName" : { - "type" : "string" - }, - "institutionType" : { - "type" : "string", - "enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP" ] - }, - "productId" : { - "type" : "string" - }, - "status" : { - "type" : "string", - "enum" : [ "ACTIVE", "DELETED" ] - }, - "taxCode" : { - "type" : "string" - }, - "type" : { - "type" : "string", - "enum" : [ "AOO", "PT" ] - }, - "updatedAt" : { - "type" : "string", - "format" : "date-time" - } - } - }, - "GeoTaxonomies" : { - "title" : "GeoTaxonomies", - "type" : "object", - "properties" : { - "code" : { - "type" : "string" - }, - "desc" : { - "type" : "string" - } - } - }, - "GeographicTaxonomies" : { - "title" : "GeographicTaxonomies", - "type" : "object", - "properties" : { - "code" : { - "type" : "string" - }, - "country" : { - "type" : "string" - }, - "country_abbreviation" : { - "type" : "string" - }, - "desc" : { - "type" : "string" - }, - "enabled" : { - "type" : "boolean" - }, - "istat_code" : { - "type" : "string" - }, - "province_abbreviation" : { - "type" : "string" - }, - "province_id" : { - "type" : "string" - }, - "region_id" : { - "type" : "string" - } - } - }, - "InstitutionBillingResponse" : { - "title" : "InstitutionBillingResponse", - "type" : "object", - "properties" : { - "address" : { - "type" : "string" - }, - "aooParentCode" : { - "type" : "string" - }, - "billing" : { - "$ref" : "#/components/schemas/BillingResponse" - }, - "description" : { - "type" : "string" - }, - "digitalAddress" : { - "type" : "string" - }, - "externalId" : { - "type" : "string" - }, - "institutionId" : { - "type" : "string" - }, - "institutionType" : { - "type" : "string", - "enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP" ] - }, - "origin" : { - "type" : "string", - "enum" : [ "ADE", "ANAC", "INFOCAMERE", "IPA", "IVASS", "MOCK", "SELC", "UNKNOWN" ] - }, - "originId" : { - "type" : "string" - }, - "pricingPlan" : { - "type" : "string" - }, - "subunitCode" : { - "type" : "string" - }, - "subunitType" : { - "type" : "string" - }, - "taxCode" : { - "type" : "string" - }, - "zipCode" : { - "type" : "string" - } - } - }, - "InstitutionFromIpaPost" : { - "title" : "InstitutionFromIpaPost", - "type" : "object", - "properties" : { - "geographicTaxonomies" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/GeoTaxonomies" - } - }, - "institutionType" : { - "type" : "string", - "enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP" ] - }, - "subunitCode" : { - "type" : "string" - }, - "subunitType" : { - "type" : "string", - "enum" : [ "AOO", "UO" ] - }, - "taxCode" : { - "type" : "string" - } - } - }, - "InstitutionGeographicTaxonomies" : { - "title" : "InstitutionGeographicTaxonomies", - "type" : "object", - "properties" : { - "code" : { - "type" : "string" - }, - "desc" : { - "type" : "string" - } - } - }, - "InstitutionManagerResponse" : { - "title" : "InstitutionManagerResponse", - "type" : "object", - "properties" : { - "billing" : { - "$ref" : "#/components/schemas/BillingResponse" - }, - "createdAt" : { - "type" : "string", - "format" : "date-time" - }, - "from" : { - "type" : "string" - }, - "id" : { - "type" : "string" - }, - "institutionUpdate" : { - "$ref" : "#/components/schemas/InstitutionUpdateResponse" - }, - "pricingPlan" : { - "type" : "string" - }, - "product" : { - "$ref" : "#/components/schemas/ProductInfo" - }, - "role" : { - "type" : "string" - }, - "state" : { - "type" : "string", - "enum" : [ "ACTIVE", "DELETED", "PENDING", "REJECTED", "SUSPENDED", "TOBEVALIDATED" ] - }, - "to" : { - "type" : "string" - }, - "updatedAt" : { - "type" : "string", - "format" : "date-time" - } - } - }, - "InstitutionOnboardingListResponse" : { - "title" : "InstitutionOnboardingListResponse", - "type" : "object", - "properties" : { - "items" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/InstitutionOnboardingResponse" - } - } - } - }, - "InstitutionOnboardingRequest" : { - "title" : "InstitutionOnboardingRequest", - "type" : "object", - "properties" : { - "activatedAt" : { - "type" : "string", - "format" : "date-time" - }, - "billing" : { - "$ref" : "#/components/schemas/BillingRequest" - }, - "contractPath" : { - "type" : "string" - }, - "pricingPlan" : { - "type" : "string" - }, - "productId" : { - "type" : "string" - }, - "tokenId" : { - "type" : "string" - }, - "users" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Person" - } - } - } - }, - "InstitutionOnboardingResponse" : { - "title" : "InstitutionOnboardingResponse", - "type" : "object", - "properties" : { - "address" : { - "type" : "string" - }, - "aooParentCode" : { - "type" : "string" - }, - "attributes" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/AttributesResponse" - } - }, - "businessRegisterPlace" : { - "type" : "string" - }, - "createdAt" : { - "type" : "string", - "format" : "date-time" - }, - "dataProtectionOfficer" : { - "$ref" : "#/components/schemas/DataProtectionOfficerResponse" - }, - "description" : { - "type" : "string" - }, - "digitalAddress" : { - "type" : "string" - }, - "externalId" : { - "type" : "string" - }, - "geographicTaxonomies" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/GeoTaxonomies" - } - }, - "id" : { - "type" : "string" - }, - "imported" : { + "belongRegulatedMarket" : { "type" : "boolean" }, - "institutionType" : { - "type" : "string", - "enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP" ] - }, - "onboardings" : { - "type" : "object", - "additionalProperties" : { - "$ref" : "#/components/schemas/OnboardingResponse" - } - }, - "origin" : { - "type" : "string" - }, - "originId" : { - "type" : "string" - }, - "paymentServiceProvider" : { - "$ref" : "#/components/schemas/PaymentServiceProviderResponse" - }, - "rea" : { - "type" : "string" - }, - "shareCapital" : { - "type" : "string" - }, - "subunitCode" : { - "type" : "string" - }, - "subunitType" : { - "type" : "string" + "establishedByRegulatoryProvision" : { + "type" : "boolean" }, - "supportEmail" : { + "establishedByRegulatoryProvisionNote" : { "type" : "string" }, - "supportPhone" : { - "type" : "string" + "ipa" : { + "type" : "boolean" }, - "taxCode" : { + "ipaCode" : { "type" : "string" }, - "updatedAt" : { - "type" : "string", - "format" : "date-time" + "otherNote" : { + "type" : "string" }, - "zipCode" : { + "regulatedMarketNote" : { "type" : "string" } } }, - "InstitutionPnPgResponse" : { - "title" : "InstitutionPnPgResponse", + "AttributesRequest" : { + "title" : "AttributesRequest", "type" : "object", "properties" : { - "id" : { + "code" : { "type" : "string" - } - } - }, - "InstitutionProduct" : { - "title" : "InstitutionProduct", - "type" : "object", - "properties" : { - "id" : { + }, + "description" : { "type" : "string" }, - "state" : { - "type" : "string", - "enum" : [ "ACTIVE", "DELETED", "PENDING", "REJECTED", "SUSPENDED", "TOBEVALIDATED" ] + "origin" : { + "type" : "string" } } }, - "InstitutionProducts" : { - "title" : "InstitutionProducts", + "AttributesResponse" : { + "title" : "AttributesResponse", "type" : "object", "properties" : { - "institutionId" : { + "code" : { "type" : "string" }, - "institutionName" : { + "description" : { "type" : "string" }, - "institutionRootName" : { + "origin" : { "type" : "string" - }, - "products" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Product" - } } } }, - "InstitutionPut" : { - "title" : "InstitutionPut", + "Billing" : { + "title" : "Billing", "type" : "object", "properties" : { - "description" : { - "type" : "string" + "publicServices" : { + "type" : "boolean" }, - "digitalAddress" : { + "recipientCode" : { "type" : "string" }, - "geographicTaxonomyCodes" : { - "type" : "array", - "items" : { - "type" : "string" - } + "vatNumber" : { + "type" : "string" } } }, - "InstitutionRequest" : { - "title" : "InstitutionRequest", + "BillingRequest" : { + "title" : "BillingRequest", "type" : "object", "properties" : { - "address" : { - "type" : "string" - }, - "attributes" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/AttributesRequest" - } - }, - "billing" : { - "$ref" : "#/components/schemas/BillingRequest" - }, - "businessRegisterPlace" : { - "type" : "string" - }, - "city" : { - "type" : "string" - }, - "country" : { - "type" : "string" - }, - "county" : { - "type" : "string" - }, - "createdAt" : { - "type" : "string", - "format" : "date-time" - }, - "dataProtectionOfficer" : { - "$ref" : "#/components/schemas/DataProtectionOfficerRequest" - }, - "delegation" : { - "type" : "boolean" - }, - "description" : { - "type" : "string" - }, - "digitalAddress" : { - "type" : "string" - }, - "externalId" : { - "type" : "string" - }, - "geographicTaxonomies" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/GeoTaxonomies" - } - }, - "id" : { - "type" : "string" - }, - "imported" : { + "publicServices" : { "type" : "boolean" }, - "institutionType" : { - "type" : "string", - "enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP" ] - }, - "onboarding" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/OnboardingRequest" - } - }, - "origin" : { - "type" : "string" - }, - "originId" : { - "type" : "string" - }, - "paymentServiceProvider" : { - "$ref" : "#/components/schemas/PaymentServiceProviderRequest" - }, - "rea" : { - "type" : "string" - }, - "shareCapital" : { - "type" : "string" - }, - "supportEmail" : { - "type" : "string" - }, - "supportPhone" : { - "type" : "string" - }, - "taxCode" : { + "recipientCode" : { "type" : "string" }, - "updatedAt" : { - "type" : "string", - "format" : "date-time" - }, - "zipCode" : { + "vatNumber" : { "type" : "string" } } }, - "InstitutionResponse" : { - "title" : "InstitutionResponse", + "BillingResponse" : { + "title" : "BillingResponse", "type" : "object", "properties" : { - "address" : { - "type" : "string" - }, - "aooParentCode" : { - "type" : "string" - }, - "attributes" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/AttributesResponse" - } - }, - "businessRegisterPlace" : { - "type" : "string" - }, - "city" : { - "type" : "string" - }, - "country" : { - "type" : "string" - }, - "county" : { - "type" : "string" - }, - "createdAt" : { - "type" : "string", - "format" : "date-time" - }, - "dataProtectionOfficer" : { - "$ref" : "#/components/schemas/DataProtectionOfficerResponse" - }, - "delegation" : { - "type" : "boolean" - }, - "description" : { - "type" : "string" - }, - "digitalAddress" : { - "type" : "string" - }, - "externalId" : { - "type" : "string" - }, - "geographicTaxonomies" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/GeoTaxonomies" - } - }, - "id" : { - "type" : "string" - }, - "imported" : { + "publicServices" : { "type" : "boolean" }, - "institutionType" : { - "type" : "string", - "enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP" ] - }, - "onboarding" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/OnboardedProductResponse" - } - }, - "origin" : { - "type" : "string" - }, - "originId" : { - "type" : "string" - }, - "paymentServiceProvider" : { - "$ref" : "#/components/schemas/PaymentServiceProviderResponse" - }, - "rea" : { - "type" : "string" - }, - "rootParent" : { - "$ref" : "#/components/schemas/RootParentResponse" - }, - "shareCapital" : { - "type" : "string" - }, - "subunitCode" : { - "type" : "string" - }, - "subunitType" : { + "recipientCode" : { "type" : "string" }, - "supportEmail" : { + "vatNumber" : { "type" : "string" - }, - "supportPhone" : { + } + } + }, + "BrokerResponse" : { + "title" : "BrokerResponse", + "type" : "object", + "properties" : { + "description" : { "type" : "string" }, - "taxCode" : { + "id" : { "type" : "string" }, - "updatedAt" : { - "type" : "string", - "format" : "date-time" + "numberOfDelegations" : { + "type" : "integer", + "format" : "int32" }, - "zipCode" : { + "taxCode" : { "type" : "string" } } }, - "InstitutionToNotifyResponse" : { - "title" : "InstitutionToNotifyResponse", + "BulkInstitution" : { + "title" : "BulkInstitution", "type" : "object", "properties" : { "address" : { "type" : "string" }, - "category" : { - "type" : "string" - }, - "city" : { - "type" : "string" + "attributes" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/AttributesResponse" + } }, - "country" : { + "description" : { "type" : "string" }, - "county" : { + "digitalAddress" : { "type" : "string" }, - "description" : { + "externalId" : { "type" : "string" }, - "digitalAddress" : { + "id" : { "type" : "string" }, "institutionType" : { "type" : "string", "enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP" ] }, - "istatCode" : { - "type" : "string" - }, "origin" : { "type" : "string" }, "originId" : { "type" : "string" }, - "paymentServiceProvider" : { - "$ref" : "#/components/schemas/PaymentServiceProvider" - }, - "rootParent" : { - "$ref" : "#/components/schemas/RootParent" - }, - "subUnitCode" : { - "type" : "string" - }, - "subUnitType" : { - "type" : "string" + "products" : { + "type" : "object", + "additionalProperties" : { + "$ref" : "#/components/schemas/BulkProduct" + } }, "taxCode" : { "type" : "string" @@ -5455,198 +2655,330 @@ } } }, - "InstitutionToOnboard" : { - "title" : "InstitutionToOnboard", + "BulkInstitutions" : { + "title" : "BulkInstitutions", "type" : "object", "properties" : { - "cfImpresa" : { - "type" : "string" + "found" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/BulkInstitution" + } }, - "denominazione" : { - "type" : "string" + "notFound" : { + "type" : "array", + "items" : { + "type" : "string" + } } } }, - "InstitutionUpdate" : { - "title" : "InstitutionUpdate", + "BulkPartiesSeed" : { + "title" : "BulkPartiesSeed", "type" : "object", "properties" : { - "additionalInformations" : { - "$ref" : "#/components/schemas/AdditionalInformations" + "partyIdentifiers" : { + "type" : "array", + "items" : { + "type" : "string" + } + } + } + }, + "BulkProduct" : { + "title" : "BulkProduct", + "type" : "object", + "properties" : { + "billing" : { + "$ref" : "#/components/schemas/BillingResponse" }, - "address" : { + "pricingPlan" : { "type" : "string" }, - "businessRegisterPlace" : { + "product" : { "type" : "string" }, - "city" : { + "status" : { + "type" : "string", + "enum" : [ "ACTIVE", "DELETED", "PENDING", "REJECTED", "SUSPENDED", "TOBEVALIDATED" ] + } + } + }, + "Contract" : { + "title" : "Contract", + "type" : "object", + "properties" : { + "path" : { "type" : "string" }, - "country" : { + "version" : { "type" : "string" - }, - "county" : { + } + } + }, + "CreatePgInstitutionRequest" : { + "title" : "CreatePgInstitutionRequest", + "type" : "object", + "properties" : { + "description" : { "type" : "string" }, - "dataProtectionOfficer" : { - "$ref" : "#/components/schemas/DataProtectionOfficer" - }, - "delegation" : { + "existsInRegistry" : { "type" : "boolean" }, + "taxId" : { + "type" : "string" + } + } + }, + "CreatePnPgInstitutionRequest" : { + "title" : "CreatePnPgInstitutionRequest", + "type" : "object", + "properties" : { "description" : { "type" : "string" }, - "digitalAddress" : { + "taxId" : { "type" : "string" + } + } + }, + "CreatedAtRequest" : { + "title" : "CreatedAtRequest", + "type" : "object", + "properties" : { + "activatedAt" : { + "type" : "string", + "format" : "date-time" }, - "geographicTaxonomies" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/InstitutionGeographicTaxonomies" - } + "createdAt" : { + "type" : "string", + "format" : "date-time" }, - "imported" : { - "type" : "boolean" + "productId" : { + "type" : "string" + } + } + }, + "DataProtectionOfficer" : { + "title" : "DataProtectionOfficer", + "type" : "object", + "properties" : { + "address" : { + "type" : "string" }, - "institutionType" : { - "type" : "string", - "enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP" ] + "email" : { + "type" : "string" }, - "ivassCode" : { + "pec" : { + "type" : "string" + } + } + }, + "DataProtectionOfficerRequest" : { + "title" : "DataProtectionOfficerRequest", + "type" : "object", + "properties" : { + "address" : { "type" : "string" }, - "paymentServiceProvider" : { - "$ref" : "#/components/schemas/PaymentServiceProvider" + "email" : { + "type" : "string" }, - "rea" : { + "pec" : { + "type" : "string" + } + } + }, + "DataProtectionOfficerResponse" : { + "title" : "DataProtectionOfficerResponse", + "type" : "object", + "properties" : { + "address" : { "type" : "string" }, - "shareCapital" : { + "email" : { "type" : "string" }, - "supportEmail" : { + "pec" : { + "type" : "string" + } + } + }, + "DelegationRequest" : { + "title" : "DelegationRequest", + "type" : "object", + "properties" : { + "from" : { "type" : "string" }, - "supportPhone" : { + "institutionFromName" : { "type" : "string" }, - "taxCode" : { + "institutionToName" : { "type" : "string" }, - "zipCode" : { + "productId" : { + "type" : "string" + }, + "to" : { "type" : "string" + }, + "type" : { + "type" : "string", + "enum" : [ "AOO", "PT" ] } } }, - "InstitutionUpdateResponse" : { - "title" : "InstitutionUpdateResponse", + "DelegationRequestFromTaxcode" : { + "title" : "DelegationRequestFromTaxcode", "type" : "object", "properties" : { - "address" : { + "fromSubunitCode" : { "type" : "string" }, - "aooParentCode" : { + "fromTaxCode" : { "type" : "string" }, - "businessRegisterPlace" : { + "institutionFromName" : { "type" : "string" }, - "city" : { + "institutionToName" : { "type" : "string" }, - "country" : { + "productId" : { + "type" : "string" + }, + "toSubunitCode" : { + "type" : "string" + }, + "toTaxCode" : { + "type" : "string" + }, + "type" : { + "type" : "string", + "enum" : [ "AOO", "PT" ] + } + } + }, + "DelegationResponse" : { + "title" : "DelegationResponse", + "type" : "object", + "properties" : { + "brokerId" : { "type" : "string" }, - "county" : { + "brokerName" : { "type" : "string" }, - "dataProtectionOfficer" : { - "$ref" : "#/components/schemas/DataProtectionOfficerResponse" - }, - "description" : { + "brokerTaxCode" : { "type" : "string" }, - "digitalAddress" : { + "brokerType" : { "type" : "string" }, - "geographicTaxonomyCodes" : { - "type" : "array", - "items" : { - "type" : "string" - } - }, - "imported" : { - "type" : "boolean" - }, - "institutionType" : { + "createdAt" : { "type" : "string", - "enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP" ] - }, - "paymentServiceProvider" : { - "$ref" : "#/components/schemas/PaymentServiceProviderResponse" + "format" : "date-time" }, - "rea" : { + "id" : { "type" : "string" }, - "shareCapital" : { + "institutionId" : { "type" : "string" }, - "subunitCode" : { + "institutionName" : { "type" : "string" }, - "subunitType" : { + "institutionRootName" : { "type" : "string" }, - "supportEmail" : { - "type" : "string" + "institutionType" : { + "type" : "string", + "enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP" ] }, - "supportPhone" : { + "productId" : { "type" : "string" }, + "status" : { + "type" : "string", + "enum" : [ "ACTIVE", "DELETED" ] + }, "taxCode" : { "type" : "string" }, - "zipCode" : { - "type" : "string" + "type" : { + "type" : "string", + "enum" : [ "AOO", "PT" ] + }, + "updatedAt" : { + "type" : "string", + "format" : "date-time" } } }, - "InstitutionsResponse" : { - "title" : "InstitutionsResponse", + "DelegationWithPaginationResponse" : { + "title" : "DelegationWithPaginationResponse", "type" : "object", "properties" : { - "institutions" : { + "delegations" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/InstitutionResponse" + "$ref" : "#/components/schemas/DelegationResponse" } + }, + "pageInfo" : { + "$ref" : "#/components/schemas/PageInfo" } } }, - "LegalsResponse" : { - "title" : "LegalsResponse", + "GeoTaxonomies" : { + "title" : "GeoTaxonomies", "type" : "object", "properties" : { - "env" : { - "type" : "string", - "enum" : [ "COLL", "DEV", "PROD", "ROOT" ] + "code" : { + "type" : "string" }, - "partyId" : { + "desc" : { + "type" : "string" + } + } + }, + "GeographicTaxonomies" : { + "title" : "GeographicTaxonomies", + "type" : "object", + "properties" : { + "code" : { "type" : "string" }, - "relationshipId" : { + "country" : { "type" : "string" }, - "role" : { - "type" : "string", - "enum" : [ "DELEGATE", "MANAGER", "OPERATOR", "SUB_DELEGATE" ] + "country_abbreviation" : { + "type" : "string" + }, + "desc" : { + "type" : "string" + }, + "enabled" : { + "type" : "boolean" + }, + "istat_code" : { + "type" : "string" + }, + "province_abbreviation" : { + "type" : "string" + }, + "province_id" : { + "type" : "string" + }, + "region_id" : { + "type" : "string" } } }, - "OnboardedInstitutionResponse" : { - "title" : "OnboardedInstitutionResponse", + "InstitutionBillingResponse" : { + "title" : "InstitutionBillingResponse", "type" : "object", "properties" : { "address" : { @@ -5655,20 +2987,8 @@ "aooParentCode" : { "type" : "string" }, - "attributes" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/AttributesResponse" - } - }, "billing" : { - "$ref" : "#/components/schemas/Billing" - }, - "businessData" : { - "$ref" : "#/components/schemas/BusinessData" - }, - "dataProtectionOfficer" : { - "$ref" : "#/components/schemas/DataProtectionOfficerResponse" + "$ref" : "#/components/schemas/BillingResponse" }, "description" : { "type" : "string" @@ -5679,13 +2999,7 @@ "externalId" : { "type" : "string" }, - "geographicTaxonomies" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/GeoTaxonomies" - } - }, - "id" : { + "institutionId" : { "type" : "string" }, "institutionType" : { @@ -5693,42 +3007,21 @@ "enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP" ] }, "origin" : { - "type" : "string" + "type" : "string", + "enum" : [ "ADE", "ANAC", "INFOCAMERE", "IPA", "IVASS", "MOCK", "SELC", "UNKNOWN" ] }, "originId" : { "type" : "string" }, - "parentDescription" : { - "type" : "string" - }, - "paymentServiceProvider" : { - "$ref" : "#/components/schemas/PaymentServiceProviderResponse" - }, "pricingPlan" : { "type" : "string" }, - "productInfo" : { - "$ref" : "#/components/schemas/ProductInfo" - }, - "role" : { - "type" : "string", - "enum" : [ "DELEGATE", "MANAGER", "OPERATOR", "SUB_DELEGATE" ] - }, - "rootParentId" : { - "type" : "string" - }, - "state" : { - "type" : "string" - }, "subunitCode" : { "type" : "string" }, "subunitType" : { "type" : "string" }, - "supportContact" : { - "$ref" : "#/components/schemas/SupportContact" - }, "taxCode" : { "type" : "string" }, @@ -5737,146 +3030,78 @@ } } }, - "OnboardedProduct" : { - "title" : "OnboardedProduct", + "InstitutionFromIpaPost" : { + "title" : "InstitutionFromIpaPost", "type" : "object", "properties" : { - "contract" : { - "type" : "string" - }, - "createdAt" : { - "type" : "string", - "format" : "date-time" + "geographicTaxonomies" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/GeoTaxonomies" + } }, - "env" : { + "institutionType" : { "type" : "string", - "enum" : [ "COLL", "DEV", "PROD", "ROOT" ] - }, - "productId" : { - "type" : "string" - }, - "productRole" : { - "type" : "string" + "enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP" ] }, - "relationshipId" : { + "subunitCode" : { "type" : "string" }, - "role" : { - "type" : "string", - "enum" : [ "DELEGATE", "MANAGER", "OPERATOR", "SUB_DELEGATE" ] - }, - "status" : { + "subunitType" : { "type" : "string", - "enum" : [ "ACTIVE", "DELETED", "PENDING", "REJECTED", "SUSPENDED", "TOBEVALIDATED" ] + "enum" : [ "AOO", "UO" ] }, - "tokenId" : { + "taxCode" : { "type" : "string" - }, - "updatedAt" : { - "type" : "string", - "format" : "date-time" } } }, - "OnboardedProductResponse" : { - "title" : "OnboardedProductResponse", + "InstitutionGeographicTaxonomies" : { + "title" : "InstitutionGeographicTaxonomies", "type" : "object", "properties" : { - "billing" : { - "$ref" : "#/components/schemas/BillingResponse" - }, - "createdAt" : { - "type" : "string", - "format" : "date-time" - }, - "productId" : { + "code" : { "type" : "string" }, - "status" : { - "type" : "string", - "enum" : [ "ACTIVE", "DELETED", "PENDING", "REJECTED", "SUSPENDED", "TOBEVALIDATED" ] - }, - "updatedAt" : { - "type" : "string", - "format" : "date-time" - } - } - }, - "OnboardedProducts" : { - "title" : "OnboardedProducts", - "type" : "object", - "properties" : { - "products" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/InstitutionProduct" - } - } - } - }, - "OnboardedUsersResponse" : { - "title" : "OnboardedUsersResponse", - "type" : "object", - "properties" : { - "users" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/UserProductsResponse" - } + "desc" : { + "type" : "string" } } }, - "OnboardingInfoResponse" : { - "title" : "OnboardingInfoResponse", + "InstitutionOnboardingListResponse" : { + "title" : "InstitutionOnboardingListResponse", "type" : "object", "properties" : { - "institutions" : { + "items" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/OnboardedInstitutionResponse" + "$ref" : "#/components/schemas/InstitutionOnboardingResponse" } - }, - "userId" : { - "type" : "string" } } }, - "OnboardingInstitutionOperatorsRequest" : { - "title" : "OnboardingInstitutionOperatorsRequest", + "InstitutionOnboardingRequest" : { + "title" : "InstitutionOnboardingRequest", "type" : "object", "properties" : { - "institutionId" : { - "type" : "string" - }, - "productId" : { - "type" : "string" + "activatedAt" : { + "type" : "string", + "format" : "date-time" }, - "productTitle" : { - "type" : "string" + "billing" : { + "$ref" : "#/components/schemas/BillingRequest" }, - "users" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/Person" - } - } - } - }, - "OnboardingInstitutionUsersRequest" : { - "title" : "OnboardingInstitutionUsersRequest", - "type" : "object", - "properties" : { - "institutionSubunitCode" : { + "contractPath" : { "type" : "string" }, - "institutionTaxCode" : { + "pricingPlan" : { "type" : "string" }, "productId" : { "type" : "string" }, - "sendCreateUserNotificationEmail" : { - "type" : "boolean" + "tokenId" : { + "type" : "string" }, "users" : { "type" : "array", @@ -5886,472 +3111,472 @@ } } }, - "OnboardingRequest" : { - "title" : "OnboardingRequest", + "InstitutionOnboardingResponse" : { + "title" : "InstitutionOnboardingResponse", "type" : "object", "properties" : { - "billingRequest" : { - "$ref" : "#/components/schemas/Billing" + "address" : { + "type" : "string" }, - "contract" : { - "$ref" : "#/components/schemas/Contract" + "aooParentCode" : { + "type" : "string" }, - "contractActivatedAt" : { - "type" : "string", - "format" : "date-time" + "attributes" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/AttributesResponse" + } }, - "contractCreatedAt" : { + "businessRegisterPlace" : { + "type" : "string" + }, + "createdAt" : { "type" : "string", "format" : "date-time" }, - "contractFilePath" : { - "type" : "string" + "dataProtectionOfficer" : { + "$ref" : "#/components/schemas/DataProtectionOfficerResponse" }, - "institutionExternalId" : { + "description" : { "type" : "string" }, - "institutionUpdate" : { - "$ref" : "#/components/schemas/InstitutionUpdate" - }, - "pricingPlan" : { + "digitalAddress" : { "type" : "string" }, - "productId" : { + "externalId" : { "type" : "string" }, - "productName" : { - "type" : "string" + "geographicTaxonomies" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/GeoTaxonomies" + } }, - "sendCompleteOnboardingEmail" : { - "type" : "boolean" + "id" : { + "type" : "string" }, - "signContract" : { + "imported" : { "type" : "boolean" }, - "tokenType" : { + "institutionType" : { "type" : "string", - "enum" : [ "INSTITUTION", "LEGALS" ] + "enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP" ] }, - "users" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/UserToOnboard" + "onboardings" : { + "type" : "object", + "additionalProperties" : { + "$ref" : "#/components/schemas/OnboardingResponse" } - } - } - }, - "OnboardingResponse" : { - "title" : "OnboardingResponse", - "type" : "object", - "properties" : { - "billing" : { - "$ref" : "#/components/schemas/BillingResponse" }, - "closedAt" : { - "type" : "string", - "format" : "date-time" + "origin" : { + "type" : "string" }, - "contract" : { + "originId" : { "type" : "string" }, - "createdAt" : { - "type" : "string", - "format" : "date-time" + "paymentServiceProvider" : { + "$ref" : "#/components/schemas/PaymentServiceProviderResponse" }, - "pricingPlan" : { + "rea" : { "type" : "string" }, - "productId" : { + "shareCapital" : { "type" : "string" }, - "status" : { - "type" : "string", - "enum" : [ "ACTIVE", "DELETED", "PENDING", "REJECTED", "SUSPENDED", "TOBEVALIDATED" ] + "subunitCode" : { + "type" : "string" }, - "tokenId" : { + "subunitType" : { + "type" : "string" + }, + "supportEmail" : { + "type" : "string" + }, + "supportPhone" : { + "type" : "string" + }, + "taxCode" : { "type" : "string" }, "updatedAt" : { "type" : "string", "format" : "date-time" + }, + "zipCode" : { + "type" : "string" } } }, - "OnboardingsResponse" : { - "title" : "OnboardingsResponse", + "InstitutionPnPgResponse" : { + "title" : "InstitutionPnPgResponse", "type" : "object", "properties" : { - "onboardings" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/OnboardingResponse" - } + "id" : { + "type" : "string" } } }, - "PaginatedTokenResponse" : { - "title" : "PaginatedTokenResponse", + "InstitutionProduct" : { + "title" : "InstitutionProduct", "type" : "object", "properties" : { - "items" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/ScContractResponse" - } + "id" : { + "type" : "string" + }, + "state" : { + "type" : "string", + "enum" : [ "ACTIVE", "DELETED", "PENDING", "REJECTED", "SUSPENDED", "TOBEVALIDATED" ] } } }, - "PaymentServiceProvider" : { - "title" : "PaymentServiceProvider", + "InstitutionPut" : { + "title" : "InstitutionPut", "type" : "object", "properties" : { - "abiCode" : { - "type" : "string" - }, - "businessRegisterNumber" : { - "type" : "string" - }, - "legalRegisterName" : { + "description" : { "type" : "string" }, - "legalRegisterNumber" : { + "digitalAddress" : { "type" : "string" }, - "vatNumberGroup" : { - "type" : "boolean" + "geographicTaxonomyCodes" : { + "type" : "array", + "items" : { + "type" : "string" + } } } }, - "PaymentServiceProviderRequest" : { - "title" : "PaymentServiceProviderRequest", + "InstitutionRequest" : { + "title" : "InstitutionRequest", "type" : "object", "properties" : { - "abiCode" : { + "address" : { "type" : "string" }, - "businessRegisterNumber" : { - "type" : "string" + "attributes" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/AttributesRequest" + } }, - "legalRegisterName" : { - "type" : "string" + "billing" : { + "$ref" : "#/components/schemas/BillingRequest" }, - "legalRegisterNumber" : { + "businessRegisterPlace" : { "type" : "string" }, - "vatNumberGroup" : { - "type" : "boolean" - } - } - }, - "PaymentServiceProviderResponse" : { - "title" : "PaymentServiceProviderResponse", - "type" : "object", - "properties" : { - "abiCode" : { + "city" : { "type" : "string" }, - "businessRegisterNumber" : { + "country" : { "type" : "string" }, - "legalRegisterName" : { + "county" : { "type" : "string" }, - "legalRegisterNumber" : { - "type" : "string" + "createdAt" : { + "type" : "string", + "format" : "date-time" }, - "vatNumberGroup" : { + "dataProtectionOfficer" : { + "$ref" : "#/components/schemas/DataProtectionOfficerRequest" + }, + "delegation" : { "type" : "boolean" - } - } - }, - "PdaInstitutionRequest" : { - "title" : "PdaInstitutionRequest", - "type" : "object", - "properties" : { - "billing" : { - "$ref" : "#/components/schemas/BillingRequest" }, "description" : { "type" : "string" }, - "injectionInstitutionType" : { + "digitalAddress" : { "type" : "string" }, - "taxCode" : { + "externalId" : { "type" : "string" - } - } - }, - "Person" : { - "title" : "Person", - "type" : "object", - "properties" : { - "email" : { + }, + "geographicTaxonomies" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/GeoTaxonomies" + } + }, + "id" : { "type" : "string" }, - "env" : { + "imported" : { + "type" : "boolean" + }, + "institutionType" : { "type" : "string", - "enum" : [ "COLL", "DEV", "PROD", "ROOT" ] + "enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP" ] }, - "id" : { + "onboarding" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/OnboardingRequest" + } + }, + "origin" : { "type" : "string" }, - "name" : { + "originId" : { "type" : "string" }, - "productRole" : { + "paymentServiceProvider" : { + "$ref" : "#/components/schemas/PaymentServiceProviderRequest" + }, + "rea" : { "type" : "string" }, - "role" : { - "type" : "string", - "enum" : [ "DELEGATE", "MANAGER", "OPERATOR", "SUB_DELEGATE" ] + "shareCapital" : { + "type" : "string" }, - "roleLabel" : { + "supportEmail" : { "type" : "string" }, - "surname" : { + "supportPhone" : { "type" : "string" }, "taxCode" : { "type" : "string" + }, + "updatedAt" : { + "type" : "string", + "format" : "date-time" + }, + "zipCode" : { + "type" : "string" } } }, - "Problem" : { - "title" : "Problem", + "InstitutionResponse" : { + "title" : "InstitutionResponse", "type" : "object", "properties" : { - "errors" : { + "address" : { + "type" : "string" + }, + "aooParentCode" : { + "type" : "string" + }, + "attributes" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/ProblemError" + "$ref" : "#/components/schemas/AttributesResponse" } }, - "status" : { - "type" : "integer", - "format" : "int32" - } - } - }, - "ProblemError" : { - "title" : "ProblemError", - "type" : "object" - }, - "Product" : { - "title" : "Product", - "type" : "object", - "properties" : { - "contract" : { + "businessRegisterPlace" : { + "type" : "string" + }, + "city" : { + "type" : "string" + }, + "country" : { + "type" : "string" + }, + "county" : { "type" : "string" }, "createdAt" : { "type" : "string", "format" : "date-time" }, - "env" : { - "type" : "string", - "enum" : [ "COLL", "DEV", "PROD", "ROOT" ] + "dataProtectionOfficer" : { + "$ref" : "#/components/schemas/DataProtectionOfficerResponse" }, - "productId" : { + "delegation" : { + "type" : "boolean" + }, + "description" : { "type" : "string" }, - "productRole" : { + "digitalAddress" : { "type" : "string" }, - "role" : { - "type" : "string", - "enum" : [ "DELEGATE", "MANAGER", "OPERATOR", "SUB_DELEGATE" ] + "externalId" : { + "type" : "string" }, - "status" : { - "type" : "string", - "enum" : [ "ACTIVE", "DELETED", "PENDING", "REJECTED", "SUSPENDED", "TOBEVALIDATED" ] + "geographicTaxonomies" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/GeoTaxonomies" + } }, - "tokenId" : { + "id" : { "type" : "string" }, - "updatedAt" : { + "imported" : { + "type" : "boolean" + }, + "institutionType" : { "type" : "string", - "format" : "date-time" - } - } - }, - "ProductCount" : { - "title" : "ProductCount", - "type" : "object", - "properties" : { - "count" : { - "type" : "integer", - "format" : "int32" + "enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP" ] }, - "productId" : { - "type" : "string" - } - } - }, - "ProductCountResponse" : { - "title" : "ProductCountResponse", - "type" : "object", - "properties" : { - "products" : { + "onboarding" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/ProductCount" + "$ref" : "#/components/schemas/OnboardedProductResponse" } - } - } - }, - "ProductInfo" : { - "title" : "ProductInfo", - "type" : "object", - "properties" : { - "createdAt" : { - "type" : "string", - "format" : "date-time" }, - "id" : { + "origin" : { "type" : "string" }, - "role" : { + "originId" : { "type" : "string" }, - "status" : { + "paymentServiceProvider" : { + "$ref" : "#/components/schemas/PaymentServiceProviderResponse" + }, + "rea" : { "type" : "string" - } - } - }, - "RelationshipResult" : { - "title" : "RelationshipResult", - "type" : "object", - "properties" : { - "billing" : { - "$ref" : "#/components/schemas/BillingResponse" }, - "createdAt" : { - "type" : "string", - "format" : "date-time" + "rootParent" : { + "$ref" : "#/components/schemas/RootParentResponse" }, - "from" : { + "shareCapital" : { "type" : "string" }, - "id" : { + "subunitCode" : { "type" : "string" }, - "institutionUpdate" : { - "$ref" : "#/components/schemas/InstitutionUpdateResponse" - }, - "pricingPlan" : { + "subunitType" : { "type" : "string" }, - "product" : { - "$ref" : "#/components/schemas/ProductInfo" - }, - "role" : { - "type" : "string", - "enum" : [ "DELEGATE", "MANAGER", "OPERATOR", "SUB_DELEGATE" ] + "supportEmail" : { + "type" : "string" }, - "state" : { - "type" : "string", - "enum" : [ "ACTIVE", "DELETED", "PENDING", "REJECTED", "SUSPENDED", "TOBEVALIDATED" ] + "supportPhone" : { + "type" : "string" }, - "to" : { + "taxCode" : { "type" : "string" }, - "tokenId" : { + "taxCodeSfe" : { "type" : "string" }, "updatedAt" : { "type" : "string", "format" : "date-time" + }, + "zipCode" : { + "type" : "string" } } }, - "RelationshipsManagement" : { - "title" : "RelationshipsManagement", + "InstitutionToOnboard" : { + "title" : "InstitutionToOnboard", "type" : "object", "properties" : { - "items" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/RelationshipResult" - } + "cfImpresa" : { + "type" : "string" + }, + "denominazione" : { + "type" : "string" } } }, - "RootParent" : { - "title" : "RootParent", + "InstitutionUpdate" : { + "title" : "InstitutionUpdate", "type" : "object", "properties" : { - "description" : { + "additionalInformations" : { + "$ref" : "#/components/schemas/AdditionalInformations" + }, + "address" : { "type" : "string" }, - "id" : { + "businessRegisterPlace" : { "type" : "string" }, - "originId" : { + "city" : { "type" : "string" - } - } - }, - "RootParentResponse" : { - "title" : "RootParentResponse", - "type" : "object", - "properties" : { - "description" : { + }, + "country" : { "type" : "string" }, - "id" : { + "county" : { "type" : "string" - } - } - }, - "ScContractResponse" : { - "title" : "ScContractResponse", - "type" : "object", - "properties" : { - "billing" : { - "$ref" : "#/components/schemas/BillingResponse" }, - "closedAt" : { - "type" : "string", - "format" : "date-time" + "dataProtectionOfficer" : { + "$ref" : "#/components/schemas/DataProtectionOfficer" + }, + "delegation" : { + "type" : "boolean" }, - "contentType" : { + "description" : { "type" : "string" }, - "createdAt" : { + "digitalAddress" : { + "type" : "string" + }, + "geographicTaxonomies" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/InstitutionGeographicTaxonomies" + } + }, + "imported" : { + "type" : "boolean" + }, + "institutionType" : { "type" : "string", - "format" : "date-time" + "enum" : [ "AS", "CON", "GSP", "PA", "PG", "PSP", "PT", "REC", "SA", "SCP" ] }, - "fileName" : { + "ivassCode" : { "type" : "string" }, - "filePath" : { - "type" : "string" + "paymentServiceProvider" : { + "$ref" : "#/components/schemas/PaymentServiceProvider" }, - "id" : { + "rea" : { "type" : "string" }, - "institution" : { - "$ref" : "#/components/schemas/InstitutionToNotifyResponse" + "shareCapital" : { + "type" : "string" }, - "internalIstitutionID" : { + "supportEmail" : { "type" : "string" }, - "notificationType" : { - "type" : "string", - "enum" : [ "ADD", "UPDATE" ] + "supportPhone" : { + "type" : "string" }, - "onboardingTokenId" : { + "taxCode" : { "type" : "string" }, - "pricingPlan" : { + "zipCode" : { "type" : "string" + } + } + }, + "InstitutionsResponse" : { + "title" : "InstitutionsResponse", + "type" : "object", + "properties" : { + "institutions" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/InstitutionResponse" + } + } + } + }, + "OnboardedProductResponse" : { + "title" : "OnboardedProductResponse", + "type" : "object", + "properties" : { + "billing" : { + "$ref" : "#/components/schemas/BillingResponse" + }, + "createdAt" : { + "type" : "string", + "format" : "date-time" }, - "product" : { + "productId" : { "type" : "string" }, - "state" : { - "type" : "string" + "status" : { + "type" : "string", + "enum" : [ "ACTIVE", "DELETED", "PENDING", "REJECTED", "SUSPENDED", "TOBEVALIDATED" ] }, "updatedAt" : { "type" : "string", @@ -6359,136 +3584,93 @@ } } }, - "SupportContact" : { - "title" : "SupportContact", - "type" : "object", - "properties" : { - "supportEmail" : { - "type" : "string" - }, - "supportPhone" : { - "type" : "string" - } - } - }, - "TokenListResponse" : { - "title" : "TokenListResponse", + "OnboardedProducts" : { + "title" : "OnboardedProducts", "type" : "object", "properties" : { - "items" : { + "products" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/TokenResponse" + "$ref" : "#/components/schemas/InstitutionProduct" } } } }, - "TokenResource" : { - "title" : "TokenResource", + "OnboardingRequest" : { + "title" : "OnboardingRequest", "type" : "object", "properties" : { - "checksum" : { - "type" : "string" - }, - "closedAt" : { - "type" : "string", - "format" : "date-time" - }, - "contractSigned" : { - "type" : "string" - }, - "contractTemplate" : { - "type" : "string" + "billingRequest" : { + "$ref" : "#/components/schemas/Billing" }, - "contractVersion" : { - "type" : "string" + "contract" : { + "$ref" : "#/components/schemas/Contract" }, - "createdAt" : { + "contractActivatedAt" : { "type" : "string", "format" : "date-time" }, - "expiringDate" : { + "contractCreatedAt" : { "type" : "string", "format" : "date-time" }, - "id" : { + "contractFilePath" : { "type" : "string" }, - "institutionId" : { + "institutionExternalId" : { "type" : "string" }, "institutionUpdate" : { "$ref" : "#/components/schemas/InstitutionUpdate" }, + "pricingPlan" : { + "type" : "string" + }, "productId" : { "type" : "string" }, - "status" : { - "type" : "string", - "enum" : [ "ACTIVE", "DELETED", "PENDING", "REJECTED", "SUSPENDED", "TOBEVALIDATED" ] + "productName" : { + "type" : "string" }, - "type" : { - "type" : "string", - "enum" : [ "INSTITUTION", "LEGALS" ] + "sendCompleteOnboardingEmail" : { + "type" : "boolean" }, - "updatedAt" : { + "signContract" : { + "type" : "boolean" + }, + "tokenType" : { "type" : "string", - "format" : "date-time" + "enum" : [ "INSTITUTION", "LEGALS" ] }, "users" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/TokenUser" + "$ref" : "#/components/schemas/UserToOnboard" } } } }, - "TokenResponse" : { - "title" : "TokenResponse", + "OnboardingResponse" : { + "title" : "OnboardingResponse", "type" : "object", "properties" : { - "checksum" : { - "type" : "string" + "billing" : { + "$ref" : "#/components/schemas/BillingResponse" }, "closedAt" : { "type" : "string", "format" : "date-time" }, - "contentType" : { - "type" : "string" - }, - "contractSigned" : { - "type" : "string" - }, - "contractTemplate" : { - "type" : "string" - }, - "contractVersion" : { + "contract" : { "type" : "string" }, "createdAt" : { "type" : "string", "format" : "date-time" }, - "expiringDate" : { - "type" : "string", - "format" : "date-time" - }, - "id" : { - "type" : "string" - }, - "institutionId" : { + "pricingPlan" : { "type" : "string" }, - "institutionUpdate" : { - "$ref" : "#/components/schemas/InstitutionUpdate" - }, - "legals" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/LegalsResponse" - } - }, "productId" : { "type" : "string" }, @@ -6496,132 +3678,123 @@ "type" : "string", "enum" : [ "ACTIVE", "DELETED", "PENDING", "REJECTED", "SUSPENDED", "TOBEVALIDATED" ] }, + "tokenId" : { + "type" : "string" + }, "updatedAt" : { "type" : "string", "format" : "date-time" - }, - "users" : { + } + } + }, + "OnboardingsResponse" : { + "title" : "OnboardingsResponse", + "type" : "object", + "properties" : { + "onboardings" : { "type" : "array", "items" : { - "$ref" : "#/components/schemas/TokenUser" + "$ref" : "#/components/schemas/OnboardingResponse" } } } }, - "TokenUser" : { - "title" : "TokenUser", + "PageInfo" : { + "title" : "PageInfo", "type" : "object", "properties" : { - "role" : { - "type" : "string", - "enum" : [ "DELEGATE", "MANAGER", "OPERATOR", "SUB_DELEGATE" ] + "pageNo" : { + "type" : "integer", + "format" : "int64" }, - "userId" : { - "type" : "string" + "pageSize" : { + "type" : "integer", + "format" : "int64" + }, + "totalElements" : { + "type" : "integer", + "format" : "int64" + }, + "totalPages" : { + "type" : "integer", + "format" : "int64" } } }, - "UserInfoResponse" : { - "title" : "UserInfoResponse", + "PaymentServiceProvider" : { + "title" : "PaymentServiceProvider", "type" : "object", "properties" : { - "email" : { + "abiCode" : { "type" : "string" }, - "id" : { + "businessRegisterNumber" : { "type" : "string" }, - "name" : { + "legalRegisterName" : { "type" : "string" }, - "products" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/OnboardedProduct" - } - }, - "surname" : { + "legalRegisterNumber" : { "type" : "string" }, - "taxCode" : { - "type" : "string" - } - } - }, - "UserNotificationBindingsResponse" : { - "title" : "UserNotificationBindingsResponse", - "type" : "object", - "properties" : { - "bindings" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/UserNotificationResponse" - } + "vatNumberGroup" : { + "type" : "boolean" } } }, - "UserNotificationResponse" : { - "title" : "UserNotificationResponse", + "PaymentServiceProviderRequest" : { + "title" : "PaymentServiceProviderRequest", "type" : "object", "properties" : { - "createdAt" : { - "type" : "string", - "format" : "date-time" - }, - "eventType" : { - "type" : "string", - "enum" : [ "ADD", "UPDATE" ] - }, - "id" : { + "abiCode" : { "type" : "string" }, - "institutionId" : { + "businessRegisterNumber" : { "type" : "string" }, - "onboardingTokenId" : { + "legalRegisterName" : { "type" : "string" }, - "productId" : { + "legalRegisterNumber" : { "type" : "string" }, - "updatedAt" : { - "type" : "string", - "format" : "date-time" - }, - "user" : { - "$ref" : "#/components/schemas/UserToNotify" + "vatNumberGroup" : { + "type" : "boolean" } } }, - "UserProductsResponse" : { - "title" : "UserProductsResponse", + "PaymentServiceProviderResponse" : { + "title" : "PaymentServiceProviderResponse", "type" : "object", "properties" : { - "bindings" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/InstitutionProducts" - } + "abiCode" : { + "type" : "string" }, - "id" : { + "businessRegisterNumber" : { "type" : "string" + }, + "legalRegisterName" : { + "type" : "string" + }, + "legalRegisterNumber" : { + "type" : "string" + }, + "vatNumberGroup" : { + "type" : "boolean" } } }, - "UserResponse" : { - "title" : "UserResponse", + "PdaInstitutionRequest" : { + "title" : "PdaInstitutionRequest", "type" : "object", "properties" : { - "email" : { - "type" : "string" - }, - "id" : { - "type" : "string" + "billing" : { + "$ref" : "#/components/schemas/BillingRequest" }, - "name" : { + "description" : { "type" : "string" }, - "surname" : { + "injectionInstitutionType" : { "type" : "string" }, "taxCode" : { @@ -6629,14 +3802,18 @@ } } }, - "UserToNotify" : { - "title" : "UserToNotify", + "Person" : { + "title" : "Person", "type" : "object", "properties" : { "email" : { "type" : "string" }, - "familyName" : { + "env" : { + "type" : "string", + "enum" : [ "COLL", "DEV", "PROD", "ROOT" ] + }, + "id" : { "type" : "string" }, "name" : { @@ -6645,15 +3822,49 @@ "productRole" : { "type" : "string" }, - "relationshipStatus" : { - "type" : "string", - "enum" : [ "ACTIVE", "DELETED", "PENDING", "REJECTED", "SUSPENDED", "TOBEVALIDATED" ] - }, "role" : { "type" : "string", "enum" : [ "DELEGATE", "MANAGER", "OPERATOR", "SUB_DELEGATE" ] }, - "userId" : { + "roleLabel" : { + "type" : "string" + }, + "surname" : { + "type" : "string" + }, + "taxCode" : { + "type" : "string" + } + } + }, + "Problem" : { + "title" : "Problem", + "type" : "object", + "properties" : { + "errors" : { + "type" : "array", + "items" : { + "$ref" : "#/components/schemas/ProblemError" + } + }, + "status" : { + "type" : "integer", + "format" : "int32" + } + } + }, + "ProblemError" : { + "title" : "ProblemError", + "type" : "object" + }, + "RootParentResponse" : { + "title" : "RootParentResponse", + "type" : "object", + "properties" : { + "description" : { + "type" : "string" + }, + "id" : { "type" : "string" } } @@ -6692,18 +3903,6 @@ "type" : "string" } } - }, - "UsersNotificationResponse" : { - "title" : "UsersNotificationResponse", - "type" : "object", - "properties" : { - "users" : { - "type" : "array", - "items" : { - "$ref" : "#/components/schemas/UserNotificationBindingsResponse" - } - } - } } }, "securitySchemes" : { diff --git a/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/CoreConnectorImpl.java b/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/CoreConnectorImpl.java index d3ddf2919..91d49b059 100644 --- a/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/CoreConnectorImpl.java +++ b/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/CoreConnectorImpl.java @@ -1,8 +1,6 @@ package it.pagopa.selfcare.dashboard.connector.rest; -import it.pagopa.selfcare.commons.base.logging.LogUtils; import it.pagopa.selfcare.commons.base.security.PartyRole; -import it.pagopa.selfcare.commons.base.security.SelfCareAuthority; import it.pagopa.selfcare.core.generated.openapi.v1.dto.*; import it.pagopa.selfcare.dashboard.connector.api.MsCoreConnector; import it.pagopa.selfcare.dashboard.connector.model.auth.AuthInfo; @@ -12,12 +10,14 @@ import it.pagopa.selfcare.dashboard.connector.model.delegation.DelegationId; import it.pagopa.selfcare.dashboard.connector.model.delegation.DelegationRequest; import it.pagopa.selfcare.dashboard.connector.model.delegation.GetDelegationParameters; -import it.pagopa.selfcare.dashboard.connector.model.institution.*; +import it.pagopa.selfcare.dashboard.connector.model.institution.GeographicTaxonomy; +import it.pagopa.selfcare.dashboard.connector.model.institution.GeographicTaxonomyList; +import it.pagopa.selfcare.dashboard.connector.model.institution.Institution; +import it.pagopa.selfcare.dashboard.connector.model.institution.UpdateInstitutionResource; import it.pagopa.selfcare.dashboard.connector.model.product.PartyProduct; -import it.pagopa.selfcare.dashboard.connector.model.user.CreateUserDto; -import it.pagopa.selfcare.dashboard.connector.model.user.RoleInfo; -import it.pagopa.selfcare.dashboard.connector.model.user.UserInfo; -import it.pagopa.selfcare.dashboard.connector.rest.client.*; +import it.pagopa.selfcare.dashboard.connector.rest.client.CoreDelegationApiRestClient; +import it.pagopa.selfcare.dashboard.connector.rest.client.CoreInstitutionApiRestClient; +import it.pagopa.selfcare.dashboard.connector.rest.client.CoreOnboardingApiRestClient; import it.pagopa.selfcare.dashboard.connector.rest.model.ProductState; import it.pagopa.selfcare.dashboard.connector.rest.model.mapper.BrokerMapper; import it.pagopa.selfcare.dashboard.connector.rest.model.mapper.DelegationRestClientMapper; @@ -30,15 +30,12 @@ import org.springframework.stereotype.Service; import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; import javax.validation.ValidationException; -import java.util.*; -import java.util.function.BinaryOperator; -import java.util.function.Function; -import java.util.stream.Collectors; - -import static it.pagopa.selfcare.dashboard.connector.model.institution.RelationshipState.*; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Objects; @Slf4j @Service @@ -48,8 +45,6 @@ class CoreConnectorImpl implements MsCoreConnector { private final CoreInstitutionApiRestClient coreInstitutionApiRestClient; private final CoreDelegationApiRestClient coreDelegationApiRestClient; - private final CoreUserApiRestClient coreUserApiRestClient; - private final CoreManagementApiRestClient coreManagementApiRestClient; private final CoreOnboardingApiRestClient coreOnboardingApiRestClient; private final BrokerMapper brokerMapper; private final InstitutionMapper institutionMapper; @@ -59,101 +54,7 @@ class CoreConnectorImpl implements MsCoreConnector { static final String REQUIRED_PRODUCT_ID_MESSAGE = "A Product id is required"; static final String REQUIRED_INSTITUTION_TYPE_MESSAGE = "An Institution type is required"; static final String REQUIRED_UPDATE_RESOURCE_MESSAGE = "An Institution description is required"; - - private static final String REQUIRED_RELATIONSHIP_MESSAGE = "A Relationship id is required"; - static final String REQUIRED_TOKEN_ID_MESSAGE = "A tokenId is required"; static final String REQUIRED_GEOGRAPHIC_TAXONOMIES_MESSAGE = "An object of geographic taxonomy list is required"; - protected static final Function RELATIONSHIP_INFO_TO_USER_INFO_FUNCTION = relationshipInfo -> { - UserInfo userInfo = new UserInfo(); - userInfo.setId(relationshipInfo.getFrom()); - userInfo.setStatus(relationshipInfo.getState().toString()); - userInfo.setRole(relationshipInfo.getRole().equals(RelationshipResult.RoleEnum.OPERATOR) ? SelfCareAuthority.LIMITED : SelfCareAuthority.ADMIN); - it.pagopa.selfcare.dashboard.connector.model.user.ProductInfo productInfo - = new it.pagopa.selfcare.dashboard.connector.model.user.ProductInfo(); - productInfo.setId(relationshipInfo.getProduct().getId()); - RoleInfo roleInfo = new RoleInfo(); - roleInfo.setRelationshipId(relationshipInfo.getId()); - roleInfo.setSelcRole(relationshipInfo.getRole().equals(RelationshipResult.RoleEnum.OPERATOR) ? SelfCareAuthority.LIMITED : SelfCareAuthority.ADMIN); - roleInfo.setRole(relationshipInfo.getProduct().getRole()); - roleInfo.setStatus(relationshipInfo.getState().toString()); - ArrayList roleInfos = new ArrayList<>(); - roleInfos.add(roleInfo); - productInfo.setRoleInfos(roleInfos); - Map products = new HashMap<>(); - products.put(productInfo.getId(), productInfo); - userInfo.setProducts(products); - userInfo.setInstitutionId(relationshipInfo.getTo()); - return userInfo; - }; - - protected static final BinaryOperator USER_INFO_MERGE_FUNCTION = (userInfo1, userInfo2) -> { - String id = userInfo2.getProducts().keySet().toArray()[0].toString(); - if (userInfo1.getProducts().containsKey(id)) { - userInfo1.getProducts().get(id).getRoleInfos().addAll(userInfo2.getProducts().get(id).getRoleInfos()); - } else { - userInfo1.getProducts().put(id, userInfo2.getProducts().get(id)); - } - if (userInfo1.getStatus().equals(userInfo2.getStatus())) { - if (userInfo1.getRole().compareTo(userInfo2.getRole()) > 0) { - userInfo1.setRole(userInfo2.getRole()); - } - } else { - if ("ACTIVE".equals(userInfo2.getStatus())) { - userInfo1.setRole(userInfo2.getRole()); - userInfo1.setStatus(userInfo2.getStatus()); - } - } - return userInfo1; - }; - - @Override - public List getUserProducts(String userId) { - log.trace("getUserProducts start"); - UserProductsResponse productsInfoUsingGET = coreUserApiRestClient._getUserProductsInfoUsingGET(userId, null, - listToString(List.of(ACTIVE.name(), PENDING.name(), TOBEVALIDATED.name()))).getBody(); - - if(Objects.isNull(productsInfoUsingGET) || - Objects.isNull(productsInfoUsingGET.getBindings())) return List.of(); - - List result = productsInfoUsingGET.getBindings().stream() - .map(institutionMapper::toInstitutionInfo) - .toList(); - log.debug("getUserProducts result = {}", result); - log.trace("getUserProducts end"); - return result; - } - - @Override - public Collection getAuthInfo(String institutionId) { - log.trace("getAuthInfo start"); - log.debug("getAuthInfo institutionId = {}", institutionId); - Collection authInfos = Collections.emptyList(); - OnboardingInfoResponse onBoardingInfo = coreOnboardingApiRestClient._onboardingInfoUsingGET(institutionId, null, ACTIVE.name()).getBody(); - if (onBoardingInfo != null && onBoardingInfo.getInstitutions() != null) { - authInfos = onBoardingInfo.getInstitutions().stream() - .filter(onboardingData -> onboardingData.getProductInfo() != null) - .collect(Collectors.collectingAndThen( - Collectors.groupingBy(OnboardedInstitutionResponse::getId, - Collectors.mapping(onboardingData -> { - PartyProductRole productRole = new PartyProductRole(); - productRole.setProductId(onboardingData.getProductInfo().getId()); - productRole.setProductRole(onboardingData.getProductInfo().getRole()); - productRole.setPartyRole(PartyRole.valueOf(onboardingData.getRole().name())); - return productRole; - }, Collectors.toList())), - map -> map.entrySet().stream() - .map(entry -> { - PartyAuthInfo authInfo = new PartyAuthInfo(); - authInfo.setInstitutionId(entry.getKey()); - authInfo.setProductRoles(Collections.unmodifiableCollection(entry.getValue())); - return authInfo; - }).collect(Collectors.toList()) - )); - } - log.debug("getAuthInfo result = {}", authInfos); - log.trace("getAuthInfo end"); - return authInfos; - } @Override public Institution getInstitution(String institutionId) { @@ -232,28 +133,6 @@ public List getDelegations(GetDelegationParameters delegationParamet return delegations; } - @Override - public void updateUser(String userId, String institutionId) { - log.trace("updateUser start"); - log.debug("updateUser userId = {}, institutionId = {}", userId, institutionId); - coreUserApiRestClient._updateUserUsingPOST(userId, institutionId); - log.trace("updateUser end"); - } - - @Override - public InstitutionInfo getOnBoardedInstitution(String institutionId) { - log.trace("getOnBoardedInstitution start"); - log.debug("getOnBoardedInstitution institutionId = {}", institutionId); - InstitutionInfo result = null; - OnboardingInfoResponse onBoardingInfo = coreOnboardingApiRestClient._onboardingInfoUsingGET(institutionId, null, ACTIVE.name()).getBody(); - if (onBoardingInfo != null && !CollectionUtils.isEmpty(onBoardingInfo.getInstitutions())) { - result = institutionMapper.toInstitutionInfo(onBoardingInfo.getInstitutions()).stream().findAny().orElse(null); - } - log.debug("getOnBoardedInstitution result = {}", result); - log.trace("getOnBoardedInstitution end"); - return result; - } - @Override public void updateInstitutionGeographicTaxonomy(String institutionId, GeographicTaxonomyList geographicTaxonomies) { log.trace("updateInstitutionGeographicTaxonomy start"); @@ -285,115 +164,6 @@ public List getGeographicTaxonomyList(String institutionId) return result; } - @Override - public UserInfo getUser(String relationshipId) { - log.trace("getUser start"); - log.debug("getUser = {}", relationshipId); - RelationshipResult relationshipResult = coreUserApiRestClient._getRelationshipUsingGET(relationshipId).getBody(); - UserInfo user = RELATIONSHIP_INFO_TO_USER_INFO_FUNCTION.apply(relationshipResult); - log.debug("getUser result = {}", user); - log.trace("getUser end"); - return user; - } - - @Override - public void createUsers(String institutionId, String productId, String userId, CreateUserDto userDto, String - productTitle) { - log.trace("createUsers start"); - log.debug(LogUtils.CONFIDENTIAL_MARKER, "createUsers institutionId = {}, productId = {}, createUserDto = {}", institutionId, productId, userId); - Assert.hasText(institutionId, REQUIRED_INSTITUTION_ID_MESSAGE); - Assert.hasText(productId, REQUIRED_PRODUCT_ID_MESSAGE); - Assert.hasText(userId, "An User Id is required"); - Assert.notNull(userDto, "A User is required"); - - OnboardingInstitutionOperatorsRequest onboardingUsersRequest = new OnboardingInstitutionOperatorsRequest(); - onboardingUsersRequest.setInstitutionId(institutionId); - onboardingUsersRequest.setProductId(productId); - onboardingUsersRequest.setProductTitle(productTitle); - Map> partyRoleToUsersMap = getPartyRoleListMap(userId, userDto); - - if (partyRoleToUsersMap.size() > 1) { - throw new ValidationException(String.format("Is not allowed to create both %s and %s users", PartyRole.SUB_DELEGATE, PartyRole.OPERATOR)); - } - - partyRoleToUsersMap.forEach((key, value) -> { - onboardingUsersRequest.setUsers(value); - switch (key) { - case SUB_DELEGATE: - coreOnboardingApiRestClient._onboardingInstitutionSubDelegateUsingPOST(onboardingUsersRequest); - break; - case OPERATOR: - coreOnboardingApiRestClient._onboardingInstitutionOperatorsUsingPOST(onboardingUsersRequest); - break; - default: - throw new IllegalArgumentException("Invalid Party role"); - } - }); - - log.trace("createUsers end"); - } - - - @Override - public void checkExistingRelationshipRoles(String institutionId, String productId, CreateUserDto - userDto, String userId) { - log.trace("checkExistingRelationshipRoles start"); - log.debug(LogUtils.CONFIDENTIAL_MARKER, "checkExistingRelationshipRoles institutionId = {}, productId = {}, createUserDto = {}, userId = {}", institutionId, productId, userDto, userId); - - Map> partyRoleToUsersMap = getPartyRoleListMap(userId, userDto); - - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - userInfoFilter.setProductId(productId); - userInfoFilter.setUserId(userId); - userInfoFilter.setAllowedStates(List.of(ACTIVE, SUSPENDED)); - - List states = CollectionUtils.isEmpty(userInfoFilter.getAllowedStates()) ? - Collections.emptyList() : userInfoFilter.getAllowedStates().stream().map(Enum::name).toList(); - - List relationshipResults = coreInstitutionApiRestClient._getUserInstitutionRelationshipsUsingGET(institutionId, userInfoFilter.getUserId(), null, listToString(states), userInfoFilter.getProductId(), listToString(userInfoFilter.getProductRoles())).getBody(); - if (!CollectionUtils.isEmpty(relationshipResults)) { - Set roles = partyRoleToUsersMap.keySet(); - List partyRoles = relationshipResults.stream().map(RelationshipResult::getRole).toList(); - - if (checkUserRole(userDto, relationshipResults)) { - throw new ValidationException("User role conflict"); - } - - if (!roles.contains(Person.RoleEnum.OPERATOR) || !(partyRoles.contains(RelationshipResult.RoleEnum.OPERATOR))) { - throw new ValidationException("User role conflict"); - } - } - log.trace("checkExistingRelationshipRoles end"); - } - - private boolean checkUserRole(CreateUserDto userDto, List relationshipResults) { - Set productRoles = relationshipResults.stream() - .map(RelationshipResult::getProduct) - .map(ProductInfo::getRole) - .collect(Collectors.toSet()); - - return userDto.getRoles().stream() - .map(CreateUserDto.Role::getProductRole) - .anyMatch(productRoles::contains); - } - - - private Map> getPartyRoleListMap(String userId, CreateUserDto userDto) { - return userDto.getRoles().stream() - .map(role -> { - Person user = new Person(); - user.setName(userDto.getName()); - user.setSurname(userDto.getSurname()); - user.setTaxCode(userDto.getTaxCode()); - user.setEmail(userDto.getEmail()); - user.setId(userId); - user.setProductRole(role.getProductRole()); - user.setRole(Person.RoleEnum.valueOf(role.getPartyRole().name())); - user.setRoleLabel(role.getLabel()); - return user; - }).collect(Collectors.groupingBy(Person::getRole)); - } - @Override public List getInstitutionProducts(String institutionId) { log.trace("getInstitutionProducts start"); @@ -410,40 +180,6 @@ public List getInstitutionProducts(String institutionId) { return products; } - @Override - public Collection getUsers(String institutionId, UserInfo.UserInfoFilter userInfoFilter) { - log.trace("getUsers start"); - log.debug("getUsers institutionId = {}, role = {}, productId = {}, productRoles = {}, userId = {}", institutionId, userInfoFilter.getRole(), userInfoFilter.getProductId(), userInfoFilter.getProductRoles(), userInfoFilter.getUserId()); - Assert.hasText(institutionId, REQUIRED_INSTITUTION_ID_MESSAGE); - - Collection userInfos = Collections.emptyList(); - List roles = null; - if (userInfoFilter.getRole() != null) { - roles = Arrays.stream(PartyRole.values()) - .filter(partyRole -> partyRole.getSelfCareAuthority().equals(userInfoFilter.getRole())) - .map(Enum::name) - .toList(); - } - List institutionRelationships = coreInstitutionApiRestClient._getUserInstitutionRelationshipsUsingGET(institutionId, - userInfoFilter.getUserId(), - listToString(roles), - !CollectionUtils.isEmpty(userInfoFilter.getAllowedStates()) ? listToString(userInfoFilter.getAllowedStates().stream().map(Enum::name).toList()) : null, - StringUtils.hasText(userInfoFilter.getProductId()) ? listToString(List.of(userInfoFilter.getProductId())) : null, - listToString(userInfoFilter.getProductRoles())) - .getBody(); - - if (institutionRelationships != null) { - userInfos = institutionRelationships.stream() - .collect(Collectors.toMap(RelationshipResult::getFrom, - RELATIONSHIP_INFO_TO_USER_INFO_FUNCTION, - USER_INFO_MERGE_FUNCTION)).values(); - } - log.debug("getUsers result = {}", userInfos); - log.trace("getUsers end"); - return userInfos; - } - - @Getter @Setter(AccessLevel.PROTECTED) protected static class PartyProductRole implements ProductRole { @@ -460,12 +196,5 @@ protected static class PartyAuthInfo implements AuthInfo { protected Collection productRoles; } - private String listToString(List list){ - if(CollectionUtils.isEmpty(list)){ - return null; - } - return String.join(",", list); - } - } diff --git a/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/client/CoreUserApiRestClient.java b/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/client/CoreUserApiRestClient.java deleted file mode 100644 index 3490ed6d5..000000000 --- a/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/client/CoreUserApiRestClient.java +++ /dev/null @@ -1,8 +0,0 @@ -package it.pagopa.selfcare.dashboard.connector.rest.client; - - -import org.springframework.cloud.openfeign.FeignClient; - -@FeignClient(name = "${rest-client.ms-core-user-api.serviceCode}", url = "${rest-client.ms-core.base-url}") -public interface CoreUserApiRestClient extends it.pagopa.selfcare.core.generated.openapi.v1.api.PersonsApi { -} diff --git a/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/config/MsCoreRestClientConfig.java b/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/config/MsCoreRestClientConfig.java index 81d1cea1d..19646cd57 100644 --- a/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/config/MsCoreRestClientConfig.java +++ b/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/config/MsCoreRestClientConfig.java @@ -1,7 +1,10 @@ package it.pagopa.selfcare.dashboard.connector.rest.config; import it.pagopa.selfcare.commons.connector.rest.config.RestClientBaseConfig; -import it.pagopa.selfcare.dashboard.connector.rest.client.*; +import it.pagopa.selfcare.dashboard.connector.rest.client.CoreDelegationApiRestClient; +import it.pagopa.selfcare.dashboard.connector.rest.client.CoreInstitutionApiRestClient; +import it.pagopa.selfcare.dashboard.connector.rest.client.CoreManagementApiRestClient; +import it.pagopa.selfcare.dashboard.connector.rest.client.CoreOnboardingApiRestClient; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Import; @@ -9,7 +12,7 @@ @Configuration @Import(RestClientBaseConfig.class) -@EnableFeignClients(clients = {CoreUserApiRestClient.class, CoreDelegationApiRestClient.class, +@EnableFeignClients(clients = {CoreDelegationApiRestClient.class, CoreInstitutionApiRestClient.class, CoreOnboardingApiRestClient.class, CoreManagementApiRestClient.class}) @PropertySource("classpath:config/ms-core-rest-client.properties") public class MsCoreRestClientConfig { diff --git a/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/model/mapper/InstitutionMapper.java b/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/model/mapper/InstitutionMapper.java index db15e0da1..1b1dd267e 100644 --- a/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/model/mapper/InstitutionMapper.java +++ b/connector/rest/src/main/java/it/pagopa/selfcare/dashboard/connector/rest/model/mapper/InstitutionMapper.java @@ -2,14 +2,13 @@ import it.pagopa.selfcare.commons.base.utils.InstitutionType; import it.pagopa.selfcare.core.generated.openapi.v1.dto.*; -import it.pagopa.selfcare.dashboard.connector.model.institution.*; import it.pagopa.selfcare.dashboard.connector.model.institution.Billing; -import it.pagopa.selfcare.dashboard.connector.model.institution.Institution; +import it.pagopa.selfcare.dashboard.connector.model.institution.*; import it.pagopa.selfcare.dashboard.connector.model.product.PartyProduct; import it.pagopa.selfcare.dashboard.connector.model.product.ProductOnBoardingStatus; import it.pagopa.selfcare.dashboard.connector.model.user.UserInstitution; -import it.pagopa.selfcare.user.generated.openapi.v1.dto.UserInstitutionRoleResponse; import it.pagopa.selfcare.user.generated.openapi.v1.dto.UserInstitutionResponse; +import it.pagopa.selfcare.user.generated.openapi.v1.dto.UserInstitutionRoleResponse; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.Named; @@ -30,19 +29,6 @@ public interface InstitutionMapper { @Mapping(target = "status", expression = "java(institutionProducts.getStatus().name())") InstitutionBase toInstitutionBase(UserInstitutionRoleResponse institutionProducts); - @Mapping(target = "id", source = "institutionId") - @Mapping(target = "description", source = "institutionName") - @Mapping(target = "parentDescription", source = "institutionRootName") - @Mapping(target = "status", source = ".", qualifiedByName = "toStatus") - InstitutionInfo toInstitutionInfo(InstitutionProducts institutionProducts); - - List toInstitutionInfo(List institutionResponse); - - @Mapping(target = "status", expression = "java(getState(institutionResponse.getState()))") - @Mapping(target = "category", expression = "java(getCategory(institutionResponse.getAttributes()))") - @Mapping(target = "geographicTaxonomies", expression = "java(getGeographicTaxonomies(institutionResponse.getGeographicTaxonomies()))") - InstitutionInfo toInstitutionInfo(OnboardedInstitutionResponse institutionResponse); - @Mapping(target = "institutionType", expression = "java(toInstitutionType(institutionResponse.getInstitutionType()))") @Mapping(target = "description" , source = "institutionUpdate.description") @Mapping(target = "taxCode" , source = "institutionUpdate.taxCode") @@ -117,14 +103,4 @@ default RelationshipState getState(String state) { } return null; } - - @Named("toStatus") - default RelationshipState toStatus(InstitutionProducts institutionProducts) { - return institutionProducts.getProducts().stream() - .map(Product::getStatus) - .sorted() - .findFirst() - .map(statusEnum -> RelationshipState.valueOf(statusEnum.name())) - .orElse(null); - } } diff --git a/connector/rest/src/test/java/it/pagopa/selfcare/dashboard/connector/rest/CoreConnectorImplTest.java b/connector/rest/src/test/java/it/pagopa/selfcare/dashboard/connector/rest/CoreConnectorImplTest.java index afaf238da..7d3fa25e2 100644 --- a/connector/rest/src/test/java/it/pagopa/selfcare/dashboard/connector/rest/CoreConnectorImplTest.java +++ b/connector/rest/src/test/java/it/pagopa/selfcare/dashboard/connector/rest/CoreConnectorImplTest.java @@ -3,7 +3,6 @@ import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.PropertyAccessor; -import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; @@ -11,50 +10,42 @@ import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import it.pagopa.selfcare.commons.base.security.SelfCareAuthority; import it.pagopa.selfcare.core.generated.openapi.v1.dto.*; -import it.pagopa.selfcare.dashboard.connector.model.auth.AuthInfo; import it.pagopa.selfcare.dashboard.connector.model.backoffice.BrokerInfo; import it.pagopa.selfcare.dashboard.connector.model.delegation.DelegationRequest; import it.pagopa.selfcare.dashboard.connector.model.delegation.*; import it.pagopa.selfcare.dashboard.connector.model.institution.*; import it.pagopa.selfcare.dashboard.connector.model.product.PartyProduct; -import it.pagopa.selfcare.dashboard.connector.model.user.CreateUserDto; -import it.pagopa.selfcare.dashboard.connector.model.user.ProductInfo; -import it.pagopa.selfcare.dashboard.connector.model.user.RoleInfo; import it.pagopa.selfcare.dashboard.connector.model.user.UserInfo; -import it.pagopa.selfcare.dashboard.connector.rest.client.*; +import it.pagopa.selfcare.dashboard.connector.rest.client.CoreDelegationApiRestClient; +import it.pagopa.selfcare.dashboard.connector.rest.client.CoreInstitutionApiRestClient; +import it.pagopa.selfcare.dashboard.connector.rest.client.CoreManagementApiRestClient; +import it.pagopa.selfcare.dashboard.connector.rest.client.CoreOnboardingApiRestClient; import it.pagopa.selfcare.dashboard.connector.rest.model.ProductState; import it.pagopa.selfcare.dashboard.connector.rest.model.mapper.BrokerMapper; import it.pagopa.selfcare.dashboard.connector.rest.model.mapper.DelegationRestClientMapperImpl; import it.pagopa.selfcare.dashboard.connector.rest.model.mapper.InstitutionMapperImpl; -import it.pagopa.selfcare.onboarding.common.PartyRole; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; import org.mockito.ArgumentCaptor; -import org.mockito.Captor; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.util.ResourceUtils; import javax.validation.ValidationException; -import java.io.File; -import java.io.IOException; import java.util.*; import java.util.function.Function; import static it.pagopa.selfcare.commons.base.security.SelfCareAuthority.ADMIN; import static it.pagopa.selfcare.commons.base.security.SelfCareAuthority.LIMITED; -import static it.pagopa.selfcare.commons.utils.TestUtils.*; -import static it.pagopa.selfcare.dashboard.connector.model.institution.RelationshipState.*; +import static it.pagopa.selfcare.commons.utils.TestUtils.checkNotNullFields; +import static it.pagopa.selfcare.commons.utils.TestUtils.mockInstance; import static it.pagopa.selfcare.dashboard.connector.rest.CoreConnectorImpl.REQUIRED_GEOGRAPHIC_TAXONOMIES_MESSAGE; import static it.pagopa.selfcare.dashboard.connector.rest.CoreConnectorImpl.REQUIRED_INSTITUTION_ID_MESSAGE; -import static java.util.Collections.singletonList; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; @@ -72,9 +63,6 @@ class CoreConnectorImplTest { @Autowired private CoreConnectorImpl msCoreConnector; - @MockBean - private CoreUserApiRestClient coreUserApiRestClientMock; - @MockBean private CoreDelegationApiRestClient coreDelegationApiRestClient; @@ -89,9 +77,6 @@ class CoreConnectorImplTest { @MockBean private BrokerMapper brokerMapper; - @Captor - private ArgumentCaptor onboardingRequestCaptor; - public CoreConnectorImplTest() { mapper = new ObjectMapper(); mapper.registerModule(new JavaTimeModule()); @@ -111,61 +96,6 @@ public CoreConnectorImplTest() { }; - @Test - void getUserProducts_shouldGetEmptyData() { - // given - String userId = "userId"; - - UserProductsResponse userProductsResponse = new UserProductsResponse(); - userProductsResponse.setId(userId); - userProductsResponse.setBindings(List.of()); - - ResponseEntity userProductsResponseResponseEntity = mock(ResponseEntity.class); - when(userProductsResponseResponseEntity.getBody()).thenReturn(userProductsResponse); - - when(coreUserApiRestClientMock._getUserProductsInfoUsingGET(any(), any(), any())) - .thenReturn(userProductsResponseResponseEntity); - // when - List institutions = msCoreConnector.getUserProducts(userId); - // then - assertNotNull(institutions); - assertEquals(0, institutions.size()); - - verify(coreUserApiRestClientMock, times(1)) - ._getUserProductsInfoUsingGET(eq(userId), isNull(), eq(ACTIVE.name() +","+ PENDING.name() +","+ TOBEVALIDATED.name())); - verifyNoMoreInteractions(coreUserApiRestClientMock); - } - - @Test - void getUserProducts_shouldGetData() { - // given - String userId = "userId"; - - UserProductsResponse userProductsResponse = new UserProductsResponse(); - userProductsResponse.setId(userId); - InstitutionProducts institutionProducts = new InstitutionProducts(); - institutionProducts.setInstitutionId("institutionId"); - institutionProducts.setProducts(List.of(it.pagopa.selfcare.core.generated.openapi.v1.dto.Product.builder() - .status(it.pagopa.selfcare.core.generated.openapi.v1.dto.Product.StatusEnum.ACTIVE) - .status(it.pagopa.selfcare.core.generated.openapi.v1.dto.Product.StatusEnum.ACTIVE) - .build())); - userProductsResponse.setBindings(List.of(institutionProducts)); - - ResponseEntity userProductsResponseResponseEntity = mock(ResponseEntity.class); - when(userProductsResponseResponseEntity.getBody()).thenReturn(userProductsResponse); - when(coreUserApiRestClientMock._getUserProductsInfoUsingGET(any(), any(), any())) - .thenReturn(userProductsResponseResponseEntity); - // when - List institutions = msCoreConnector.getUserProducts(userId); - - assertEquals(userProductsResponse.getBindings().get(0).getInstitutionRootName(), institutions.get(0).getParentDescription()); - assertEquals(userProductsResponse.getBindings().get(0).getInstitutionId(), institutions.get(0).getId()); - - verify(coreUserApiRestClientMock, times(1)) - ._getUserProductsInfoUsingGET(eq(userId), isNull(), eq(ACTIVE.name() +","+ PENDING.name() +","+ TOBEVALIDATED.name())); - verifyNoMoreInteractions(coreUserApiRestClientMock); - } - @Test void getInstitution_nullInstitutionId() { // given @@ -183,7 +113,6 @@ void getInstitution_nullInstitutionId() { void getInstitution_nullResponse() { // given String institutionId = "institutionId"; - InstitutionResponse instResp = mockInstance(new InstitutionResponse()); // when when(coreInstitutionApiRestClient._retrieveInstitutionByIdUsingGET(institutionId)).thenReturn(ResponseEntity.ok().build()); Institution institution = msCoreConnector.getInstitution(institutionId); @@ -345,165 +274,6 @@ private DelegationResponse dummyDelegationResponse() { return delegationResponse; } - @Test - void updateUser() { - //given - String userId = UUID.randomUUID().toString(); - String institutionId = UUID.randomUUID().toString(); - //when - Executable executable = () -> msCoreConnector.updateUser(userId, institutionId); - //then - assertDoesNotThrow(executable); - verify(coreUserApiRestClientMock, times(1))._updateUserUsingPOST(userId, institutionId); - } - - @Test - void getInstitution_nullOnBoardingInfo() { - // given - String institutionId = "institutionId"; - // when - when(coreOnboardingApiRestClient._onboardingInfoUsingGET(institutionId, null, ACTIVE.name())) - .thenReturn(ResponseEntity.of(Optional.of(new OnboardingInfoResponse()))); - InstitutionInfo institutionInfo = msCoreConnector.getOnBoardedInstitution(institutionId); - // then - assertNull(institutionInfo); - verify(coreOnboardingApiRestClient, times(1)) - ._onboardingInfoUsingGET(institutionId, null, ACTIVE.name()); - verifyNoMoreInteractions(coreOnboardingApiRestClient); - } - - - @Test - void getInstitution_nullInstitutions() { - // given - String institutionId = "institutionId"; - OnboardingInfoResponse onBoardingInfo = new OnboardingInfoResponse(); - when(coreOnboardingApiRestClient._onboardingInfoUsingGET(any(), any(), any())) - .thenReturn(ResponseEntity.of(Optional.of(onBoardingInfo))); - // when - InstitutionInfo institutionInfo = msCoreConnector.getOnBoardedInstitution(institutionId); - // then - assertNull(institutionInfo); - verify(coreOnboardingApiRestClient, times(1)) - ._onboardingInfoUsingGET(institutionId, null, ACTIVE.name()); - verifyNoMoreInteractions(coreOnboardingApiRestClient); - } - - @Test - void getInstitution_emptyInstitutions() { - // given - String institutionId = "institutionId"; - OnboardingInfoResponse onBoardingInfo = new OnboardingInfoResponse(); - onBoardingInfo.setInstitutions(Collections.emptyList()); - when(coreOnboardingApiRestClient._onboardingInfoUsingGET(any(), any(), any())) - .thenReturn(ResponseEntity.of(Optional.of(onBoardingInfo))); - // when - InstitutionInfo institutionInfo = msCoreConnector.getOnBoardedInstitution(institutionId); - // then - assertNull(institutionInfo); - verify(coreOnboardingApiRestClient, times(1)) - ._onboardingInfoUsingGET(institutionId, null, ACTIVE.name()); - verifyNoMoreInteractions(coreOnboardingApiRestClient); - } - - - @Test - void getInstitution_nullAttributes() { - // given - String institutionId = "institutionId"; - OnboardingInfoResponse onBoardingInfo = new OnboardingInfoResponse(); - OnboardedInstitutionResponse onboardingData = mockInstance(new OnboardedInstitutionResponse()); - onboardingData.setState("PENDING"); - onboardingData.setGeographicTaxonomies(List.of(mockInstance(new GeoTaxonomies()))); - onBoardingInfo.setInstitutions(singletonList(onboardingData)); - when(coreOnboardingApiRestClient._onboardingInfoUsingGET(any(), any(), any())) - .thenReturn(ResponseEntity.of(Optional.of(onBoardingInfo))); - // when - InstitutionInfo institutionInfo = msCoreConnector.getOnBoardedInstitution(institutionId); - // then - assertNotNull(institutionInfo); - assertNull(institutionInfo.getCategory()); - verify(coreOnboardingApiRestClient, times(1)) - ._onboardingInfoUsingGET(institutionId, null, ACTIVE.name()); - verifyNoMoreInteractions(coreOnboardingApiRestClient); - } - - @Test - void getInstitution_emptyAttributes() { - // given - String institutionId = "institutionId"; - OnboardingInfoResponse onBoardingInfo = new OnboardingInfoResponse(); - OnboardedInstitutionResponse onboardingData = mockInstance(new OnboardedInstitutionResponse()); - onboardingData.setState("SUSPENDED"); - onboardingData.setGeographicTaxonomies(List.of(mockInstance(new GeoTaxonomies()))); - onBoardingInfo.setInstitutions(singletonList(onboardingData)); - when(coreOnboardingApiRestClient._onboardingInfoUsingGET(any(), any(), any())) - .thenReturn(ResponseEntity.of(Optional.of(onBoardingInfo))); - // when - InstitutionInfo institutionInfo = msCoreConnector.getOnBoardedInstitution(institutionId); - // then - assertNotNull(institutionInfo); - assertNull(institutionInfo.getCategory()); - verify(coreOnboardingApiRestClient, times(1)) - ._onboardingInfoUsingGET(institutionId, null, ACTIVE.name()); - verifyNoMoreInteractions(coreOnboardingApiRestClient); - } - - @Test - void getInstitution_nullGeographicTaxonomy() { - // given - String institutionId = "institutionId"; - OnboardingInfoResponse onBoardingInfo = new OnboardingInfoResponse(); - OnboardedInstitutionResponse onboardingData = mockInstance(new OnboardedInstitutionResponse(), "setGeographicTaxonomies"); - onboardingData.setState("PENDING"); - onBoardingInfo.setInstitutions(singletonList(onboardingData)); - when(coreOnboardingApiRestClient._onboardingInfoUsingGET(any(), any(), any())) - .thenReturn(ResponseEntity.of(Optional.of(onBoardingInfo))); - // when - - // then - InstitutionInfo institutionInfo = msCoreConnector.getOnBoardedInstitution(institutionId); - assertNotNull(institutionInfo.getGeographicTaxonomies()); - assertTrue(institutionInfo.getGeographicTaxonomies().isEmpty()); - - verify(coreOnboardingApiRestClient, times(1)) - ._onboardingInfoUsingGET(institutionId, null, ACTIVE.name()); - verifyNoMoreInteractions(coreOnboardingApiRestClient); - } - - @Test - void getOnBoardedInstitution() { - // given - String institutionId = "institutionId"; - OnboardingInfoResponse onBoardingInfo = new OnboardingInfoResponse(); - OnboardedInstitutionResponse onboardingData = mockInstance(new OnboardedInstitutionResponse()); - onboardingData.setAttributes(List.of(mockInstance(new AttributesResponse()))); - onboardingData.setGeographicTaxonomies(List.of(mockInstance(new GeoTaxonomies()))); - onboardingData.setState("ACTIVE"); - onBoardingInfo.setInstitutions(singletonList(onboardingData)); - when(coreOnboardingApiRestClient._onboardingInfoUsingGET(any(), any(), any())) - .thenReturn(ResponseEntity.of(Optional.of(onBoardingInfo))); - // when - InstitutionInfo institutionInfo = msCoreConnector.getOnBoardedInstitution(institutionId); - // then - assertNotNull(institutionInfo); - checkNotNullFields(institutionInfo, "paymentServiceProvider", "dataProtectionOfficer", "city", "country", "county", "additionalInformations"); - assertEquals(onboardingData.getDescription(), institutionInfo.getDescription()); - assertEquals(onboardingData.getDigitalAddress(), institutionInfo.getDigitalAddress()); - assertEquals(onboardingData.getExternalId(), institutionInfo.getExternalId()); - assertEquals(onboardingData.getState(), institutionInfo.getStatus().name()); - assertEquals(onboardingData.getAttributes().get(0).getCode(), institutionInfo.getCategory()); - assertEquals(onboardingData.getGeographicTaxonomies().get(0).getCode(), institutionInfo.getGeographicTaxonomies().get(0).getCode()); - assertEquals(onboardingData.getGeographicTaxonomies().get(0).getDesc(), institutionInfo.getGeographicTaxonomies().get(0).getDesc()); - assertEquals(onboardingData.getZipCode(), institutionInfo.getZipCode()); - reflectionEqualsByName(onboardingData.getPaymentServiceProvider(), institutionInfo.getPaymentServiceProvider()); - reflectionEqualsByName(onboardingData.getSupportContact(), institutionInfo.getSupportContact()); - reflectionEqualsByName(onboardingData.getBilling(), institutionInfo.getBilling()); - verify(coreOnboardingApiRestClient, times(1)) - ._onboardingInfoUsingGET(institutionId, null, ACTIVE.name()); - verifyNoMoreInteractions(coreOnboardingApiRestClient); - } - @Test void updateGeographicTaxonomy() { // given @@ -624,116 +394,6 @@ void getInstitutionProducts() { } - @Test - void getAuthInfo_nullOnBoardingInfo() { - // given - String institutionId = "institutionId"; - // when - when(coreOnboardingApiRestClient._onboardingInfoUsingGET(institutionId, null, ACTIVE.name())) - .thenReturn(ResponseEntity.ok().build()); - Collection authInfos = msCoreConnector.getAuthInfo(institutionId); - // then - assertNotNull(authInfos); - assertTrue(authInfos.isEmpty()); - verify( coreOnboardingApiRestClient, times(1)) - ._onboardingInfoUsingGET(institutionId, null,ACTIVE.name()); - verifyNoMoreInteractions(coreOnboardingApiRestClient); - } - - - @Test - void getAuthInfo_nullInstitutions() { - // given - String institutionId = "institutionId"; - OnboardingInfoResponse onBoardingInfo = new OnboardingInfoResponse(); - when(coreOnboardingApiRestClient._onboardingInfoUsingGET(any(), any(), any())) - .thenReturn(ResponseEntity.ok(onBoardingInfo)); - // when - Collection authInfos = msCoreConnector.getAuthInfo(institutionId); - // then - assertNotNull(authInfos); - assertTrue(authInfos.isEmpty()); - verify(coreOnboardingApiRestClient, times(1)) - ._onboardingInfoUsingGET(institutionId, null, ACTIVE.name()); - verifyNoMoreInteractions(coreOnboardingApiRestClient); - } - - - @Test - void getAuthInfo_emptyInstitutions() { - // given - String institutionId = "institutionId"; - OnboardingInfoResponse onBoardingInfo = new OnboardingInfoResponse(); - onBoardingInfo.setInstitutions(Collections.emptyList()); - when(coreOnboardingApiRestClient._onboardingInfoUsingGET(any(), any(), any())) - .thenReturn(ResponseEntity.ok(onBoardingInfo)); - Collection authInfos = msCoreConnector.getAuthInfo(institutionId); - // then - assertNotNull(authInfos); - assertTrue(authInfos.isEmpty()); - verify(coreOnboardingApiRestClient, times(1)) - ._onboardingInfoUsingGET(institutionId, null, ACTIVE.name()); - verifyNoMoreInteractions(coreOnboardingApiRestClient); - } - - @Test - void getAuthInfo_nullProductInfo() { - // given - String institutionId = "institutionId"; - OnboardingInfoResponse onBoardingInfo = new OnboardingInfoResponse(); - OnboardedInstitutionResponse onboardingData = mockInstance(new OnboardedInstitutionResponse(), "setProductInfo"); - onboardingData.setState(ACTIVE.name()); - onBoardingInfo.setInstitutions(List.of(onboardingData)); - when(coreOnboardingApiRestClient._onboardingInfoUsingGET(any(), any(), any())) - .thenReturn(ResponseEntity.of(Optional.of(onBoardingInfo))); - // when - Collection authInfos = msCoreConnector.getAuthInfo(institutionId); - // then - assertNotNull(authInfos); - assertTrue(authInfos.isEmpty()); - verify(coreOnboardingApiRestClient, times(1)) - ._onboardingInfoUsingGET(institutionId, null, ACTIVE.name()); - verifyNoMoreInteractions(coreOnboardingApiRestClient); - } - - @Test - void getAuthInfo() { - // given - String institutionId = "institutionId"; - OnboardingInfoResponse onBoardingInfo = new OnboardingInfoResponse(); - OnboardedInstitutionResponse onboardingData1 = mockInstance(new OnboardedInstitutionResponse()); - onboardingData1.setState(ACTIVE.name()); - OnboardedInstitutionResponse onboardingData2 = mockInstance(new OnboardedInstitutionResponse()); - onboardingData2.setState(ACTIVE.name()); - OnboardedInstitutionResponse onboardingData3 = mockInstance(new OnboardedInstitutionResponse()); - onboardingData3.setId(onboardingData1.getId()); - onboardingData3.setState(ACTIVE.name()); - onBoardingInfo.setInstitutions(List.of(onboardingData1, onboardingData2, onboardingData3)); - when(coreOnboardingApiRestClient._onboardingInfoUsingGET(any(), any(), any())) - .thenReturn(ResponseEntity.ok(onBoardingInfo)); - // when - Collection authInfos = msCoreConnector.getAuthInfo(institutionId); - // then - assertNotNull(authInfos); - assertFalse(authInfos.isEmpty()); - assertEquals(1, authInfos.size()); - AuthInfo authInfo = authInfos.iterator().next(); - assertNotNull(authInfo.getProductRoles()); - assertEquals(3, authInfo.getProductRoles().size()); - authInfo.getProductRoles().forEach(productRole -> { - if (productRole.getProductId().equals(onboardingData1.getProductInfo().getId())) { - assertEquals(onboardingData1.getProductInfo().getRole(), productRole.getProductRole()); - } else if (productRole.getProductId().equals(onboardingData3.getProductInfo().getId())) { - assertEquals(onboardingData3.getProductInfo().getRole(), productRole.getProductRole()); - } else { - fail(); - } - }); - verify(coreOnboardingApiRestClient, times(1)) - ._onboardingInfoUsingGET(institutionId, null, ACTIVE.name()); - verifyNoMoreInteractions(coreOnboardingApiRestClient); - } - @ParameterizedTest @EnumSource(value = it.pagopa.selfcare.commons.base.security.PartyRole.class) void party2SelcRoleMapping(it.pagopa.selfcare.commons.base.security.PartyRole partyRole) { @@ -743,384 +403,6 @@ void party2SelcRoleMapping(it.pagopa.selfcare.commons.base.security.PartyRole pa assertEquals(PARTY_2_SELC_ROLE.apply(partyRole), authority); } - @Test - void getUsers_nullInstitutionId() { - // given - String institutionId = null; - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - // when - Executable executable = () -> msCoreConnector.getUsers(institutionId, userInfoFilter); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - assertEquals("An Institution id is required", e.getMessage()); - verifyNoInteractions(coreInstitutionApiRestClient); - } - - @Test - void getUsers_nullResponse_emptyRole_emptyProductIds_emptyProductRole_emptyUserId() { - // given - String institutionId = "institutionId"; - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - userInfoFilter.setAllowedStates(List.of(ACTIVE, SUSPENDED)); - - when(coreInstitutionApiRestClient._getUserInstitutionRelationshipsUsingGET(institutionId, null, null, ACTIVE.name() +","+ SUSPENDED.name(), null, null)) - .thenReturn(ResponseEntity.ok(Collections.emptyList())); - - Collection users = msCoreConnector.getUsers(institutionId, userInfoFilter); - // then - assertNotNull(users); - assertTrue(users.isEmpty()); - verify(coreInstitutionApiRestClient, times(1)) - ._getUserInstitutionRelationshipsUsingGET(eq(institutionId), isNull(), isNull(), notNull(), isNull(), isNull()); - verifyNoMoreInteractions(coreInstitutionApiRestClient); - } - - @Test - void getUsers_nullResponse() { - // given - String institutionId = "institutionId"; - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - when(coreInstitutionApiRestClient._getUserInstitutionRelationshipsUsingGET(institutionId, null, null, null, null, null)) - .thenReturn(ResponseEntity.ok().build()); - // when - Collection users = msCoreConnector.getUsers(institutionId, userInfoFilter); - // then - assertNotNull(users); - assertTrue(users.isEmpty()); - verify(coreInstitutionApiRestClient, times(1)) - ._getUserInstitutionRelationshipsUsingGET(eq(institutionId), isNull(), isNull(), isNull(), isNull(), isNull()); - verifyNoMoreInteractions(coreInstitutionApiRestClient); - } - - @Test - void getUsers_notEmptyProductIds() { - // given - String institutionId = "institutionId"; - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - userInfoFilter.setProductId("productId"); - userInfoFilter.setAllowedStates(List.of(ACTIVE, SUSPENDED)); - - when(coreInstitutionApiRestClient - ._getUserInstitutionRelationshipsUsingGET(institutionId, null, null, ACTIVE.name() +","+ SUSPENDED.name(), userInfoFilter.getProductId(), null)) - .thenReturn(ResponseEntity.ok().build()); - // when - Collection users = msCoreConnector.getUsers(institutionId, userInfoFilter); - // then - assertNotNull(users); - assertTrue(users.isEmpty()); - verify(coreInstitutionApiRestClient, times(1)) - ._getUserInstitutionRelationshipsUsingGET(eq(institutionId), isNull(), isNull(), notNull(), eq(userInfoFilter.getProductId()), isNull()); - verifyNoMoreInteractions(coreInstitutionApiRestClient); - } - - @Test - void getUsers_notEmptyProductRoles() { - // given - String institutionId = "institutionId"; - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - userInfoFilter.setProductRoles(List.of("api", "security")); - userInfoFilter.setAllowedStates(List.of(ACTIVE, SUSPENDED)); - when(coreInstitutionApiRestClient._getUserInstitutionRelationshipsUsingGET(institutionId, null, null, ACTIVE.name() +","+ SUSPENDED.name(), null, String.join(",", userInfoFilter.getProductRoles()))) - .thenReturn(ResponseEntity.ok(Collections.emptyList())); - // when - Collection users = msCoreConnector.getUsers(institutionId, userInfoFilter); - // then - assertNotNull(users); - assertTrue(users.isEmpty()); - verify(coreInstitutionApiRestClient, times(1)) - ._getUserInstitutionRelationshipsUsingGET(eq(institutionId), isNull(), isNull(), isNotNull(), isNull(), eq(String.join(",", userInfoFilter.getProductRoles()))); - verifyNoMoreInteractions(coreInstitutionApiRestClient); - } - - @ParameterizedTest - @EnumSource(value = SelfCareAuthority.class) - void getUsers_notEmptyRole(SelfCareAuthority selfCareAuthority) { - // given - String institutionId = "institutionId"; - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - userInfoFilter.setRole(selfCareAuthority); - userInfoFilter.setAllowedStates(List.of(ACTIVE, SUSPENDED)); - List partyRoles = new ArrayList<>(); - for (it.pagopa.selfcare.commons.base.security.PartyRole partyRole : it.pagopa.selfcare.commons.base.security.PartyRole.values()) { - if (userInfoFilter.getRole().equals(PARTY_2_SELC_ROLE.apply(partyRole))) { - partyRoles.add(partyRole.name()); - } - } - - when(coreInstitutionApiRestClient._getUserInstitutionRelationshipsUsingGET(eq(institutionId), isNull(), isNotNull(), isNotNull(), isNull(), isNull())) - .thenReturn(ResponseEntity.of(Optional.of(new ArrayList<>()))); - // when - Collection users = msCoreConnector.getUsers(institutionId, userInfoFilter); - // then - assertNotNull(users); - assertTrue(users.isEmpty()); - verify(coreInstitutionApiRestClient, times(1)) - ._getUserInstitutionRelationshipsUsingGET(eq(institutionId), isNull(), isNotNull(), isNotNull(), isNull(), isNull()); - verifyNoMoreInteractions(coreInstitutionApiRestClient); - } - - @Test - void getUsers() { - // given - String institutionId = "institutionId"; - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - userInfoFilter.setAllowedStates(List.of(ACTIVE, SUSPENDED)); - - List relationshipsResponse = new ArrayList<>(); - RelationshipResult relationshipInfo1 = mockInstance(new RelationshipResult(), "setFrom"); - String id = "id"; - relationshipInfo1.setFrom(id); - RelationshipResult relationshipInfo2 = mockInstance(new RelationshipResult(), "setFrom"); - relationshipInfo2.setFrom(id); - relationshipsResponse.add(relationshipInfo1); - relationshipsResponse.add(relationshipInfo2); - when(coreInstitutionApiRestClient._getUserInstitutionRelationshipsUsingGET(any(), any(), any(), any(), any(), any())) - .thenReturn(ResponseEntity.ok(relationshipsResponse)); - // when - Collection userInfos = msCoreConnector.getUsers(institutionId, userInfoFilter); - // then - assertNotNull(userInfos); - assertEquals(1, userInfos.size()); - UserInfo userInfo = userInfos.iterator().next(); - String prodId = null; - Map productInfoMap = userInfo.getProducts(); - for (String key : - productInfoMap.keySet()) { - prodId = key; - } - ProductInfo product = productInfoMap.get(prodId); - assertEquals(id, userInfo.getId()); - assertNotNull(product.getRoleInfos()); - assertNotNull(product.getId()); - assertNull(product.getTitle()); - assertNull(userInfo.getUser()); - assertNotNull(userInfo.getStatus()); - assertNotNull(userInfo.getRole()); - assertEquals(1, userInfo.getProducts().size()); - - assertNotNull(productInfoMap.keySet()); - verify(coreInstitutionApiRestClient, times(1)) - ._getUserInstitutionRelationshipsUsingGET(eq(institutionId), any(), isNull(), notNull(), isNull(), isNull()); - verifyNoMoreInteractions(coreInstitutionApiRestClient); - } - - @Test - void getUser() { - // given - String relationshipId = "relationshipId"; - - RelationshipResult relationshipInfo1 = mockInstance(new RelationshipResult(), "setFrom"); - relationshipInfo1.setFrom(relationshipId); - when(coreUserApiRestClientMock._getRelationshipUsingGET(anyString())) - .thenReturn(ResponseEntity.ok(relationshipInfo1)); - // when - UserInfo userInfo = msCoreConnector.getUser(relationshipId); - // then - assertNotNull(userInfo); - assertEquals(relationshipId, userInfo.getId()); - assertNull(userInfo.getUser()); - assertNotNull(userInfo.getStatus()); - assertNotNull(userInfo.getRole()); - String prodId = null; - Map productInfoMap = userInfo.getProducts(); - for (String key : - productInfoMap.keySet()) { - prodId = key; - } - assertEquals(1, userInfo.getProducts().size()); - ProductInfo product = productInfoMap.get(prodId); - assertNotNull(product.getRoleInfos()); - assertNotNull(product.getId()); - assertNull(product.getTitle()); - verify(coreUserApiRestClientMock, times(1)) - ._getRelationshipUsingGET(anyString()); - verifyNoMoreInteractions(coreUserApiRestClientMock); - } - - @Test - void relationship_info_to_user_info_function() throws IOException { - // given - File stub = ResourceUtils.getFile("classpath:stubs/PartyConnectorImplTest/getUserInstitutionRelationships/relationInfo-to-userInfo.json"); - RelationshipResult relationshipInfo = mapper.readValue(stub, RelationshipResult.class); - // when - UserInfo userInfo = CoreConnectorImpl.RELATIONSHIP_INFO_TO_USER_INFO_FUNCTION.apply(relationshipInfo); - // then - assertNull(userInfo.getUser()); - assertEquals(relationshipInfo.getState().toString(), userInfo.getStatus()); - assertEquals(relationshipInfo.getFrom(), userInfo.getId()); - String prodId = null; - Map productInfoMap = userInfo.getProducts(); - for (String key : - productInfoMap.keySet()) { - prodId = key; - } - ProductInfo product = productInfoMap.get(prodId); - assertEquals(relationshipInfo.getProduct().getId(), product.getId()); - assertEquals(1, product.getRoleInfos().size()); - RoleInfo roleInfo = product.getRoleInfos().get(0); - assertEquals(relationshipInfo.getProduct().getRole(), product.getRoleInfos().get(0).getRole()); - assertEquals(relationshipInfo.getId(), roleInfo.getRelationshipId()); - assertEquals(ADMIN, roleInfo.getSelcRole()); - } - - @Test - void getUser_mergeRoleInfos() throws IOException { - //given - String institutionId = "institutionId"; - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - - File stub = ResourceUtils.getFile("classpath:stubs/PartyConnectorImplTest/getUserInstitutionRelationships/multi-role.json"); - List relationshipsResponse = mapper.readValue(stub, new TypeReference<>() {}); - when(coreInstitutionApiRestClient._getUserInstitutionRelationshipsUsingGET(any(), any(), any(), any(), any(), any())) - .thenReturn((ResponseEntity.ok(relationshipsResponse))); - //when - Collection userInfos = msCoreConnector.getUsers(institutionId, userInfoFilter); - //then - assertEquals(1, userInfos.size()); - UserInfo userInfo = userInfos.iterator().next(); - Map productInfoMap = userInfo.getProducts(); - assertEquals(2, productInfoMap.values().size()); - assertEquals(2, productInfoMap.get("prod-io").getRoleInfos().size()); - assertEquals(1, productInfoMap.get("prod-pn").getRoleInfos().size()); - - } - - @Test - void getUsers_higherRoleForActiveUsers() throws IOException { - //given - String institutionId = "institutionId"; - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - - File stub = ResourceUtils.getFile("classpath:stubs/PartyConnectorImplTest/getUserInstitutionRelationships/higher-role-active.json"); - List relationshipsResponse = mapper.readValue(stub, new TypeReference<>() {}); - when(coreInstitutionApiRestClient._getUserInstitutionRelationshipsUsingGET(any(), any(), any(), any(), any(), any())) - .thenReturn((ResponseEntity.ok(relationshipsResponse))); - //when - Collection userInfos = msCoreConnector.getUsers(institutionId, userInfoFilter); - //Then - assertEquals(1, userInfos.size()); - UserInfo userInfo = userInfos.iterator().next(); - assertNull(userInfo.getUser()); - assertEquals(ADMIN, userInfo.getRole()); - assertEquals("ACTIVE", userInfo.getStatus()); - assertEquals(2, userInfo.getProducts().size()); - } - - @Test - void getUser_getProductFromMerge() throws IOException { - //given - String institutionId = "institutionId"; - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - - - File stub = ResourceUtils.getFile("classpath:stubs/PartyConnectorImplTest/getUserInstitutionRelationships/merge.json"); - List relationshipsResponse = mapper.readValue(stub, new TypeReference<>() {}); - when(coreInstitutionApiRestClient._getUserInstitutionRelationshipsUsingGET(any(), any(), any(), any(), any(), any())) - .thenReturn((ResponseEntity.ok(relationshipsResponse))); - //when - Collection userInfos = msCoreConnector.getUsers(institutionId, userInfoFilter); - //then - assertEquals(1, userInfos.size()); - UserInfo userInfo = userInfos.iterator().next(); - assertEquals(relationshipsResponse.size(), userInfo.getProducts().size()); - assertNull(userInfo.getUser()); - assertEquals(ADMIN, userInfo.getRole()); - assertEquals("PENDING", userInfo.getStatus()); - } - - @Test - void getUsers_higherRoleForPendingUsers() throws IOException { - //given - String institutionId = "institutionId"; - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - - - File stub = ResourceUtils.getFile("classpath:stubs/PartyConnectorImplTest/getUserInstitutionRelationships/higher-role-pending.json"); - List relationshipsResponse = mapper.readValue(stub, new TypeReference<>() {}); - when(coreInstitutionApiRestClient._getUserInstitutionRelationshipsUsingGET(any(), any(), any(), any(), any(), any())) - .thenReturn((ResponseEntity.ok(relationshipsResponse))); - //when - Collection userInfos = msCoreConnector.getUsers(institutionId, userInfoFilter); - UserInfo userInfo = userInfos.iterator().next(); - //Then - assertNull(userInfo.getUser()); - assertEquals(ADMIN, userInfo.getRole()); - assertEquals("PENDING", userInfo.getStatus()); - assertEquals(1, userInfos.size()); - } - - @Test - void getUsers_activeRoleUserDifferentStatus() throws IOException { - //given - String institutionId = "institutionId"; - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - - File stub = ResourceUtils.getFile("classpath:stubs/PartyConnectorImplTest/getUserInstitutionRelationships/active-role-different-status.json"); - List relationshipsResponse = mapper.readValue(stub, new TypeReference<>() {}); - when(coreInstitutionApiRestClient._getUserInstitutionRelationshipsUsingGET(any(), any(), any(), any(), any(), any())) - .thenReturn((ResponseEntity.ok(relationshipsResponse))); - //when - Collection userInfos = msCoreConnector.getUsers(institutionId, userInfoFilter); - UserInfo userInfo = userInfos.iterator().next(); - //Then - assertNull(userInfo.getUser()); - assertEquals(LIMITED, userInfo.getRole()); - assertEquals("ACTIVE", userInfo.getStatus()); - assertEquals(1, userInfos.size()); - } - - - @Test - void getUsers_activeRoleUserDifferentStatus_2() throws IOException { - //given - String institutionId = "institutionId"; - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - - File stub = ResourceUtils.getFile("classpath:stubs/PartyConnectorImplTest/getUserInstitutionRelationships/active-role-different-status-2.json"); - List relationshipsResponse = mapper.readValue(stub, new TypeReference<>() {}); - when(coreInstitutionApiRestClient._getUserInstitutionRelationshipsUsingGET(any(), any(), any(), any(), any(), any())) - .thenReturn((ResponseEntity.ok(relationshipsResponse))); - //when - Collection userInfos = msCoreConnector.getUsers(institutionId, userInfoFilter); - UserInfo userInfo = userInfos.iterator().next(); - //Then - assertNull(userInfo.getUser()); - assertEquals(ADMIN, userInfo.getRole()); - assertEquals("ACTIVE", userInfo.getStatus()); - assertEquals(1, userInfos.size()); - - } - - @Test - void getUsers_activeRoleUserDifferentStatus2() { - //given - String institutionId = "institutionId"; - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - - List relationshipsResponse = new ArrayList<>(); - RelationshipResult relationshipInfo1 = mockInstance(new RelationshipResult(), "setFrom"); - String id = "id"; - relationshipInfo1.setFrom(id); - relationshipInfo1.setRole(RelationshipResult.RoleEnum.valueOf(PartyRole.OPERATOR.name())); - relationshipInfo1.setState(RelationshipResult.StateEnum.valueOf(PENDING.name())); - RelationshipResult relationshipInfo2 = mockInstance(new RelationshipResult(), "setFrom"); - relationshipInfo2.setFrom(id); - relationshipInfo2.setRole(RelationshipResult.RoleEnum.valueOf(PartyRole.DELEGATE.name())); - relationshipInfo2.setState(RelationshipResult.StateEnum.valueOf(ACTIVE.name())); - relationshipsResponse.add(relationshipInfo1); - relationshipsResponse.add(relationshipInfo2); - when(coreInstitutionApiRestClient._getUserInstitutionRelationshipsUsingGET(any(), any(), any(), any(), any(), any())) - .thenReturn(ResponseEntity.ok(relationshipsResponse)); - //when - Collection userInfos = msCoreConnector.getUsers(institutionId, userInfoFilter); - UserInfo userInfo = userInfos.iterator().next(); - //Then - assertNull(userInfo.getUser()); - assertEquals(ADMIN, userInfo.getRole()); - assertEquals("ACTIVE", userInfo.getStatus()); - assertEquals(1, userInfos.size()); - - } @Test void userInfoFilter_emptyOptionals() { @@ -1145,195 +427,6 @@ void userInfoFilter_emptyOptionals() { assertNull(filter.getAllowedStates()); } - @Test - void createUsers_nullInstitutionId() { - // given - String institutionId = null; - String productId = "productId"; - String productTitle = "productTitle"; - String userId = UUID.randomUUID().toString(); - CreateUserDto createUserDto = new CreateUserDto(); - // when - Executable executable = () -> msCoreConnector.createUsers(institutionId, productId, userId, createUserDto, productTitle); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - assertEquals("An Institution id is required", e.getMessage()); - verifyNoInteractions(coreOnboardingApiRestClient); - } - - @Test - void createUsers_nullProductId() { - // given - String institutionId = "institutionId"; - String productTitle = "productTitle"; - String productId = null; - String userId = UUID.randomUUID().toString(); - CreateUserDto createUserDto = new CreateUserDto(); - // when - Executable executable = () -> msCoreConnector.createUsers(institutionId, productId, userId, createUserDto, productTitle); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - assertEquals("A Product id is required", e.getMessage()); - verifyNoInteractions(coreOnboardingApiRestClient); - } - - @Test - void createUsers_nullUser() { - // given - String institutionId = "institutionId"; - String productId = "productId"; - String productTitle = "productTitle"; - String userId = UUID.randomUUID().toString(); - CreateUserDto createUserDto = null; - // when - Executable executable = () -> msCoreConnector.createUsers(institutionId, productId, userId, createUserDto, productTitle); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - assertEquals("A User is required", e.getMessage()); - verifyNoInteractions(coreOnboardingApiRestClient); - } - - @Test - void createUsers_nullUserId() { - // given - String institutionId = "institutionId"; - String productId = "productId"; - String productTitle = "productTitle"; - String userId = null; - CreateUserDto createUserDto = new CreateUserDto(); - // when - Executable executable = () -> msCoreConnector.createUsers(institutionId, productId, userId, createUserDto, productTitle); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - assertEquals("An User Id is required", e.getMessage()); - verifyNoInteractions(coreOnboardingApiRestClient); - } - - @ParameterizedTest - @EnumSource(value = PartyRole.class) - void createUsers(PartyRole partyRole) { - // given - String institutionId = "institutionId"; - String productId = "productId"; - String productTitle = "productTitle"; - String productRoles = "Operator Api"; - String userId = UUID.randomUUID().toString(); - CreateUserDto createUserDto = mockInstance(new CreateUserDto(), "setRoles"); - CreateUserDto.Role roleMock = mockInstance(new CreateUserDto.Role(), "setPartyRole"); - roleMock.setProductRole(productRoles); - roleMock.setPartyRole(partyRole); - createUserDto.setRoles(Set.of(roleMock)); - // when - Executable executable = () -> msCoreConnector.createUsers(institutionId, productId, userId, createUserDto, productTitle); - // then - switch (partyRole) { - case SUB_DELEGATE: - assertDoesNotThrow(executable); - verify(coreOnboardingApiRestClient, times(1)) - ._onboardingInstitutionSubDelegateUsingPOST(onboardingRequestCaptor.capture()); - verifyRequest(institutionId, productId, createUserDto, onboardingRequestCaptor, userId); - break; - case OPERATOR: - assertDoesNotThrow(executable); - verify(coreOnboardingApiRestClient, times(1)) - ._onboardingInstitutionOperatorsUsingPOST(onboardingRequestCaptor.capture()); - verifyRequest(institutionId, productId, createUserDto, onboardingRequestCaptor, userId); - break; - default: - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - assertEquals("Invalid Party role", e.getMessage()); - } - verifyNoMoreInteractions(coreOnboardingApiRestClient); - } - - @ParameterizedTest - @EnumSource(value = PartyRole.class) - void checkExistingRelationshipRoles_noUserExisting(PartyRole partyRole) { - // given - String institutionId = "institutionId"; - String productId = "productId"; - String productRoles = "Operator Api"; - String userId = UUID.randomUUID().toString(); - CreateUserDto createUserDto = mockInstance(new CreateUserDto(), "setRoles"); - CreateUserDto.Role roleMock = mockInstance(new CreateUserDto.Role(), "setPartyRole"); - roleMock.setProductRole(productRoles); - roleMock.setPartyRole(partyRole); - createUserDto.setRoles(Set.of(roleMock)); - UserInfo.UserInfoFilter mockUserInfoFilter = new UserInfo.UserInfoFilter(); - mockUserInfoFilter.setProductId(productId); - mockUserInfoFilter.setUserId(userId); - mockUserInfoFilter.setAllowedStates(List.of(ACTIVE)); - List mockRelationshipsResponse = getRelationshipResultList(); - when(coreInstitutionApiRestClient._getUserInstitutionRelationshipsUsingGET(anyString(), anyString(), any(), any(), any(), any())) - .thenReturn(ResponseEntity.ok(mockRelationshipsResponse)); - // when - Assertions.assertThrows(ValidationException.class, () -> msCoreConnector.checkExistingRelationshipRoles(institutionId, productId, createUserDto, userId) - , "User role conflict"); - // then - verify(coreInstitutionApiRestClient, times(1)) - ._getUserInstitutionRelationshipsUsingGET(anyString(), any(), any(), any(), any(), any()); - } - - private static List getRelationshipResultList() { - RelationshipResult mockRelationshipResult = new RelationshipResult(); - mockRelationshipResult.setFrom("from"); - mockRelationshipResult.setId("id"); - mockRelationshipResult.setTo("to"); - it.pagopa.selfcare.core.generated.openapi.v1.dto.ProductInfo productInfo = new it.pagopa.selfcare.core.generated.openapi.v1.dto.ProductInfo(); - productInfo.setRole("MANAGER"); - mockRelationshipResult.setProduct(productInfo); - List mockRelationshipsResponse = new ArrayList<>(); - mockRelationshipsResponse.add(mockRelationshipResult); - return mockRelationshipsResponse; - } - - @Test - void createUser_multiplePartyRole() { - // given - String institutionId = "institutionId"; - String productId = "productId"; - String productTitle = "productTitle"; - String productRoles1 = "Operator Api"; - String productRoles2 = "Operator Security"; - PartyRole partyRole1 = PartyRole.OPERATOR; - PartyRole partyRole2 = PartyRole.SUB_DELEGATE; - String userId = UUID.randomUUID().toString(); - CreateUserDto createUserDto = mockInstance(new CreateUserDto(), "setRoles"); - CreateUserDto.Role roleMock1 = mockInstance(new CreateUserDto.Role(), "setPartyROle"); - CreateUserDto.Role roleMock2 = mockInstance(new CreateUserDto.Role(), "setPartyROle"); - - roleMock1.setProductRole(productRoles1); - roleMock1.setPartyRole(partyRole1); - roleMock2.setProductRole(productRoles2); - roleMock2.setPartyRole(partyRole2); - createUserDto.setRoles(Set.of(roleMock1, roleMock2)); - // when - Executable executable = () -> msCoreConnector.createUsers(institutionId, productId, userId, createUserDto, productTitle); - // then - ValidationException e = assertThrows(ValidationException.class, executable); - assertEquals("Is not allowed to create both SUB_DELEGATE and OPERATOR users", e.getMessage()); - verifyNoInteractions(coreOnboardingApiRestClient); - } - - private void verifyRequest(String institutionId, String productId, CreateUserDto createUserDto, ArgumentCaptor onboardingRequestCaptor, String userId) { - OnboardingInstitutionOperatorsRequest request = onboardingRequestCaptor.getValue(); - assertNotNull(request); - assertEquals(institutionId, request.getInstitutionId()); - assertEquals(productId, request.getProductId()); - assertNotNull(request.getUsers()); - assertEquals(1, request.getUsers().size()); - assertEquals(createUserDto.getName(), request.getUsers().get(0).getName()); - assertEquals(createUserDto.getSurname(), request.getUsers().get(0).getSurname()); - assertEquals(createUserDto.getTaxCode(), request.getUsers().get(0).getTaxCode()); - assertEquals(createUserDto.getEmail(), request.getUsers().get(0).getEmail()); - assertEquals(userId, request.getUsers().get(0).getId()); - createUserDto.getRoles().forEach(role -> request.getUsers().forEach(user -> { - assertEquals(role.getProductRole(), user.getProductRole()); - assertEquals(role.getPartyRole().name(), user.getRole().name()); - })); - } - - @Test void getGeographicTaxonomyList_nullInstitutionId() { // given @@ -1385,85 +478,6 @@ void getGeographicTaxonomyList() { verifyNoMoreInteractions(coreInstitutionApiRestClient); } - @ParameterizedTest - @EnumSource(value = PartyRole.class) - void checkExistingRelationshipRoles_userExistingConflict2 (PartyRole partyRole){ - // given - String institutionId = "institutionId"; - String productId = "productId"; - String productRoles = "Operator Api"; - String userId = UUID.randomUUID().toString(); - CreateUserDto createUserDto = mockInstance(new CreateUserDto(), "setRoles"); - CreateUserDto.Role roleMock = mockInstance(new CreateUserDto.Role(), "setPartyRole"); - roleMock.setProductRole(productRoles); - roleMock.setPartyRole(partyRole); - createUserDto.setRoles(Set.of(roleMock)); - UserInfo.UserInfoFilter mockUserInfoFilter = new UserInfo.UserInfoFilter(); - mockUserInfoFilter.setProductId(productId); - mockUserInfoFilter.setUserId(userId); - mockUserInfoFilter.setAllowedStates(List.of(ACTIVE)); - List mockRelationshipsResponse = getRelationshipResults(); - when(coreInstitutionApiRestClient._getUserInstitutionRelationshipsUsingGET(anyString(), any(), any(), any(), any(), any())) - .thenReturn(ResponseEntity.ok(mockRelationshipsResponse)); - // when - Executable executable = () -> msCoreConnector.checkExistingRelationshipRoles(institutionId, productId, createUserDto, userId); - // then - ValidationException e = assertThrows(ValidationException.class, executable); - assertEquals("User role conflict", e.getMessage()); - verify(coreInstitutionApiRestClient, times(1)) - ._getUserInstitutionRelationshipsUsingGET(anyString(), any(), any(), any(), any(), any()); - } - - private static List getRelationshipResults() { - RelationshipResult mockRelationshipInfo = new RelationshipResult(); - mockRelationshipInfo.setFrom("from"); - mockRelationshipInfo.setId("id"); - mockRelationshipInfo.setTo("to"); - it.pagopa.selfcare.core.generated.openapi.v1.dto.ProductInfo productInfo = new it.pagopa.selfcare.core.generated.openapi.v1.dto.ProductInfo(); - productInfo.setId("productId"); - productInfo.setRole("Operator security"); - mockRelationshipInfo.setProduct(productInfo); - List mockRelationshipsResponse = new ArrayList<>(); - mockRelationshipsResponse.add(mockRelationshipInfo); - return mockRelationshipsResponse; - } - - @Test - void checkExistingRelationshipRoles_userExistingNoConflict () { - // given - String institutionId = "institutionId"; - String productId = "productId"; - String productRoles = "Operator"; - String userId = UUID.randomUUID().toString(); - CreateUserDto createUserDto = mockInstance(new CreateUserDto(), "setRoles"); - CreateUserDto.Role roleMock = mockInstance(new CreateUserDto.Role(), "setPartyRole"); - roleMock.setProductRole(productRoles); - roleMock.setPartyRole(PartyRole.OPERATOR); - createUserDto.setRoles(Set.of(roleMock)); - UserInfo.UserInfoFilter mockUserInfoFilter = new UserInfo.UserInfoFilter(); - mockUserInfoFilter.setProductId(productId); - mockUserInfoFilter.setUserId(userId); - mockUserInfoFilter.setAllowedStates(List.of(ACTIVE)); - RelationshipResult mockRelationshipResult = new RelationshipResult(); - mockRelationshipResult.setFrom("from"); - mockRelationshipResult.setId("id"); - mockRelationshipResult.setTo("to"); - mockRelationshipResult.setRole(RelationshipResult.RoleEnum.valueOf(PartyRole.OPERATOR.name())); - it.pagopa.selfcare.core.generated.openapi.v1.dto.ProductInfo productInfo = new it.pagopa.selfcare.core.generated.openapi.v1.dto.ProductInfo(); - productInfo.setId("productId"); - productInfo.setRole("Operator Api"); - mockRelationshipResult.setProduct(productInfo); - List mockRelationshipsResponse = new ArrayList<>(); - mockRelationshipsResponse.add(mockRelationshipResult); - when(coreInstitutionApiRestClient._getUserInstitutionRelationshipsUsingGET(anyString(), any(), any(), any(), any(), any())) - .thenReturn(ResponseEntity.ok(mockRelationshipsResponse)); - // when - msCoreConnector.checkExistingRelationshipRoles(institutionId, productId, createUserDto, userId); - // then - verify(coreInstitutionApiRestClient, times(1)) - ._getUserInstitutionRelationshipsUsingGET(anyString(), any(), any(), any(), any(), any()); - } - private GetDelegationParameters dummyDelegationParameters() { return GetDelegationParameters.builder() .to("to") diff --git a/connector/rest/src/test/java/it/pagopa/selfcare/dashboard/connector/rest/MsCoreConnectorImplTest.java b/connector/rest/src/test/java/it/pagopa/selfcare/dashboard/connector/rest/MsCoreConnectorImplTest.java deleted file mode 100644 index e69de29bb..000000000 diff --git a/core/src/main/java/it/pagopa/selfcare/dashboard/core/InstitutionService.java b/core/src/main/java/it/pagopa/selfcare/dashboard/core/InstitutionService.java index 98dcece12..a273b77ba 100644 --- a/core/src/main/java/it/pagopa/selfcare/dashboard/core/InstitutionService.java +++ b/core/src/main/java/it/pagopa/selfcare/dashboard/core/InstitutionService.java @@ -1,44 +1,22 @@ package it.pagopa.selfcare.dashboard.core; -import it.pagopa.selfcare.commons.base.security.SelfCareAuthority; -import it.pagopa.selfcare.dashboard.connector.model.institution.*; +import it.pagopa.selfcare.dashboard.connector.model.institution.GeographicTaxonomy; +import it.pagopa.selfcare.dashboard.connector.model.institution.GeographicTaxonomyList; +import it.pagopa.selfcare.dashboard.connector.model.institution.Institution; +import it.pagopa.selfcare.dashboard.connector.model.institution.UpdateInstitutionResource; import it.pagopa.selfcare.dashboard.connector.model.product.ProductTree; -import it.pagopa.selfcare.dashboard.connector.model.user.CreateUserDto; -import it.pagopa.selfcare.dashboard.connector.model.user.UserId; -import it.pagopa.selfcare.dashboard.connector.model.user.UserInfo; -import java.util.Collection; import java.util.List; -import java.util.Optional; -import java.util.Set; public interface InstitutionService { - InstitutionInfo getInstitution(String institutionId); - Institution getInstitutionById(String institutionId); - Collection getInstitutions(String userId); - void updateInstitutionGeographicTaxonomy(String institutionId, GeographicTaxonomyList geographicTaxonomies); List getGeographicTaxonomyList(String institutionId); List getProductsTree(); - /** - * @deprecated method has been deprecated because a new method has been implemented. - * Remove the query from the repository - */ - @Deprecated(forRemoval = true, since = "1.5") - Collection getInstitutionUsers(String institutionId, Optional productId, Optional role, Optional> productRoles); - - UserInfo getInstitutionUser(String institutionId, String userId); - - Collection getInstitutionProductUsers(String institutionId, String productId, Optional role, Optional> productRoles); - - UserId createUsers(String institutionId, String productId, CreateUserDto user); - - void addUserProductRoles(String institutionId, String productId, String userId, CreateUserDto dto); Institution updateInstitutionDescription(String institutionId, UpdateInstitutionResource updatePnPGInstitutionResource); diff --git a/core/src/main/java/it/pagopa/selfcare/dashboard/core/InstitutionServiceImpl.java b/core/src/main/java/it/pagopa/selfcare/dashboard/core/InstitutionServiceImpl.java index aae78ccef..2aff228e6 100644 --- a/core/src/main/java/it/pagopa/selfcare/dashboard/core/InstitutionServiceImpl.java +++ b/core/src/main/java/it/pagopa/selfcare/dashboard/core/InstitutionServiceImpl.java @@ -2,92 +2,46 @@ import it.pagopa.selfcare.commons.base.logging.LogUtils; import it.pagopa.selfcare.commons.base.security.ProductGrantedAuthority; -import it.pagopa.selfcare.commons.base.security.SelfCareAuthority; import it.pagopa.selfcare.commons.base.security.SelfCareGrantedAuthority; import it.pagopa.selfcare.dashboard.connector.api.MsCoreConnector; import it.pagopa.selfcare.dashboard.connector.api.ProductsConnector; -import it.pagopa.selfcare.dashboard.connector.api.UserRegistryConnector; -import it.pagopa.selfcare.dashboard.connector.exception.ResourceNotFoundException; -import it.pagopa.selfcare.dashboard.connector.model.institution.*; -import it.pagopa.selfcare.dashboard.connector.model.product.PartyProduct; +import it.pagopa.selfcare.dashboard.connector.model.institution.GeographicTaxonomy; +import it.pagopa.selfcare.dashboard.connector.model.institution.GeographicTaxonomyList; +import it.pagopa.selfcare.dashboard.connector.model.institution.Institution; +import it.pagopa.selfcare.dashboard.connector.model.institution.UpdateInstitutionResource; import it.pagopa.selfcare.dashboard.connector.model.product.ProductTree; -import it.pagopa.selfcare.dashboard.connector.model.product.mapper.ProductMapper; -import it.pagopa.selfcare.dashboard.connector.model.user.*; -import it.pagopa.selfcare.dashboard.core.exception.InvalidProductRoleException; -import it.pagopa.selfcare.onboarding.common.PartyRole; -import it.pagopa.selfcare.product.entity.Product; -import it.pagopa.selfcare.product.entity.ProductRoleInfo; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.security.core.Authentication; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.stereotype.Service; import org.springframework.util.Assert; -import java.util.*; -import java.util.function.BinaryOperator; -import java.util.function.Function; -import java.util.stream.Collectors; +import java.util.List; +import java.util.Map; +import java.util.Optional; import static it.pagopa.selfcare.commons.base.security.SelfCareAuthority.LIMITED; -import static it.pagopa.selfcare.dashboard.connector.model.user.User.Fields.*; @Slf4j @Service class InstitutionServiceImpl implements InstitutionService { static final String REQUIRED_INSTITUTION_MESSAGE = "An Institution id is required"; - private static final String REQUIRED_USER_ID = "A user id is required"; - private static final EnumSet PARTY_ROLE_WHITE_LIST = EnumSet.of(PartyRole.SUB_DELEGATE, PartyRole.OPERATOR); - private static final EnumSet USER_FIELD_LIST = EnumSet.of(name, familyName, workContacts); - private static final EnumSet USER_FIELD_LIST_ENHANCED = EnumSet.of(fiscalCode, name, familyName, workContacts); - private static final String A_PRODUCT_ID_IS_REQUIRED = "A Product id is required"; - private static final String A_USER_ID_IS_REQUIRED = "A User id is required"; - private static final String AN_USER_IS_REQUIRED = "An User is required"; - private static final String AN_OPTIONAL_ROLE_OBJECT_IS_REQUIRED = "An Optional role object is required"; - private static final String AN_OPTIONAL_PRODUCT_ROLE_OBJECT_IS_REQUIRED = "An Optional product role object is required"; - private static final String A_USER_INFO_FILTER_OBJECT_IS_REQUIRED = "A UserInfoFilter object is required"; static final String REQUIRED_GEOGRAPHIC_TAXONOMIES = "An object of geographic taxonomy list is required"; - static final String REQUIRED_TOKEN_ID_MESSAGE = "A tokenId is required"; static final String REQUIRED_UPDATE_RESOURCE_MESSAGE = "An Institution update resource is required"; - - private final Optional> allowedStates; - private final UserRegistryConnector userRegistryConnector; private final MsCoreConnector msCoreConnector; private final ProductsConnector productsConnector; - protected static final BinaryOperator MERGE_FUNCTION = (inst1, inst2) -> inst1.getOnBoardingStatus().compareTo(inst2.getOnBoardingStatus()) < 0 ? inst1 : inst2; - - @Autowired - public InstitutionServiceImpl(@Value("${dashboard.institution.getUsers.filter.states}") String[] allowedStates, - UserRegistryConnector userRegistryConnector, - ProductsConnector productsConnector, + public InstitutionServiceImpl(ProductsConnector productsConnector, MsCoreConnector msCoreConnector) { - this.allowedStates = allowedStates == null || allowedStates.length == 0 - ? Optional.empty() - : Optional.of(EnumSet.copyOf(Arrays.stream(allowedStates) - .map(RelationshipState::valueOf) - .toList())); - this.userRegistryConnector = userRegistryConnector; this.productsConnector = productsConnector; this.msCoreConnector = msCoreConnector; } - @Override - public InstitutionInfo getInstitution(String institutionId) { - log.trace("getInstitution start"); - log.debug("getInstitution institutionId = {}", institutionId); - InstitutionInfo result = msCoreConnector.getOnBoardedInstitution(institutionId); - log.debug(LogUtils.CONFIDENTIAL_MARKER, "getInstitution result = {}", result); - log.trace("getInstitution end"); - return result; - } - - @Override public Institution getInstitutionById(String institutionId) { log.trace("getInstitution start"); @@ -118,15 +72,6 @@ public List getGeographicTaxonomyList(String institutionId) return result; } - @Override - public Collection getInstitutions(String userId) { - log.trace("getInstitutions start"); - Collection result = msCoreConnector.getUserProducts(userId); - log.debug(LogUtils.CONFIDENTIAL_MARKER, "getInstitutions result = {}", result); - log.trace("getInstitutions end"); - return result; - } - @Override public List getProductsTree(){ log.trace("getProductsTree start"); @@ -136,165 +81,6 @@ public List getProductsTree(){ return productTrees; } - /** - * @deprecated method has been deprecated because a new method has been implemented. - * Remove the query from the repository - */ - @Deprecated(forRemoval = true) - @Override - public Collection getInstitutionUsers(String institutionId, Optional productId, Optional role, Optional> productRoles) { - log.trace("getInstitutionUsers start"); - log.debug("getInstitutionUsers institutionId = {}, productId = {}, role = {}, productRoles = {}", institutionId, productId, role, productRoles); - Assert.hasText(institutionId, REQUIRED_INSTITUTION_MESSAGE); - Assert.notNull(productId, "An Optional Product id object is required"); - Assert.notNull(role, AN_OPTIONAL_ROLE_OBJECT_IS_REQUIRED); - Assert.notNull(productRoles, AN_OPTIONAL_PRODUCT_ROLE_OBJECT_IS_REQUIRED); - - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - userInfoFilter.setRole(role.orElse(null)); - userInfoFilter.setProductId(productId.orElse(null)); - userInfoFilter.setProductRoles(productRoles.map(relationshipStates -> relationshipStates.stream().toList()).orElse(null)); - userInfoFilter.setAllowedStates(allowedStates.map(relationshipStates -> relationshipStates.stream().toList()).orElse(null)); - Collection userInfos = getInstitutionUsers(institutionId, userInfoFilter); - userInfos.forEach(userInfo -> userInfo.setUser(userRegistryConnector.getUserByInternalId(userInfo.getId(), USER_FIELD_LIST))); - log.debug(LogUtils.CONFIDENTIAL_MARKER, "getInstitutionUsers result = {}", userInfos); - log.trace("getInstitutionUsers end"); - return userInfos; - } - - - private Collection getInstitutionUsers(String institutionId, UserInfo.UserInfoFilter userInfoFilter) { - log.trace("getInstitutionUsers start"); - log.debug("getInstitutionUsers institutionId = {}, productId = {}, role = {}, productRoles = {}", - institutionId, userInfoFilter.getProductId(), userInfoFilter.getRole(), userInfoFilter.getProductRoles()); - Assert.hasText(institutionId, REQUIRED_INSTITUTION_MESSAGE); - Assert.notNull(userInfoFilter, A_USER_INFO_FILTER_OBJECT_IS_REQUIRED); - - - Collection userInfos = msCoreConnector.getUsers(institutionId, userInfoFilter); - Map idToProductMap = productsConnector.getProductsTree().stream() - .collect(Collectors.toMap(productTree -> productTree.getNode().getId(), Function.identity())); - - userInfos.forEach(userInfo -> { - Iterator> productsIterator = userInfo.getProducts().entrySet().iterator(); - while (productsIterator.hasNext()) { - Map.Entry next = productsIterator.next(); - String key = next.getKey(); - ProductInfo prod = next.getValue(); - if (idToProductMap.containsKey(prod.getId())) { - userInfo.getProducts().get(key).setTitle(idToProductMap.get(prod.getId()).getNode().getTitle()); - } else if (idToProductMap.values().stream() - .map(ProductTree::getChildren) - .filter(Objects::nonNull) - .flatMap(Collection::stream) - .map(Product::getId) - .anyMatch(key::equals)) { - productsIterator.remove(); - } else { - productsIterator.remove(); - log.warn("No matching product found with id {}", key); - } - } - }); - - log.debug(LogUtils.CONFIDENTIAL_MARKER, "getInstitutionUsers result = {}", userInfos); - log.trace("getInstitutionUsers end"); - return userInfos; - } - - - @Override - public UserInfo getInstitutionUser(String institutionId, String userId) { - log.trace("getInstitutionUser start"); - log.debug("getInstitutionUser institutionId = {}, userId = {}", institutionId, userId); - - Assert.hasText(institutionId, REQUIRED_INSTITUTION_MESSAGE); - Assert.hasText(userId, REQUIRED_USER_ID); - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - userInfoFilter.setUserId(userId); - userInfoFilter.setAllowedStates(allowedStates.map(relationshipStates -> relationshipStates.stream().toList()).orElse(null)); - - Collection userInfos = getInstitutionUsers(institutionId, userInfoFilter); - if (!userInfos.iterator().hasNext()) { - throw new ResourceNotFoundException("No User found for the given userId"); - } - UserInfo result = userInfos.iterator().next(); - User user = userRegistryConnector.getUserByInternalId(result.getId(), USER_FIELD_LIST_ENHANCED); - result.setUser(user); - log.debug(LogUtils.CONFIDENTIAL_MARKER, "getInstitutionUser result = {}", result); - log.trace("getInstitutionUser end"); - return result; - } - - @Override - public Collection getInstitutionProductUsers(String institutionId, String productId, Optional role, Optional> productRoles) { - log.trace("getInstitutionProductUsers start"); - log.debug("getInstitutionProductUsers institutionId = {}, productId = {}, role = {}, productRoles = {}", institutionId, productId, role, productRoles); - Assert.hasText(institutionId, REQUIRED_INSTITUTION_MESSAGE); - Assert.hasText(productId, A_PRODUCT_ID_IS_REQUIRED); - Assert.notNull(role, AN_OPTIONAL_ROLE_OBJECT_IS_REQUIRED); - Assert.notNull(productRoles, AN_OPTIONAL_PRODUCT_ROLE_OBJECT_IS_REQUIRED); - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - userInfoFilter.setRole(role.orElse(null)); - userInfoFilter.setProductId(productId); - userInfoFilter.setProductRoles(productRoles.map(relationshipStates -> relationshipStates.stream().toList()).orElse(null)); - userInfoFilter.setAllowedStates(allowedStates.map(relationshipStates -> relationshipStates.stream().toList()).orElse(null)); - Collection result = msCoreConnector.getUsers(institutionId, userInfoFilter); - result.forEach(userInfo -> - userInfo.setUser(userRegistryConnector.getUserByInternalId(userInfo.getId(), USER_FIELD_LIST))); - log.debug(LogUtils.CONFIDENTIAL_MARKER, "getInstitutionProductUsers result = {}", result); - log.trace("getInstitutionProductUsers end"); - return result; - } - - - @Override - public UserId createUsers(String institutionId, String productId, CreateUserDto user) { - log.trace("createUsers start"); - log.debug(LogUtils.CONFIDENTIAL_MARKER, "createUsers institutionId = {}, productId = {}, user = {}", institutionId, productId, user); - Assert.hasText(institutionId, REQUIRED_INSTITUTION_MESSAGE); - Assert.hasText(productId, A_PRODUCT_ID_IS_REQUIRED); - Assert.notNull(user, AN_USER_IS_REQUIRED); - - Product product = productsConnector.getProduct(productId); - user.getRoles().forEach(role -> { - Map roleMappings = product.getRoleMappings(); - role.setLabel(ProductMapper.getLabel(role.getProductRole(), roleMappings).orElse(null)); - Optional partyRole = ProductMapper.getPartyRole(role.getProductRole(), roleMappings, PARTY_ROLE_WHITE_LIST); - role.setPartyRole(partyRole.orElseThrow(() -> - new InvalidProductRoleException(String.format("Product role '%s' is not valid", role.getProductRole())))); - }); - - UserId userId = userRegistryConnector.saveUser(user.getUser()); - msCoreConnector.checkExistingRelationshipRoles(institutionId, productId, user, userId.getId().toString()); - msCoreConnector.createUsers(institutionId, productId, userId.getId().toString(), user, product.getTitle()); - log.debug("createUsers result = {}", userId); - log.trace("createUsers end"); - return userId; - } - - @Override - public void addUserProductRoles(String institutionId, String productId, String userId, CreateUserDto user) { - log.trace("addProductUser start"); - log.debug("addProductUser institutionId = {}, productId = {}, userId = {}, user = {}", institutionId, productId, userId, user); - Assert.hasText(institutionId, REQUIRED_INSTITUTION_MESSAGE); - Assert.hasText(productId, A_PRODUCT_ID_IS_REQUIRED); - Assert.hasText(userId, A_USER_ID_IS_REQUIRED); - Assert.notNull(user, AN_USER_IS_REQUIRED); - - Product product = productsConnector.getProduct(productId); - user.getRoles().forEach(role -> { - Map roleMappings = product.getRoleMappings(); - role.setLabel(ProductMapper.getLabel(role.getProductRole(), roleMappings).orElse(null)); - Optional partyRole = ProductMapper.getPartyRole(role.getProductRole(), roleMappings, PARTY_ROLE_WHITE_LIST); - role.setPartyRole(partyRole.orElseThrow(() -> - new InvalidProductRoleException(String.format("Product role '%s' is not valid", role.getProductRole())))); - }); - - msCoreConnector.createUsers(institutionId, productId, userId, user, product.getTitle()); - log.trace("addProductUser end"); - } - @Override public Institution updateInstitutionDescription(String institutionId, UpdateInstitutionResource updateInstitutionResource) { log.trace("updateInstitutionDescription start"); diff --git a/core/src/test/java/it/pagopa/selfcare/dashboard/core/InstitutionServiceImplTest.java b/core/src/test/java/it/pagopa/selfcare/dashboard/core/InstitutionServiceImplTest.java index 5bae33ee5..92eaf63b9 100644 --- a/core/src/test/java/it/pagopa/selfcare/dashboard/core/InstitutionServiceImplTest.java +++ b/core/src/test/java/it/pagopa/selfcare/dashboard/core/InstitutionServiceImplTest.java @@ -1,31 +1,19 @@ package it.pagopa.selfcare.dashboard.core; import it.pagopa.selfcare.commons.base.security.ProductGrantedAuthority; -import it.pagopa.selfcare.commons.base.security.SelfCareAuthority; import it.pagopa.selfcare.commons.base.security.SelfCareGrantedAuthority; -import it.pagopa.selfcare.commons.utils.TestUtils; import it.pagopa.selfcare.dashboard.connector.api.MsCoreConnector; import it.pagopa.selfcare.dashboard.connector.api.ProductsConnector; import it.pagopa.selfcare.dashboard.connector.api.UserRegistryConnector; -import it.pagopa.selfcare.dashboard.connector.exception.ResourceNotFoundException; -import it.pagopa.selfcare.dashboard.connector.model.institution.OnboardedProduct; import it.pagopa.selfcare.dashboard.connector.model.institution.*; import it.pagopa.selfcare.dashboard.connector.model.product.ProductTree; -import it.pagopa.selfcare.dashboard.connector.model.user.*; -import it.pagopa.selfcare.dashboard.connector.model.user.User.Fields; +import it.pagopa.selfcare.dashboard.connector.model.user.CreateUserDto; import it.pagopa.selfcare.dashboard.core.config.CoreTestConfig; -import it.pagopa.selfcare.dashboard.core.exception.InvalidProductRoleException; -import it.pagopa.selfcare.onboarding.common.PartyRole; -import it.pagopa.selfcare.product.entity.Product; -import it.pagopa.selfcare.product.entity.ProductRole; -import it.pagopa.selfcare.product.entity.ProductRoleInfo; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.function.Executable; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.EnumSource; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mockito; @@ -37,16 +25,12 @@ import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit.jupiter.SpringExtension; -import java.util.*; -import java.util.stream.Collectors; +import java.util.Collections; +import java.util.List; import static it.pagopa.selfcare.commons.base.security.PartyRole.MANAGER; import static it.pagopa.selfcare.commons.base.security.PartyRole.OPERATOR; -import static it.pagopa.selfcare.commons.base.security.SelfCareAuthority.ADMIN; import static it.pagopa.selfcare.commons.utils.TestUtils.mockInstance; -import static it.pagopa.selfcare.dashboard.connector.model.institution.RelationshipState.ACTIVE; -import static it.pagopa.selfcare.dashboard.connector.model.institution.RelationshipState.SUSPENDED; -import static it.pagopa.selfcare.dashboard.connector.model.user.User.Fields.*; import static it.pagopa.selfcare.dashboard.core.InstitutionServiceImpl.*; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; @@ -99,23 +83,6 @@ void getInstitutionById() { assertEquals(institution, result); } - - @Test - void getInstitution() { - // given - String institutionId = "institutionId"; - InstitutionInfo expectedInstitutionInfo = new InstitutionInfo(); - when(msCoreConnectorMock.getOnBoardedInstitution(any())) - .thenReturn(expectedInstitutionInfo); - // when - InstitutionInfo institutionInfo = institutionService.getInstitution(institutionId); - // then - assertSame(expectedInstitutionInfo, institutionInfo); - verify(msCoreConnectorMock, times(1)) - .getOnBoardedInstitution(institutionId); - verifyNoMoreInteractions(msCoreConnectorMock); - } - @Test void updateInstitutionGeographicTaxonomy() { // given @@ -189,24 +156,6 @@ void getGeographicTaxonomyList_hasNullInstitutionId() { verifyNoInteractions(msCoreConnectorMock); } - @Test - void getInstitutions() { - // given - String userId = "userId"; - InstitutionInfo expectedInstitutionInfo = new InstitutionInfo(); - when(msCoreConnectorMock.getUserProducts(userId)) - .thenReturn(List.of(expectedInstitutionInfo)); - // when - Collection institutions = institutionService.getInstitutions(userId); - // then - assertNotNull(institutions); - assertEquals(1, institutions.size()); - assertSame(expectedInstitutionInfo, institutions.iterator().next()); - verify(msCoreConnectorMock, times(1)) - .getUserProducts(userId); - verifyNoMoreInteractions(msCoreConnectorMock); - } - @Test void getProductsTree_emptyProducts() { when(productsConnectorMock.getProductsTree()) @@ -237,907 +186,6 @@ void getProductsTree() { verifyNoInteractions(msCoreConnectorMock); } - @Test - void getInstitutionProductUsers_nullInstitutionId() { - // given - String institutionId = null; - String productId = "productId"; - Optional role = Optional.empty(); - Optional> productRole = Optional.empty(); - // when - Executable executable = () -> institutionService.getInstitutionProductUsers(institutionId, productId, role, productRole); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - Assertions.assertEquals("An Institution id is required", e.getMessage()); - verifyNoInteractions(productsConnectorMock, msCoreConnectorMock); - } - - @Test - void getInstitutionProductUsers_nullProductId() { - // given - String institutionId = "institutionId"; - String productId = null; - Optional role = Optional.empty(); - Optional> productRole = Optional.empty(); - // when - Executable executable = () -> institutionService.getInstitutionProductUsers(institutionId, productId, role, productRole); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - Assertions.assertEquals("A Product id is required", e.getMessage()); - verifyNoInteractions(productsConnectorMock, msCoreConnectorMock); - } - - @Test - void getInstitutionProductUsers_nullProductRole() { - // given - String institutionId = "institutionId"; - String productId = "productId"; - Optional role = Optional.empty(); - Optional> productRole = null; - // when - Executable executable = () -> institutionService.getInstitutionProductUsers(institutionId, productId, role, productRole); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - Assertions.assertEquals("An Optional product role object is required", e.getMessage()); - verifyNoInteractions(productsConnectorMock, msCoreConnectorMock); - } - - @Test - void getInstitutionProductUsers_nullRole() { - // given - String institutionId = "institutionId"; - String productId = "productId"; - Optional role = null; - Optional> productRole = Optional.empty(); - // when - Executable executable = () -> institutionService.getInstitutionProductUsers(institutionId, productId, role, productRole); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - Assertions.assertEquals("An Optional role object is required", e.getMessage()); - verifyNoInteractions(productsConnectorMock, msCoreConnectorMock); - } - - @Test - void getInstitutionProductUsers() { - // given - String institutionId = "institutionId"; - String productId = "productId"; - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - userInfoFilter.setProductId(productId); - userInfoFilter.setAllowedStates(List.of(ACTIVE, SUSPENDED)); - Optional role = Optional.empty(); - Optional> productRole = Optional.empty(); - UserInfo userInfo = mockInstance(new UserInfo()); - String userId = UUID.randomUUID().toString(); - userInfo.setId(userId); - User user = mockInstance(new User()); - user.setId(userId); - WorkContact contact = mockInstance(new WorkContact()); - Map workContact = new HashMap<>(); - workContact.put(institutionId, contact); - user.setWorkContacts(workContact); - when(msCoreConnectorMock.getUsers(anyString(), any())) - .thenReturn(Collections.singletonList(userInfo)); - when(userRegistryConnector.getUserByInternalId(anyString(), any())) - .thenReturn(user); - // when - Collection userInfos = institutionService.getInstitutionProductUsers(institutionId, productId, role, productRole); - // then - Assertions.assertNotNull(userInfos); - userInfos.forEach(userInfo1 -> { - TestUtils.checkNotNullFields(userInfo1, "products"); - TestUtils.checkNotNullFields(userInfo1.getUser()); - }); - ArgumentCaptor filterCaptor = ArgumentCaptor.forClass(UserInfo.UserInfoFilter.class); - verify(msCoreConnectorMock, times(1)) - .getUsers(Mockito.eq(institutionId), filterCaptor.capture()); - UserInfo.UserInfoFilter capturedFilter = filterCaptor.getValue(); - Assertions.assertNull(capturedFilter.getRole()); - assertEquals(productId, capturedFilter.getProductId()); - assertNull(capturedFilter.getProductRoles()); - assertNull(capturedFilter.getUserId()); - ArgumentCaptor> filedsCaptor = ArgumentCaptor.forClass(EnumSet.class); - verify(userRegistryConnector, times(1)) - .getUserByInternalId(Mockito.eq(userId), filedsCaptor.capture()); - EnumSet capturedFields = filedsCaptor.getValue(); - assertTrue(capturedFields.contains(name)); - assertTrue(capturedFields.contains(familyName)); - assertTrue(capturedFields.contains(workContacts)); - verifyNoMoreInteractions(msCoreConnectorMock, userRegistryConnector); - verifyNoInteractions(productsConnectorMock); - } - - @Test - void getInstitutionProductUsers_nullAllowedStates() { - //given - InstitutionServiceImpl institutionService = new InstitutionServiceImpl(null, userRegistryConnector, productsConnectorMock, msCoreConnectorMock); - String institutionId = "institutionId"; - String productId = "productId"; - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - userInfoFilter.setProductId(productId); - Optional role = Optional.empty(); - Optional> productRole = Optional.empty(); - UserInfo userInfo = mockInstance(new UserInfo()); - String userId = UUID.randomUUID().toString(); - userInfo.setId(userId); - User user = mockInstance(new User()); - user.setId(userId); - WorkContact contact = mockInstance(new WorkContact()); - Map workContact = new HashMap<>(); - workContact.put(institutionId, contact); - user.setWorkContacts(workContact); - when(msCoreConnectorMock.getUsers(anyString(), any())) - .thenReturn(Collections.singletonList(userInfo)); - when(userRegistryConnector.getUserByInternalId(anyString(), any())) - .thenReturn(user); - //when - Collection userInfos = institutionService.getInstitutionProductUsers(institutionId, productId, role, productRole); - // then - Assertions.assertNotNull(userInfos); - userInfos.forEach(userInfo1 -> { - TestUtils.checkNotNullFields(userInfo1, "products"); - TestUtils.checkNotNullFields(userInfo1.getUser()); - }); - ArgumentCaptor filterCaptor = ArgumentCaptor.forClass(UserInfo.UserInfoFilter.class); - verify(msCoreConnectorMock, times(1)) - .getUsers(Mockito.eq(institutionId), filterCaptor.capture()); - UserInfo.UserInfoFilter capturedFilter = filterCaptor.getValue(); - assertNull(capturedFilter.getRole()); - assertEquals(productId, capturedFilter.getProductId()); - assertNull(capturedFilter.getProductRoles()); - assertNull(capturedFilter.getUserId()); - assertNull(capturedFilter.getAllowedStates()); - ArgumentCaptor> filedsCaptor = ArgumentCaptor.forClass(EnumSet.class); - verify(userRegistryConnector, times(1)) - .getUserByInternalId(Mockito.eq(userId), filedsCaptor.capture()); - EnumSet capturedFields = filedsCaptor.getValue(); - assertTrue(capturedFields.contains(name)); - assertTrue(capturedFields.contains(familyName)); - assertTrue(capturedFields.contains(workContacts)); - assertFalse(capturedFields.contains(fiscalCode)); - verifyNoMoreInteractions(msCoreConnectorMock, userRegistryConnector); - } - - @Test - void emptyAllowedStates() { - //given - InstitutionServiceImpl institutionService = new InstitutionServiceImpl(new String[0], userRegistryConnector, productsConnectorMock, msCoreConnectorMock); - String institutionId = "institutionId"; - String productId = "productId"; - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - userInfoFilter.setProductId(productId); - Optional role = Optional.empty(); - Optional> productRole = Optional.empty(); - //when - Collection userInfos = institutionService.getInstitutionProductUsers(institutionId, productId, role, productRole); - // then - Assertions.assertNotNull(userInfos); - verify(msCoreConnectorMock, times(1)) - .getUsers(institutionId, userInfoFilter); - verifyNoMoreInteractions(msCoreConnectorMock); - verifyNoInteractions(productsConnectorMock); - } - - @Test - void getInstitutionUsers_nullInstitutionId() { - // given - String institutionId = null; - Optional productId = Optional.empty(); - Optional> productRole = Optional.empty(); - Optional role = Optional.empty(); - UserInfo.UserInfoFilter filter = new UserInfo.UserInfoFilter(); - // when - Executable executable = () -> institutionService.getInstitutionUsers(institutionId, productId, role, productRole); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - Assertions.assertEquals("An Institution id is required", e.getMessage()); - verifyNoInteractions(productsConnectorMock, msCoreConnectorMock); - } - - @Test - void getInstitutionUsers_nullProductIds() { - // given - String institutionId = "institutionId"; - Optional productId = null; - Optional role = Optional.empty(); - Optional> productRole = Optional.empty(); - - // when - Executable executable = () -> institutionService.getInstitutionUsers(institutionId, productId, role, productRole); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - Assertions.assertEquals("An Optional Product id object is required", e.getMessage()); - verifyNoInteractions(productsConnectorMock, msCoreConnectorMock); - } - - @Test - void getInstitutionUsers_nullProductRole() { - // given - String institutionId = "institutionId"; - Optional productId = Optional.empty(); - Optional role = Optional.empty(); - Optional> productRole = null; - - // when - Executable executable = () -> institutionService.getInstitutionUsers(institutionId, productId, role, productRole); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - Assertions.assertEquals("An Optional product role object is required", e.getMessage()); - verifyNoInteractions(productsConnectorMock, msCoreConnectorMock); - } - - @Test - void getInstitutionUsers_nullRole() { - // given - String institutionId = "institutionId"; - Optional productId = Optional.empty(); - Optional role = null; - Optional> productRole = Optional.empty(); - // when - Executable executable = () -> institutionService.getInstitutionUsers(institutionId, productId, role, productRole); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - Assertions.assertEquals("An Optional role object is required", e.getMessage()); - verifyNoInteractions(productsConnectorMock, msCoreConnectorMock); - } - - @Test - void getInstitutionUser() { - // given - String institutionId = "institutionId"; - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - userInfoFilter.setUserId("userId1"); - - UserInfo userInfoMock1 = mockInstance(new UserInfo(), 1, "setId"); - userInfoMock1.setId("userId1"); - - ProductInfo productInfo1 = new ProductInfo(); - String productId1 = "prod-1"; - productInfo1.setId(productId1); - - Map products1 = new HashMap<>(); - products1.put(productId1, productInfo1); - userInfoMock1.setProducts(products1); - - User userMock = mockInstance(new User()); - userMock.setId("userId1"); - WorkContact contact = mockInstance(new WorkContact()); - Map workContact = new HashMap<>(); - workContact.put(institutionId, contact); - userMock.setWorkContacts(workContact); - when(userRegistryConnector.getUserByInternalId(anyString(), any())) - .thenReturn(userMock); - - when(msCoreConnectorMock.getUsers(any(), any())) - .thenReturn(List.of(userInfoMock1)); - Product product1 = new Product(); - product1.setId(productId1); - - Map idToProductMap = Map.of(productId1, product1); - when(productsConnectorMock.getProductsTree()) - .thenReturn(idToProductMap.values().stream() - .map(product -> { - final ProductTree productTree = new ProductTree(); - productTree.setNode(product); - return productTree; - }).collect(Collectors.toList())); - // when - UserInfo userInfo = institutionService.getInstitutionUser(institutionId, userInfoFilter.getUserId()); - // then - TestUtils.checkNotNullFields(userInfo); - TestUtils.checkNotNullFields(userInfo.getUser()); - Map productInfoMap = userInfo.getProducts(); - Assertions.assertNotNull(userInfo.getProducts()); - Assertions.assertEquals(1, userInfo.getProducts().size()); - for (String key : productInfoMap.keySet()) { - ProductInfo productInfo = productInfoMap.get(key); - Assertions.assertEquals(idToProductMap.get(productInfo.getId()).getTitle(), productInfo.getTitle()); - } - ArgumentCaptor filterCaptor = ArgumentCaptor.forClass(UserInfo.UserInfoFilter.class); - verify(msCoreConnectorMock, times(1)) - .getUsers(Mockito.eq(institutionId), filterCaptor.capture()); - UserInfo.UserInfoFilter capturedFilter = filterCaptor.getValue(); - assertNull(capturedFilter.getRole()); - assertNull(capturedFilter.getProductId()); - assertNull(capturedFilter.getProductRoles()); - assertEquals(userInfoFilter.getUserId(), capturedFilter.getUserId()); - verify(productsConnectorMock, times(1)) - .getProductsTree(); - ArgumentCaptor> filedsCaptor = ArgumentCaptor.forClass(EnumSet.class); - verify(userRegistryConnector, times(1)) - .getUserByInternalId(Mockito.eq("userId1"), filedsCaptor.capture()); - EnumSet capturedFields = filedsCaptor.getValue(); - assertTrue(capturedFields.contains(name)); - assertTrue(capturedFields.contains(familyName)); - assertTrue(capturedFields.contains(workContacts)); - assertTrue(capturedFields.contains(fiscalCode)); - verifyNoMoreInteractions(msCoreConnectorMock, productsConnectorMock); - } - - @Test - void getInstitutionUser_nullUserId() { - // given - String institutionId = "institutionId"; - String userId = null; - // when - Executable executable = () -> institutionService.getInstitutionUser(institutionId, userId); - // then - - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - Assertions.assertEquals("A user id is required", e.getMessage()); - verifyNoInteractions(productsConnectorMock, msCoreConnectorMock); - - } - - @Test - void getInstitutionUser_userNotFound() { - // given - String institutionId = "institutionId"; - String userId = "userId1"; - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - userInfoFilter.setUserId(userId); - when(msCoreConnectorMock.getUsers(any(), any())) - .thenReturn(Collections.emptyList()); - // when - Executable executable = () -> institutionService.getInstitutionUser(institutionId, userId); - // then - ResourceNotFoundException e = assertThrows(ResourceNotFoundException.class, executable); - Assertions.assertEquals("No User found for the given userId", e.getMessage()); - ArgumentCaptor filterCaptor = ArgumentCaptor.forClass(UserInfo.UserInfoFilter.class); - verify(msCoreConnectorMock, times(1)) - .getUsers(Mockito.eq(institutionId), filterCaptor.capture()); - UserInfo.UserInfoFilter capturedFilter = filterCaptor.getValue(); - assertNull(capturedFilter.getRole()); - assertNull(capturedFilter.getProductId()); - assertNull(capturedFilter.getProductRoles()); - assertEquals(userId, capturedFilter.getUserId()); - assertEquals(List.of(ACTIVE, SUSPENDED), capturedFilter.getAllowedStates()); - verify(productsConnectorMock, times(1)) - .getProductsTree(); - verifyNoMoreInteractions(msCoreConnectorMock, productsConnectorMock, userRegistryConnector); - } - - - @Test - void getInstitutionUser_noMatchingProduct() { - // given - String institutionId = "institutionId"; - String userId = "userId1"; - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - userInfoFilter.setUserId(userId); - UserInfo userInfoMock = mockInstance(new UserInfo(), "setProducts"); - final ProductInfo productInfoMock = mockInstance(new ProductInfo(), 1, "setRoleInfos"); - Map map = new HashMap<>(); - map.put(productInfoMock.getId(), productInfoMock); - userInfoMock.setProducts(map); - when(msCoreConnectorMock.getUsers(any(), any())) - .thenReturn(List.of(userInfoMock)); - final ProductTree productTree = new ProductTree(); - Product productParentMock = new Product(); - productParentMock.setId("id1"); - productTree.setNode(productParentMock); - productTree.setChildren(Collections.emptyList()); - when(productsConnectorMock.getProductsTree()) - .thenReturn(List.of(productTree)); - User user = new User(); - user.setId("id"); - CertifiedField nameCert = new CertifiedField<>(); - nameCert.setValue("name"); - user.setName(nameCert); - CertifiedField surnameCert = new CertifiedField<>(); - surnameCert.setValue("surname"); - user.setFamilyName(surnameCert); - user.setFiscalCode("fiscalCode"); - CertifiedField mailCert = new CertifiedField<>(); - mailCert.setValue("surname"); - user.setEmail(mailCert); - user.setWorkContacts(new HashMap<>()); - when(userRegistryConnector.getUserByInternalId(any(), any())).thenReturn(user); - // when - UserInfo userInfo = institutionService.getInstitutionUser(institutionId, userId); - - Assertions.assertNotNull(userInfo.getProducts()); - Assertions.assertEquals(0, userInfo.getProducts().size()); - TestUtils.checkNotNullFields(userInfo); - TestUtils.checkNotNullFields(userInfo.getUser()); - verify(msCoreConnectorMock, times(1)) - .getUsers(Mockito.eq(institutionId), any(UserInfo.UserInfoFilter.class)); - verify(productsConnectorMock, times(1)) - .getProductsTree(); - ArgumentCaptor> fieldsCaptor = ArgumentCaptor.forClass(EnumSet.class); - verify(userRegistryConnector, times(1)) - .getUserByInternalId(any(), fieldsCaptor.capture()); - EnumSet capturedFields = fieldsCaptor.getValue(); - assertTrue(capturedFields.contains(name)); - assertTrue(capturedFields.contains(familyName)); - assertTrue(capturedFields.contains(workContacts)); - assertTrue(capturedFields.contains(fiscalCode)); - verifyNoMoreInteractions(msCoreConnectorMock, productsConnectorMock); - } - - - @Test - void getInstitutionUser_matchingChildProduct() { - // given - String institutionId = "institutionId"; - String userId = "userId1"; - UserInfo.UserInfoFilter userInfoFilter = new UserInfo.UserInfoFilter(); - userInfoFilter.setUserId(userId); - UserInfo userInfoMock = new UserInfo(); - final ProductInfo productInfoMock1 = new ProductInfo(); - productInfoMock1.setId("id1"); - final ProductInfo productInfoMock2 = new ProductInfo(); - productInfoMock2.setId("id2"); - final Map productInfoMapMock = new HashMap<>(); - productInfoMapMock.put(productInfoMock1.getId(), productInfoMock1); - productInfoMapMock.put(productInfoMock2.getId(), productInfoMock2); - userInfoMock.setProducts(productInfoMapMock); - userInfoMock.setId("userId1"); - userInfoMock.setRole(ADMIN); - userInfoMock.setStatus("ACTIVE"); - userInfoMock.setInstitutionId("institutionId"); - userInfoMock.setUserMailUuid("UUID"); - User userMock = new User(); - userMock.setId("userId1"); - userMock.setFiscalCode("fiscalCode"); - userMock.setName(new CertifiedField<>()); - userMock.setFamilyName(new CertifiedField<>()); - userMock.setEmail(new CertifiedField<>()); - WorkContact contact = new WorkContact(); - Map workContact = new HashMap<>(); - workContact.put(institutionId, contact); - userMock.setWorkContacts(workContact); - when(userRegistryConnector.getUserByInternalId(anyString(), any())) - .thenReturn(userMock); - - when(msCoreConnectorMock.getUsers(any(), any())) - .thenReturn(List.of(userInfoMock)); - final ProductTree productTreeMock = new ProductTree(); - final Product productChildMock = new Product(); - productChildMock.setId("id2"); - productTreeMock.setChildren(List.of(productChildMock)); - final Product productParentMock = new Product(); - productParentMock.setId("id1"); - productTreeMock.setNode(productParentMock); - when(productsConnectorMock.getProductsTree()) - .thenReturn(List.of(productTreeMock)); - // when - UserInfo userInfo = institutionService.getInstitutionUser(institutionId, userId); - // then - Assertions.assertNotNull(userInfo.getProducts()); - Assertions.assertEquals(1, userInfo.getProducts().size()); - TestUtils.checkNotNullFields(userInfo); - TestUtils.checkNotNullFields(userInfo.getUser()); - Assertions.assertFalse(userInfo.getProducts().containsKey(productInfoMock2.getId())); - verify(msCoreConnectorMock, times(1)) - .getUsers(Mockito.eq(institutionId), any(UserInfo.UserInfoFilter.class)); - verify(productsConnectorMock, times(1)) - .getProductsTree(); - ArgumentCaptor> fieldsCaptor = ArgumentCaptor.forClass(EnumSet.class); - verify(userRegistryConnector, times(1)) - .getUserByInternalId(Mockito.eq("userId1"), fieldsCaptor.capture()); - EnumSet capturedFields = fieldsCaptor.getValue(); - assertTrue(capturedFields.contains(name)); - assertTrue(capturedFields.contains(familyName)); - assertTrue(capturedFields.contains(workContacts)); - assertTrue(capturedFields.contains(fiscalCode)); - verifyNoMoreInteractions(msCoreConnectorMock, productsConnectorMock); - } - - @Test - void getInstitutionUsers() { - // given - String institutionId = "institutionId"; - Optional productId = Optional.of("productId"); - Optional role = Optional.of(ADMIN); - Optional> productRole = Optional.of(Set.of("Operatore")); - Optional userId = Optional.empty(); - - String userId1 = UUID.randomUUID().toString(); - String userId2 = UUID.randomUUID().toString(); - UserInfo userInfoMock1 = mockInstance(new UserInfo(), 1, "setId"); - UserInfo userInfoMock2 = mockInstance(new UserInfo(), 2, "setId"); - userInfoMock1.setId(userId1); - userInfoMock2.setId(userId2); - User userMock1 = mockInstance(new User(), 1, "setId"); - User userMock2 = mockInstance(new User(), 2, "setId"); - userMock1.setId(userId1); - WorkContact contact = mockInstance(new WorkContact()); - Map workContact = new HashMap<>(); - workContact.put(institutionId, contact); - userMock1.setWorkContacts(workContact); - userMock2.setId(userId2); - userMock2.setWorkContacts(workContact); - ProductInfo productInfo1 = new ProductInfo(); - ProductInfo productInfo2 = new ProductInfo(); - ProductInfo productInfo3 = new ProductInfo(); - - String productId1 = "prod-1"; - String productId2 = "prod-2"; - String productId3 = "prod-3"; - productInfo1.setId(productId1); - productInfo2.setId(productId2); - productInfo3.setId(productId3); - Map products1 = new HashMap<>(); - products1.put(productId1, productInfo1); - products1.put(productId2, productInfo2); - userInfoMock1.setProducts(products1); - HashMap products2 = new HashMap<>(); - products2.put(productId3, productInfo3); - userInfoMock2.setProducts(products2); - when(msCoreConnectorMock.getUsers(any(), any())) - .thenReturn(List.of(userInfoMock1, userInfoMock2)); - Product product1 = new Product(); - product1.setId(productId1); - Product product2 = new Product(); - product2.setId(productId2); - Product product3 = new Product(); - product3.setId(productId3); - Map idToProductMap = Map.of(productId1, product1, productId2, product2, productId3, product3); - when(productsConnectorMock.getProductsTree()) - .thenReturn(idToProductMap.values().stream() - .map(product -> { - final ProductTree productTree = new ProductTree(); - productTree.setNode(product); - return productTree; - }).collect(Collectors.toList())); - when(userRegistryConnector.getUserByInternalId(Mockito.eq(userId1), any())) - .thenReturn(userMock1); - when(userRegistryConnector.getUserByInternalId(Mockito.eq(userId2), any())) - .thenReturn(userMock2); - // when - Collection userInfos = institutionService.getInstitutionUsers(institutionId, productId, role, productRole); - // then - Assertions.assertNotNull(userInfos); - Assertions.assertEquals(2, userInfos.size()); - userInfos.forEach(userInfo -> { - TestUtils.checkNotNullFields(userInfo); - TestUtils.checkNotNullFields(userInfo.getUser()); - }); - UserInfo userInfo = userInfos.iterator().next(); - Map productInfoMap = userInfo.getProducts(); - Assertions.assertNotNull(userInfo.getProducts()); - Assertions.assertEquals(2, userInfo.getProducts().size()); - for (String key : productInfoMap.keySet()) { - ProductInfo productInfo = productInfoMap.get(key); - Assertions.assertEquals(idToProductMap.get(productInfo.getId()).getTitle(), productInfo.getTitle()); - } - - ArgumentCaptor filterCaptor = ArgumentCaptor.forClass(UserInfo.UserInfoFilter.class); - verify(msCoreConnectorMock, times(1)) - .getUsers(Mockito.eq(institutionId), filterCaptor.capture()); - UserInfo.UserInfoFilter capturedFilter = filterCaptor.getValue(); - assertEquals(role.get(), capturedFilter.getRole()); - assertEquals(productId.get(), capturedFilter.getProductId()); - assertNull(capturedFilter.getUserId()); - ArgumentCaptor userIdCaptor = ArgumentCaptor.forClass(String.class); - ArgumentCaptor> filedsCaptor = ArgumentCaptor.forClass(EnumSet.class); - verify(userRegistryConnector, times(2)) - .getUserByInternalId(userIdCaptor.capture(), filedsCaptor.capture()); - EnumSet capturedFields = filedsCaptor.getValue(); - List userIds = userIdCaptor.getAllValues(); - assertEquals(userIds, List.of(userId1, userId2)); - assertTrue(capturedFields.contains(name)); - assertTrue(capturedFields.contains(familyName)); - assertTrue(capturedFields.contains(workContacts)); - assertFalse(capturedFields.contains(fiscalCode)); - verify(productsConnectorMock, times(1)) - .getProductsTree(); - verifyNoMoreInteractions(msCoreConnectorMock, productsConnectorMock); - } - - @Test - void createUsers_nullInstitutionId() { - // given - String institutionId = null; - String productId = "productId"; - CreateUserDto createUserDto = new CreateUserDto(); - // when - Executable executable = () -> institutionService.createUsers(institutionId, productId, createUserDto); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - Assertions.assertEquals("An Institution id is required", e.getMessage()); - verifyNoInteractions(productsConnectorMock, msCoreConnectorMock, userRegistryConnector); - } - - @Test - void createUsers_nullProductId() { - // given - String institutionId = "institutionId"; - String productId = null; - CreateUserDto createUserDto = new CreateUserDto(); - // when - Executable executable = () -> institutionService.createUsers(institutionId, productId, createUserDto); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - Assertions.assertEquals("A Product id is required", e.getMessage()); - verifyNoInteractions(productsConnectorMock, msCoreConnectorMock, userRegistryConnector); - } - - @Test - void createUsers_nullUser() { - // given - String institutionId = "institutionId"; - String productId = "productId"; - CreateUserDto createUserDto = null; - // when - Executable executable = () -> institutionService.createUsers(institutionId, productId, createUserDto); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - Assertions.assertEquals("An User is required", e.getMessage()); - verifyNoInteractions(productsConnectorMock, msCoreConnectorMock, userRegistryConnector); - } - - @ParameterizedTest - @EnumSource(value = PartyRole.class) - void createUsers(PartyRole partyRole) { - // given - String institutionId = "institutionId"; - String productId = "productId"; - String productRoleCode1 = "productRoleCode"; - String productRoleLabel1 = "productRoleLabel"; - String productRoleCode2 = "productRoleCode2"; - String productRoleLabel2 = "productRoleLabel2"; - String productRoleCode3 = "productRoleCode3"; - String productRoleLabel3 = "productRoleLabel3"; - UUID id = UUID.randomUUID(); - UserId userId = new UserId(); - userId.setId(id); - CreateUserDto createUserDto = mockInstance(new CreateUserDto(), "setRole"); - CreateUserDto.Role roleMock1 = mockInstance(new CreateUserDto.Role(), "setProductRole"); - CreateUserDto.Role roleMock2 = mockInstance(new CreateUserDto.Role(), "setProductRole"); - CreateUserDto.Role roleMock3 = mockInstance(new CreateUserDto.Role(), "setProductRole"); - if (PartyRole.MANAGER.equals(partyRole) || PartyRole.DELEGATE.equals(partyRole)) { - roleMock1.setPartyRole(partyRole); - roleMock1.setProductRole(productRoleCode1); - createUserDto.setRoles(Set.of(roleMock1)); - } else { - roleMock1.setPartyRole(partyRole); - roleMock1.setProductRole(productRoleCode1); - roleMock2.setPartyRole(partyRole); - roleMock2.setProductRole(productRoleCode2); - roleMock3.setPartyRole(partyRole); - roleMock3.setProductRole(productRoleCode3); - createUserDto.setRoles(Set.of(roleMock1, roleMock2, roleMock3)); - } - Product product = new Product(); - product.setId(productId); - ProductRole productRole1 = new ProductRole(); - productRole1.setCode(productRoleCode1); - productRole1.setLabel(productRoleLabel1); - ProductRole productRole2 = new ProductRole(); - productRole2.setCode(productRoleCode2); - productRole2.setLabel(productRoleLabel2); - ProductRole productRole3 = new ProductRole(); - productRole3.setCode(productRoleCode3); - productRole3.setLabel(productRoleLabel3); - ProductRoleInfo productRoleInfo = new ProductRoleInfo(); - productRoleInfo.setRoles(List.of(productRole1, productRole2, productRole3)); - EnumMap map = new EnumMap<>(PartyRole.class); - map.put(partyRole, productRoleInfo); - product.setRoleMappings(map); - product.setTitle("setTitle"); - when(userRegistryConnector.saveUser(any())) - .thenReturn(userId); - when(productsConnectorMock.getProduct(anyString())) - .thenReturn(product); - // when - Executable executable = () -> institutionService.createUsers(institutionId, productId, createUserDto); - // then - if (PartyRole.SUB_DELEGATE.equals(partyRole) || PartyRole.OPERATOR.equals(partyRole)) { - assertDoesNotThrow(executable); - verify(userRegistryConnector, times(1)) - .saveUser(createUserDto.getUser()); - verify(msCoreConnectorMock, times(1)) - .createUsers(Mockito.eq(institutionId), Mockito.eq(productId), Mockito.eq(id.toString()), createUserDtoCaptor.capture(), eq("setTitle")); - createUserDtoCaptor.getValue().getRoles().forEach(role1 -> { - createUserDto.getRoles().forEach(role -> { - if (role.getLabel().equals(role1.getLabel())) { - Assertions.assertEquals(role.getPartyRole(), role1.getPartyRole()); - Assertions.assertEquals(role.getLabel(), role1.getLabel()); - } - }); - { - } - }); - TestUtils.reflectionEqualsByName(createUserDtoCaptor.getValue(), createUserDto); - } else { - InvalidProductRoleException e = assertThrows(InvalidProductRoleException.class, executable); - createUserDto.getRoles().forEach(role -> { - Assertions.assertEquals(String.format("Product role '%s' is not valid", role.getProductRole()), e.getMessage()); - }); - verifyNoInteractions(msCoreConnectorMock); - } - verify(productsConnectorMock, times(1)) - .getProduct(productId); - verifyNoMoreInteractions(productsConnectorMock); - } - - @Test - void createUsers() { - //given - String institutionId = "institutionId"; - String productId = "productId"; - String productRoleCode1 = "productRoleCode"; - String productRoleLabel1 = "productRoleLabel"; - UUID id = UUID.randomUUID(); - UserId userId = new UserId(); - userId.setId(id); - CreateUserDto createUserDto = new CreateUserDto(); - CreateUserDto.Role roleMock1 = new CreateUserDto.Role(); - roleMock1.setPartyRole(PartyRole.OPERATOR); - roleMock1.setProductRole(productRoleCode1); - createUserDto.setRoles(Set.of(roleMock1)); - Product product = new Product(); - product.setId(productId); - ProductRole productRole1 = new ProductRole(); - productRole1.setCode(productRoleCode1); - productRole1.setLabel(productRoleLabel1); - ProductRoleInfo productRoleInfo = new ProductRoleInfo(); - productRoleInfo.setRoles(List.of(productRole1)); - EnumMap map = new EnumMap<>(PartyRole.class); - map.put(PartyRole.OPERATOR, productRoleInfo); - product.setRoleMappings(map); - product.setTitle("setTitle"); - when(userRegistryConnector.saveUser(any())) - .thenReturn(userId); - when(productsConnectorMock.getProduct(anyString())) - .thenReturn(product); - //when - UserId result = institutionService.createUsers(institutionId, productId, createUserDto); - //then - assertEquals(userId.getId(), result.getId()); - verify(userRegistryConnector, times(1)) - .saveUser(createUserDto.getUser()); - verify(msCoreConnectorMock, times(1)) - .checkExistingRelationshipRoles(institutionId, productId, createUserDto, userId.getId().toString()); - verify(msCoreConnectorMock, times(1)) - .createUsers(institutionId, productId, userId.getId().toString(), createUserDto, "setTitle"); - verify(productsConnectorMock, times(1)) - .getProduct(productId); - verifyNoMoreInteractions(userRegistryConnector, msCoreConnectorMock); - } - - @Test - void addUserProductRoles_nullInstitutionId() { - //given - String institutionId = null; - String productId = null; - String userId = null; - CreateUserDto createUserDto = null; - //when - Executable executable = () -> institutionService.addUserProductRoles(institutionId, productId, userId, createUserDto); - //then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - assertEquals("An Institution id is required", e.getMessage()); - verifyNoInteractions(productsConnectorMock); - } - - @Test - void addUserProductRoles_nullProductId() { - //given - String institutionId = "institutionId"; - String productId = null; - String userId = null; - CreateUserDto createUserDto = null; - //when - Executable executable = () -> institutionService.addUserProductRoles(institutionId, productId, userId, createUserDto); - //then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - assertEquals("A Product id is required", e.getMessage()); - verifyNoInteractions(productsConnectorMock); - } - - @Test - void addUserProductRoles_nullUserId() { - //given - String institutionId = "institutionId"; - String productId = "productId"; - String userId = null; - CreateUserDto createUserDto = null; - //when - Executable executable = () -> institutionService.addUserProductRoles(institutionId, productId, userId, createUserDto); - //then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - assertEquals("A User id is required", e.getMessage()); - verifyNoInteractions(productsConnectorMock); - } - - @Test - void addUserProductRoles_nullUser() { - //given - String institutionId = "institutionId"; - String productId = "productId"; - String userId = "userId"; - CreateUserDto createUserDto = null; - //when - Executable executable = () -> institutionService.addUserProductRoles(institutionId, productId, userId, createUserDto); - //then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - assertEquals("An User is required", e.getMessage()); - verifyNoInteractions(productsConnectorMock); - } - - @ParameterizedTest - @EnumSource(value = PartyRole.class) - void addUserProductRoles(PartyRole partyRole) { - // given - String institutionId = "institutionId"; - String productId = "productId"; - String productRoleCode1 = "productRoleCode"; - String productRoleLabel1 = "productRoleLabel"; - String productRoleCode2 = "productRoleCode2"; - String productRoleLabel2 = "productRoleLabel2"; - String productRoleCode3 = "productRoleCode3"; - String productRoleLabel3 = "productRoleLabel3"; - String userId = UUID.randomUUID().toString(); - CreateUserDto createUserDto = new CreateUserDto(); - CreateUserDto.Role roleMock1 = new CreateUserDto.Role(); - CreateUserDto.Role roleMock2 = new CreateUserDto.Role(); - CreateUserDto.Role roleMock3 = new CreateUserDto.Role(); - if (PartyRole.MANAGER.equals(partyRole) || PartyRole.DELEGATE.equals(partyRole)) { - roleMock1.setPartyRole(partyRole); - roleMock1.setProductRole(productRoleCode1); - createUserDto.setRoles(Set.of(roleMock1)); - } else { - roleMock1.setPartyRole(partyRole); - roleMock1.setProductRole(productRoleCode1); - roleMock2.setPartyRole(partyRole); - roleMock2.setProductRole(productRoleCode2); - roleMock3.setPartyRole(partyRole); - roleMock3.setProductRole(productRoleCode3); - createUserDto.setRoles(Set.of(roleMock1, roleMock2, roleMock3)); - } - Product product = new Product(); - product.setId(productId); - ProductRole productRole1 = new ProductRole(); - productRole1.setCode(productRoleCode1); - productRole1.setLabel(productRoleLabel1); - ProductRole productRole2 = new ProductRole(); - productRole2.setCode(productRoleCode2); - productRole2.setLabel(productRoleLabel2); - ProductRole productRole3 = new ProductRole(); - productRole3.setCode(productRoleCode3); - productRole3.setLabel(productRoleLabel3); - ProductRoleInfo productRoleInfo = new ProductRoleInfo(); - productRoleInfo.setRoles(List.of(productRole1, productRole2, productRole3)); - EnumMap map = new EnumMap<>(PartyRole.class); - map.put(partyRole, productRoleInfo); - product.setRoleMappings(map); - product.setTitle("setTitle"); - when(productsConnectorMock.getProduct(anyString())) - .thenReturn(product); - // when - Executable executable = () -> institutionService.addUserProductRoles(institutionId, productId, userId, createUserDto); - // then - if (PartyRole.SUB_DELEGATE.equals(partyRole) || PartyRole.OPERATOR.equals(partyRole)) { - assertDoesNotThrow(executable); - verify(msCoreConnectorMock, times(1)) - .createUsers(Mockito.eq(institutionId), Mockito.eq(productId), Mockito.eq(userId), createUserDtoCaptor.capture(), eq("setTitle")); - createUserDtoCaptor.getValue().getRoles().forEach(role1 -> { - createUserDto.getRoles().forEach(role -> { - if (role.getLabel().equals(role1.getLabel())) { - Assertions.assertEquals(role.getPartyRole(), role1.getPartyRole()); - Assertions.assertEquals(role.getLabel(), role1.getLabel()); - } - }); - { - } - }); - TestUtils.reflectionEqualsByName(createUserDtoCaptor.getValue(), createUserDto); - verifyNoMoreInteractions(msCoreConnectorMock); - } else { - InvalidProductRoleException e = assertThrows(InvalidProductRoleException.class, executable); - createUserDto.getRoles().forEach(role -> { - Assertions.assertEquals(String.format("Product role '%s' is not valid", role.getProductRole()), e.getMessage()); - }); - verifyNoInteractions(msCoreConnectorMock); - } - verify(productsConnectorMock, times(1)) - .getProduct(productId); - verifyNoInteractions(userRegistryConnector); - verifyNoMoreInteractions(productsConnectorMock); - } @Test void updateInstitutionDescription() { diff --git a/web/src/main/java/it/pagopa/selfcare/dashboard/web/config/MethodSecurityConfig.java b/web/src/main/java/it/pagopa/selfcare/dashboard/web/config/MethodSecurityConfig.java index 924813005..01bd31b2c 100644 --- a/web/src/main/java/it/pagopa/selfcare/dashboard/web/config/MethodSecurityConfig.java +++ b/web/src/main/java/it/pagopa/selfcare/dashboard/web/config/MethodSecurityConfig.java @@ -1,11 +1,8 @@ package it.pagopa.selfcare.dashboard.web.config; -import it.pagopa.selfcare.dashboard.connector.api.MsCoreConnector; import it.pagopa.selfcare.dashboard.connector.api.UserApiConnector; import it.pagopa.selfcare.dashboard.connector.api.UserGroupConnector; -import it.pagopa.selfcare.dashboard.web.security.SelfCarePermissionEvaluator; import it.pagopa.selfcare.dashboard.web.security.SelfCarePermissionEvaluatorV2; -import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler; import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler; @@ -16,31 +13,21 @@ @EnableGlobalMethodSecurity(prePostEnabled = true) public class MethodSecurityConfig extends GlobalMethodSecurityConfiguration { - private final MsCoreConnector msCoreConnector; private final UserApiConnector userApiConnector; private final UserGroupConnector userGroupConnector; - private final String securityConnectorType; - public MethodSecurityConfig(MsCoreConnector msCoreConnector, - UserApiConnector userApiConnector, - UserGroupConnector userGroupConnector, - @Value("${dashboard.security.connector}") String securityConnectorType) { - this.msCoreConnector = msCoreConnector; + public MethodSecurityConfig(UserApiConnector userApiConnector, + UserGroupConnector userGroupConnector) { this.userApiConnector = userApiConnector; this.userGroupConnector = userGroupConnector; - this.securityConnectorType = securityConnectorType; } @Override protected MethodSecurityExpressionHandler createExpressionHandler() { DefaultMethodSecurityExpressionHandler expressionHandler = new DefaultMethodSecurityExpressionHandler(); - if(securityConnectorType.equalsIgnoreCase("v1")) { - expressionHandler.setPermissionEvaluator(new SelfCarePermissionEvaluator(msCoreConnector)); - }else { - expressionHandler.setPermissionEvaluator(new SelfCarePermissionEvaluatorV2(userApiConnector, userGroupConnector)); - } + expressionHandler.setPermissionEvaluator(new SelfCarePermissionEvaluatorV2(userApiConnector, userGroupConnector)); return expressionHandler; } diff --git a/web/src/main/java/it/pagopa/selfcare/dashboard/web/controller/InstitutionController.java b/web/src/main/java/it/pagopa/selfcare/dashboard/web/controller/InstitutionController.java index c71fa4eda..4f6d0ccd2 100644 --- a/web/src/main/java/it/pagopa/selfcare/dashboard/web/controller/InstitutionController.java +++ b/web/src/main/java/it/pagopa/selfcare/dashboard/web/controller/InstitutionController.java @@ -4,42 +4,38 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import it.pagopa.selfcare.commons.base.logging.LogUtils; -import it.pagopa.selfcare.commons.base.security.SelfCareAuthority; -import it.pagopa.selfcare.commons.base.security.SelfCareUser; import it.pagopa.selfcare.dashboard.connector.model.delegation.GetDelegationParameters; import it.pagopa.selfcare.dashboard.connector.model.delegation.GetDelegationsMode; import it.pagopa.selfcare.dashboard.connector.model.delegation.Order; import it.pagopa.selfcare.dashboard.connector.model.institution.GeographicTaxonomyList; import it.pagopa.selfcare.dashboard.connector.model.institution.Institution; -import it.pagopa.selfcare.dashboard.connector.model.institution.InstitutionInfo; import it.pagopa.selfcare.dashboard.connector.model.product.ProductTree; -import it.pagopa.selfcare.dashboard.connector.model.user.UserId; -import it.pagopa.selfcare.dashboard.connector.model.user.UserInfo; import it.pagopa.selfcare.dashboard.core.DelegationService; import it.pagopa.selfcare.dashboard.core.FileStorageService; import it.pagopa.selfcare.dashboard.core.InstitutionService; -import it.pagopa.selfcare.dashboard.web.InstitutionBaseResource; -import it.pagopa.selfcare.dashboard.web.model.*; +import it.pagopa.selfcare.dashboard.web.model.GeographicTaxonomyListDto; +import it.pagopa.selfcare.dashboard.web.model.GeographicTaxonomyResource; +import it.pagopa.selfcare.dashboard.web.model.InstitutionResource; +import it.pagopa.selfcare.dashboard.web.model.UpdateInstitutionDto; import it.pagopa.selfcare.dashboard.web.model.delegation.DelegationResource; -import it.pagopa.selfcare.dashboard.web.model.mapper.*; -import it.pagopa.selfcare.dashboard.web.model.product.ProductUserResource; +import it.pagopa.selfcare.dashboard.web.model.mapper.DelegationMapper; +import it.pagopa.selfcare.dashboard.web.model.mapper.GeographicTaxonomyMapper; +import it.pagopa.selfcare.dashboard.web.model.mapper.InstitutionResourceMapper; +import it.pagopa.selfcare.dashboard.web.model.mapper.ProductsMapper; import it.pagopa.selfcare.dashboard.web.model.product.ProductsResource; -import it.pagopa.selfcare.dashboard.web.model.user.UserIdResource; -import it.pagopa.selfcare.dashboard.web.model.user.UserProductRoles; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.validation.Valid; import java.io.IOException; -import java.util.*; -import java.util.stream.Collectors; +import java.util.List; +import java.util.Objects; @Slf4j @RestController @@ -84,25 +80,6 @@ public Object saveInstitutionLogo(@ApiParam("${swagger.dashboard.institutions.mo } - @GetMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseStatus(HttpStatus.OK) - @ApiOperation(value = "", notes = "${swagger.dashboard.institutions.api.getInstitutions}") - public List getInstitutions(Authentication authentication) { - - log.trace("getInstitutions start"); - String userId = ((SelfCareUser) authentication.getPrincipal()).getId(); - Collection institutions = institutionService.getInstitutions(userId); - - List result = institutions.stream() - .map(institutionResourceMapper::toResource) - .collect(Collectors.toList()); - log.debug(LogUtils.CONFIDENTIAL_MARKER, "getInstitutions result = {}", result); - log.trace("getInstitutions end"); - - return result; - } - - @GetMapping(value = "/{institutionId}", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "", notes = "${swagger.dashboard.institutions.api.getInstitution}") @@ -135,7 +112,7 @@ public void updateInstitutionGeographicTaxonomy(@ApiParam("${swagger.dashboard.i log.trace("updateInstitutionGeographicTaxonomy start"); log.debug("updateInstitutionGeographicTaxonomy institutionId = {}, geographic taxonomies = {}", institutionId, geographicTaxonomyListDto); GeographicTaxonomyList geographicTaxonomies = new GeographicTaxonomyList(); - geographicTaxonomies.setGeographicTaxonomyList(geographicTaxonomyListDto.getGeographicTaxonomyDtoList().stream().map(GeographicTaxonomyMapper::fromDto).collect(Collectors.toList())); + geographicTaxonomies.setGeographicTaxonomyList(geographicTaxonomyListDto.getGeographicTaxonomyDtoList().stream().map(GeographicTaxonomyMapper::fromDto).toList()); institutionService.updateInstitutionGeographicTaxonomy(institutionId, geographicTaxonomies); log.trace("updateInstitutionsGeographicTaxonomy end"); } @@ -151,67 +128,12 @@ public List getInstitutionGeographicTaxonomy(@ApiPar List geographicTaxonomies = institutionService.getGeographicTaxonomyList(institutionId) .stream() .map(GeographicTaxonomyMapper::toResource) - .collect(Collectors.toList()); + .toList(); log.debug("getInstitutionGeographicTaxonomy result = {}", geographicTaxonomies); log.trace("getInstitutionGeographicTaxonomy end"); return geographicTaxonomies; } - /** - * @deprecated since it's not used - */ - @Deprecated(forRemoval = true, since = "1.5") - @GetMapping(value = "/{institutionId}/users", produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseStatus(HttpStatus.OK) - @ApiOperation(value = "", notes = "${swagger.dashboard.institutions.api.getInstitutionUsers}") - @PreAuthorize("hasPermission(#institutionId, 'InstitutionResource', 'ANY')") - public List getInstitutionUsers(@ApiParam("${swagger.dashboard.institutions.model.id}") - @PathVariable("institutionId") - String institutionId, - @ApiParam("${swagger.dashboard.products.model.id}") - @RequestParam(value = "productId", required = false) - Optional productId, - @ApiParam("${swagger.dashboard.user.model.role}") - @RequestParam(value = "role", required = false) - Optional role, - @ApiParam("${swagger.dashboard.user.model.productRoles}") - @RequestParam(value = "productRoles", required = false) - Optional> productRoles) { - - log.trace("getInstitutionUsers start"); - log.debug("getInstitutionUsers institutionId = {}, role = {}, productId = {}", institutionId, role, productId); - Collection userInfos = institutionService.getInstitutionUsers(institutionId, productId, role, productRoles); - List result = userInfos.stream() - .map(UserMapper::toInstitutionUser) - .collect(Collectors.toList()); - log.debug("getInstitutionUsers result = {}", result); - log.trace("getInstitutionUsers end"); - - return result; - } - - - @GetMapping(value = "/{institutionId}/users/{userId}", produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseStatus(HttpStatus.OK) - @ApiOperation(value = "", notes = "${swagger.dashboard.institutions.api.getInstitutionUser}") - @PreAuthorize("hasPermission(#institutionId, 'InstitutionResource', 'ANY')") - public InstitutionUserDetailsResource getInstitutionUser(@ApiParam("${swagger.dashboard.institutions.model.id}") - @PathVariable("institutionId") - String institutionId, - @ApiParam("${swagger.dashboard.user.model.id}") - @PathVariable("userId") - String userId) { - - log.trace("getInstitutionUser start"); - log.debug("getInstitutionUser institutionId = {}, userId = {}", institutionId, userId); - UserInfo userInfo = institutionService.getInstitutionUser(institutionId, userId); - InstitutionUserDetailsResource result = UserMapper.toInstitutionUserDetails(userInfo); - log.debug(LogUtils.CONFIDENTIAL_MARKER, "getInstitutionUser result = {}", result); - log.trace("getInstitutionUser end"); - - return result; - } - @GetMapping(value = "/products", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "", notes = "${swagger.dashboard.institutions.api.getInstitutionProducts}") @@ -222,7 +144,7 @@ public List getProductsTree() { List products = institutionService.getProductsTree(); List result = products.stream() .map(ProductsMapper::toResource) - .collect(Collectors.toList()); + .toList(); log.debug("getProducts result = {}", result); log.debug("getProducts result = {}", result); log.trace("getProducts end"); @@ -230,84 +152,6 @@ public List getProductsTree() { return result; } - @GetMapping(value = "/{institutionId}/products/{productId}/users", produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseStatus(HttpStatus.OK) - @ApiOperation(value = "", notes = "${swagger.dashboard.institutions.api.getInstitutionProductUsers}") - @PreAuthorize("hasPermission(new it.pagopa.selfcare.dashboard.web.security.ProductAclDomain(#institutionId, #productId), 'ANY')") - public List getInstitutionProductUsers(@ApiParam("${swagger.dashboard.institutions.model.id}") - @PathVariable("institutionId") - String institutionId, - @ApiParam("${swagger.dashboard.products.model.id}") - @PathVariable("productId") - String productId, - @ApiParam("${swagger.dashboard.user.model.role}") - @RequestParam(value = "role", required = false) - Optional role, - @ApiParam("${swagger.dashboard.user.model.productRoles}") - @RequestParam(value = "productRoles", required = false) - Optional> productRoles) { - - log.trace("getInstitutionProductUsers start"); - log.debug("getInstitutionProductUsers institutionId = {}, productId = {}, role = {}", institutionId, productId, role); - - Collection userInfos = institutionService.getInstitutionProductUsers(institutionId, productId, role, productRoles); - List result = userInfos.stream() - .map(UserMapper::toProductUser) - .collect(Collectors.toList()); - log.debug("getInstitutionProductUsers result = {}", result); - log.trace("getInstitutionProductUsers end"); - - return result; - } - - - @PostMapping(value = "/{institutionId}/products/{productId}/users", produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseStatus(HttpStatus.CREATED) - @ApiOperation(value = "", notes = "${swagger.dashboard.institutions.api.createInstitutionProductUser}") - @PreAuthorize("hasPermission(new it.pagopa.selfcare.dashboard.web.security.ProductAclDomain(#institutionId, #productId), 'ADMIN')") - public UserIdResource createInstitutionProductUser(@ApiParam("${swagger.dashboard.institutions.model.id}") - @PathVariable("institutionId") - String institutionId, - @ApiParam("${swagger.dashboard.products.model.id}") - @PathVariable("productId") - String productId, - @ApiParam("${swagger.dashboard.user.model.role}") - @RequestBody - @Valid - CreateUserDto user) { - - log.trace("createInstitutionProductUser start"); - log.debug(LogUtils.CONFIDENTIAL_MARKER, "createInstitutionProductUser institutionId = {}, productId = {}, user = {}", institutionId, productId, user); - UserId userId = institutionService.createUsers(institutionId, productId, UserMapper.fromCreateUserDto(user, institutionId)); - UserIdResource result = UserMapper.toIdResource(userId); - log.debug("createInstitutionProductUser result = {}", result); - log.trace("createInstitutionProductUser end"); - return result; - } - - @PutMapping(value = "/{institutionId}/products/{productId}/users/{userId}", produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseStatus(HttpStatus.CREATED) - @ApiOperation(value = "", notes = "${swagger.dashboard.institutions.api.addUserProductRoles}") - @PreAuthorize("hasPermission(new it.pagopa.selfcare.dashboard.web.security.ProductAclDomain(#institutionId, #productId), 'ADMIN')") - public void addUserProductRoles(@ApiParam("${swagger.dashboard.institutions.model.id}") - @PathVariable("institutionId") - String institutionId, - @ApiParam("${swagger.dashboard.products.model.id}") - @PathVariable("productId") - String productId, - @ApiParam("${swagger.dashboard.user.model.id}") - @PathVariable("userId") - String userId, - @ApiParam("${swagger.dashboard.user.model.productRoles}") - @RequestBody - @Valid - UserProductRoles userProductRoles) { - log.trace("addUserProductRoles start"); - log.debug("institutionId = {}, productId = {}, userId = {}, userProductRoles = {}", institutionId, productId, userId, userProductRoles); - institutionService.addUserProductRoles(institutionId, productId, userId, UserMapper.toCreateUserDto(userProductRoles)); - log.trace("addUserProductRoles end"); - } - @PutMapping(value = "/{institutionId}", produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.OK) @ApiOperation(value = "", notes = "${swagger.dashboard.institutions.api.updateInstitutionDescription}") diff --git a/web/src/main/java/it/pagopa/selfcare/dashboard/web/security/PartyAuthoritiesRetriever.java b/web/src/main/java/it/pagopa/selfcare/dashboard/web/security/PartyAuthoritiesRetriever.java deleted file mode 100644 index 29927a099..000000000 --- a/web/src/main/java/it/pagopa/selfcare/dashboard/web/security/PartyAuthoritiesRetriever.java +++ /dev/null @@ -1,72 +0,0 @@ -package it.pagopa.selfcare.dashboard.web.security; - -import it.pagopa.selfcare.commons.base.logging.LogUtils; -import it.pagopa.selfcare.commons.base.security.ProductGrantedAuthority; -import it.pagopa.selfcare.commons.base.security.SelfCareGrantedAuthority; -import it.pagopa.selfcare.commons.base.security.SelfCareUser; -import it.pagopa.selfcare.commons.web.security.AuthoritiesRetriever; -import it.pagopa.selfcare.commons.web.security.AuthoritiesRetrieverException; -import it.pagopa.selfcare.dashboard.connector.api.MsCoreConnector; -import it.pagopa.selfcare.dashboard.connector.model.auth.AuthInfo; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.stereotype.Component; - -import java.util.Collection; -import java.util.function.Function; -import java.util.stream.Collectors; - -@Slf4j -@Component -@ConditionalOnProperty( - value="dashboard.security.connector", - havingValue = "v1", - matchIfMissing = true) -class PartyAuthoritiesRetriever implements AuthoritiesRetriever { - - private final MsCoreConnector msCoreConnector; - - - @Autowired - public PartyAuthoritiesRetriever(MsCoreConnector msCoreConnector) { - this.msCoreConnector = msCoreConnector; - } - - - @Override - public Collection retrieveAuthorities() { - try { - log.trace("retrieveAuthorities start"); - Collection authorities = null; - - Collection authInfos = msCoreConnector.getAuthInfo(null); - - if (authInfos != null) { - authorities = authInfos.stream() - .map(authInfo -> new SelfCareGrantedAuthority(authInfo.getInstitutionId(), authInfo.getProductRoles().stream() - .map(productRole -> new ProductGrantedAuthority(productRole.getPartyRole(), - productRole.getProductRole(), - productRole.getProductId())) - .collect(Collectors.toMap(ProductGrantedAuthority::getProductId, - Function.identity(), - ProductGrantedAuthority.MERGE)) - .values())) - .collect(Collectors.toList()); - } - - log.debug(LogUtils.CONFIDENTIAL_MARKER, "retrieved authorities = {}", authorities); - log.trace("retrieveAuthorities end"); - return authorities; - } catch (AuthoritiesRetrieverException e){ - Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); - SelfCareUser selfCareUser = (SelfCareUser) authentication.getPrincipal(); - log.error("retrieveAuthorities error for user {}, error message: {}", selfCareUser.getId(), e.getMessage()); - throw new RuntimeException(e.getMessage()); - } - } - -} \ No newline at end of file diff --git a/web/src/main/java/it/pagopa/selfcare/dashboard/web/security/SelfCarePermissionEvaluator.java b/web/src/main/java/it/pagopa/selfcare/dashboard/web/security/SelfCarePermissionEvaluator.java deleted file mode 100644 index e7d893a61..000000000 --- a/web/src/main/java/it/pagopa/selfcare/dashboard/web/security/SelfCarePermissionEvaluator.java +++ /dev/null @@ -1,96 +0,0 @@ -package it.pagopa.selfcare.dashboard.web.security; - -import it.pagopa.selfcare.commons.base.logging.LogUtils; -import it.pagopa.selfcare.commons.base.security.SelfCareGrantedAuthority; -import it.pagopa.selfcare.dashboard.connector.api.MsCoreConnector; -import it.pagopa.selfcare.dashboard.connector.model.user.UserInfo; -import it.pagopa.selfcare.dashboard.web.model.InstitutionResource; -import lombok.extern.slf4j.Slf4j; -import org.springframework.security.access.PermissionEvaluator; -import org.springframework.security.core.Authentication; -import org.springframework.util.Assert; -import org.springframework.util.CollectionUtils; - -import java.io.Serializable; - -@Slf4j -public class SelfCarePermissionEvaluator implements PermissionEvaluator { - - public static final String ANY_PERMISSION = "ANY"; - public static final String RELATIONSHIP_ID = "relationshipId"; - private final MsCoreConnector msCoreConnector; - - public SelfCarePermissionEvaluator(MsCoreConnector msCoreConnector) { - this.msCoreConnector = msCoreConnector; - } - - - @Override - public boolean hasPermission(Authentication authentication, Object targetDomainObject, Object permission) { - log.trace("hasPermission start"); - log.debug(LogUtils.CONFIDENTIAL_MARKER, "hasPermission authentication = {}, targetDomainObject = {}, permission = {}" , authentication, targetDomainObject, permission); - - Assert.notNull(authentication, "An authentication is required"); - Assert.notNull(permission, "A permission is required"); - - boolean result = false; - - if (targetDomainObject != null && ProductAclDomain.class.equals(targetDomainObject.getClass())) { - ProductAclDomain productAclDomain = (ProductAclDomain) targetDomainObject; - result = authentication.getAuthorities() - .stream() - .filter(grantedAuthority -> SelfCareGrantedAuthority.class.isAssignableFrom(grantedAuthority.getClass())) - .map(SelfCareGrantedAuthority.class::cast) - .filter(grantedAuthority -> grantedAuthority.getInstitutionId().equals(productAclDomain.getInstitutionId())) - .filter(grantedAuthority -> grantedAuthority.getRoleOnProducts().containsKey(productAclDomain.getProductId())) - .map(grantedAuthority -> grantedAuthority.getRoleOnProducts().get(productAclDomain.getProductId())) - .anyMatch(grantedAuthority -> ANY_PERMISSION.equals(permission) || permission.equals(grantedAuthority.getAuthority())); - } - - log.debug("hasPermission result = {}", result); - log.trace("hasPermission end"); - return result; - } - - - @Override - public boolean hasPermission(Authentication authentication, Serializable targetId, String targetType, Object permission) { - log.trace("hasPermission start"); - log.debug(LogUtils.CONFIDENTIAL_MARKER, "hasPermission authentication = {}, targetId = {}, targetType = {}, permission = {}" , authentication, targetId, targetType, permission); - - Assert.notNull(authentication, "An authentication is required"); - Assert.notNull(targetType, "A targetType is required"); - Assert.notNull(permission, "A permission is required"); - - boolean result = false; - - if (targetId != null && InstitutionResource.class.getSimpleName().equals(targetType)) { - result = authentication.getAuthorities() - .stream() - .filter(grantedAuthority -> SelfCareGrantedAuthority.class.isAssignableFrom(grantedAuthority.getClass())) - .map(SelfCareGrantedAuthority.class::cast) - .filter(grantedAuthority -> targetId.toString().equals(grantedAuthority.getInstitutionId())) - .anyMatch(grantedAuthority -> ANY_PERMISSION.equals(permission) || permission.equals(grantedAuthority.getAuthority())); - } - - if (targetId != null && RELATIONSHIP_ID.equals(targetType)) { - UserInfo userInfo = msCoreConnector.getUser(targetId.toString()); - if(!CollectionUtils.isEmpty(userInfo.getProducts()) && userInfo.getProducts().size() == 1) { - String productId = userInfo.getProducts().keySet().stream().toList().get(0); - result = authentication.getAuthorities() - .stream() - .filter(grantedAuthority -> SelfCareGrantedAuthority.class.isAssignableFrom(grantedAuthority.getClass())) - .map(SelfCareGrantedAuthority.class::cast) - .filter(grantedAuthority -> grantedAuthority.getInstitutionId().equals(userInfo.getInstitutionId())) - .filter(grantedAuthority -> grantedAuthority.getRoleOnProducts().containsKey(productId)) - .map(grantedAuthority -> grantedAuthority.getRoleOnProducts().get(productId)) - .anyMatch(grantedAuthority -> ANY_PERMISSION.equals(permission) || permission.equals(grantedAuthority.getAuthority())); - } - } - - log.debug("hasPermission result = {}", result); - log.trace("hasPermission end"); - return result; - } - -} diff --git a/web/src/test/java/it/pagopa/selfcare/dashboard/web/controller/InstitutionControllerTest.java b/web/src/test/java/it/pagopa/selfcare/dashboard/web/controller/InstitutionControllerTest.java index 275f4a571..3b01fb3d6 100644 --- a/web/src/test/java/it/pagopa/selfcare/dashboard/web/controller/InstitutionControllerTest.java +++ b/web/src/test/java/it/pagopa/selfcare/dashboard/web/controller/InstitutionControllerTest.java @@ -2,30 +2,23 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; -import it.pagopa.selfcare.commons.base.security.SelfCareAuthority; -import it.pagopa.selfcare.commons.base.security.SelfCareUser; -import it.pagopa.selfcare.dashboard.connector.exception.ResourceNotFoundException; import it.pagopa.selfcare.dashboard.connector.model.delegation.*; -import it.pagopa.selfcare.dashboard.connector.model.institution.*; +import it.pagopa.selfcare.dashboard.connector.model.institution.GeographicTaxonomy; +import it.pagopa.selfcare.dashboard.connector.model.institution.GeographicTaxonomyList; +import it.pagopa.selfcare.dashboard.connector.model.institution.Institution; +import it.pagopa.selfcare.dashboard.connector.model.institution.UpdateInstitutionResource; import it.pagopa.selfcare.dashboard.connector.model.product.ProductTree; -import it.pagopa.selfcare.dashboard.connector.model.user.UserId; -import it.pagopa.selfcare.dashboard.connector.model.user.UserInfo; import it.pagopa.selfcare.dashboard.core.DelegationService; import it.pagopa.selfcare.dashboard.core.FileStorageService; import it.pagopa.selfcare.dashboard.core.InstitutionService; import it.pagopa.selfcare.dashboard.web.config.WebTestConfig; import it.pagopa.selfcare.dashboard.web.handler.DashboardExceptionsHandler; -import it.pagopa.selfcare.dashboard.web.model.GET_INSTITUTION_MODE; import it.pagopa.selfcare.dashboard.web.model.GeographicTaxonomyListDto; -import it.pagopa.selfcare.dashboard.web.model.InstitutionResource; -import it.pagopa.selfcare.dashboard.web.model.InstitutionUserResource; import it.pagopa.selfcare.dashboard.web.model.delegation.DelegationResource; import it.pagopa.selfcare.dashboard.web.model.mapper.DelegationMapperImpl; import it.pagopa.selfcare.dashboard.web.model.mapper.InstitutionResourceMapperImpl; import it.pagopa.selfcare.dashboard.web.model.product.ProductsResource; -import it.pagopa.selfcare.dashboard.web.model.user.UserProductRoles; import it.pagopa.selfcare.product.entity.Product; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.InjectMocks; @@ -37,9 +30,7 @@ import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.core.io.Resource; import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; import org.springframework.mock.web.MockMultipartFile; -import org.springframework.security.core.Authentication; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; @@ -48,20 +39,17 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import org.springframework.util.MimeTypeUtils; -import java.util.*; +import java.util.Collections; +import java.util.List; import static it.pagopa.selfcare.commons.utils.TestUtils.mockInstance; -import static java.util.Collections.singletonList; -import static java.util.UUID.randomUUID; import static org.assertj.core.api.AssertionsForClassTypes.assertThat; -import static org.hamcrest.Matchers.is; import static org.junit.jupiter.api.Assertions.*; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.*; -import static org.springframework.http.MediaType.APPLICATION_JSON; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @WebMvcTest(value = {InstitutionController.class}, excludeAutoConfiguration = SecurityAutoConfiguration.class) @ContextConfiguration(classes = {InstitutionController.class, DelegationMapperImpl.class, WebTestConfig.class, DashboardExceptionsHandler.class, InstitutionResourceMapperImpl.class}) @@ -135,7 +123,7 @@ void getInstitution_institutionInfoNotNull() throws Exception { return institution; }); // when - MvcResult result = mvc.perform(MockMvcRequestBuilders + mvc.perform(MockMvcRequestBuilders .get(BASE_URL + "/{institutionId}", institutionId) .contentType(APPLICATION_JSON_VALUE) .accept(APPLICATION_JSON_VALUE)) @@ -147,60 +135,6 @@ void getInstitution_institutionInfoNotNull() throws Exception { verifyNoMoreInteractions(institutionServiceMock); } - @Test - void getInstitution_institutionInfoNull() throws Exception { - // given - String institutionId = "institutionId"; - when(institutionServiceMock.getInstitution(anyString())) - .thenReturn(null); - // when - MvcResult result = mvc.perform(MockMvcRequestBuilders - .get(BASE_URL + "/{institutionId}", institutionId) - .contentType(APPLICATION_JSON_VALUE) - .accept(APPLICATION_JSON_VALUE)) - .andExpect(status().is2xxSuccessful()) - .andReturn(); - // then - assertEquals("", result.getResponse().getContentAsString()); - verify(institutionServiceMock, times(1)) - .findInstitutionById(institutionId); - verifyNoMoreInteractions(institutionServiceMock); - } - - @Test - void getInstitutions_institutionInfoNotNull() throws Exception { - // given - String userId = "userId"; - Authentication authentication = mock(Authentication.class); - when(authentication.getPrincipal()).thenReturn(SelfCareUser.builder(userId).build()); - - InstitutionInfo expectedInstitution = mockInstance(new InstitutionInfo()); - expectedInstitution.setGeographicTaxonomies(List.of(mockInstance(new GeographicTaxonomy()))); - List expectedInstitutionInfos = new ArrayList<>(); - expectedInstitutionInfos.add(expectedInstitution); - when(institutionServiceMock.getInstitutions(userId)).thenReturn(expectedInstitutionInfos); - // when - MvcResult result = mvc.perform(MockMvcRequestBuilders - .get(BASE_URL + "?mode=" + GET_INSTITUTION_MODE.BASE.name()) - .principal(authentication) - .contentType(APPLICATION_JSON_VALUE) - .accept(APPLICATION_JSON_VALUE)) - .andExpect(status().is2xxSuccessful()) - .andReturn(); - // then - List resources = objectMapper.readValue(result.getResponse().getContentAsString(), - new TypeReference<>() { - }); - - assertNotNull(resources); - assertFalse(resources.isEmpty()); - assertEquals(resources.get(0).getStatus(), expectedInstitution.getStatus().name()); - assertNotNull(resources.get(0).getUserRole()); - verify(institutionServiceMock, times(1)) - .getInstitutions(userId); - verifyNoMoreInteractions(institutionServiceMock); - } - @Test void getProductsTree_notNull() throws Exception { // given @@ -252,165 +186,6 @@ void getProductsTree_empty() throws Exception { verifyNoMoreInteractions(institutionServiceMock); } - @Test - void getInstitutionUsers_empty() throws Exception { - // given - String institutionId = "institutionId"; - when(institutionServiceMock.getInstitutionUsers(any(), any(), any(), any())) - .thenReturn(Collections.emptyList()); - // when - MvcResult result = mvc.perform(MockMvcRequestBuilders - .get(BASE_URL + "/{institutionId}/users", institutionId) - .contentType(APPLICATION_JSON_VALUE) - .accept(APPLICATION_JSON_VALUE)) - .andExpect(status().is2xxSuccessful()) - .andReturn(); - // then - List products = objectMapper.readValue( - result.getResponse().getContentAsString(), - new TypeReference<>() { - }); - assertNotNull(products); - assertTrue(products.isEmpty()); - verify(institutionServiceMock, times(1)) - .getInstitutionUsers(institutionId, Optional.empty(), Optional.empty(), Optional.empty()); - verifyNoMoreInteractions(institutionServiceMock); - } - - @Test - void getInstitutionUsers_notEmpty() throws Exception { - // given - String institutionId = "institutionId"; - String productId = "institutionId"; - SelfCareAuthority role = SelfCareAuthority.ADMIN; - String[] productRole = {"api", "security"}; - final UserInfo userInfo = mockInstance(new UserInfo(), "setId"); - userInfo.setId(randomUUID().toString()); - when(institutionServiceMock.getInstitutionUsers(any(), any(), any(), any())) - .thenReturn(singletonList(userInfo)); - // when - MvcResult result = mvc.perform(MockMvcRequestBuilders - .get(BASE_URL + "/{institutionId}/users", institutionId) - .queryParam("role", role.toString()) - .queryParam("productId", productId) - .queryParam("productRoles", productRole) - .contentType(APPLICATION_JSON_VALUE) - .accept(APPLICATION_JSON_VALUE)) - .andExpect(status().is2xxSuccessful()) - .andReturn(); - // then - List products = objectMapper.readValue( - result.getResponse().getContentAsString(), - new TypeReference<>() { - }); - assertNotNull(products); - assertFalse(products.isEmpty()); - verify(institutionServiceMock, times(1)) - .getInstitutionUsers(institutionId, Optional.of(productId), Optional.of(role), Optional.of(Set.of(productRole))); - verifyNoMoreInteractions(institutionServiceMock); - } - - @Test - void getInstitutionUser_nullUser() throws Exception { - //given - String institutionId = "institutionId"; - String userId = "notFound"; - when(institutionServiceMock.getInstitutionUser(any(), any())) - .thenThrow(ResourceNotFoundException.class); - //when - MvcResult result = mvc.perform(MockMvcRequestBuilders - .get(BASE_URL + "/{institutionId}/users/{userId}", institutionId, userId) - .contentType(APPLICATION_JSON_VALUE) - .accept(APPLICATION_JSON_VALUE)) - .andExpect(status().is(HttpStatus.NOT_FOUND.value())) - .andReturn(); - //then - Assertions.assertEquals(0, result.getResponse().getContentLength()); - - } - - @Test - void getInstitutionUser_notNullUser() throws Exception { - //given - String institutionId = "institutionId"; - String userId = "notFound"; - UserInfo userInfo = mockInstance(new UserInfo(), "setId"); - userInfo.setId(randomUUID().toString()); - - when(institutionServiceMock.getInstitutionUser(any(), any())) - .thenReturn(userInfo); - //when - MvcResult result = mvc.perform(MockMvcRequestBuilders - .get(BASE_URL + "/{institutionId}/users/{userId}", institutionId, userId) - .contentType(APPLICATION_JSON_VALUE) - .accept(APPLICATION_JSON_VALUE)) - .andExpect(status().is2xxSuccessful()) - .andReturn(); - //then - InstitutionUserResource userResource = objectMapper.readValue(result.getResponse().getContentAsString(), InstitutionUserResource.class); - assertNotNull(userResource); - verify(institutionServiceMock, times(1)) - .getInstitutionUser(institutionId, userId); - verifyNoMoreInteractions(institutionServiceMock); - - } - - @Test - void getInstitutionProductUsers_empty() throws Exception { - // given - String institutionId = "institutionId"; - String productId = "productId"; - when(institutionServiceMock.getInstitutionProductUsers(any(), any(), any(), any())) - .thenReturn(Collections.emptyList()); - // when - MvcResult result = mvc.perform(MockMvcRequestBuilders - .get(BASE_URL + "/{institutionId}/products/{productId}/users", institutionId, productId) - .contentType(APPLICATION_JSON_VALUE) - .accept(APPLICATION_JSON_VALUE)) - .andExpect(status().is2xxSuccessful()) - .andReturn(); - // then - List products = objectMapper.readValue( - result.getResponse().getContentAsString(), - new TypeReference<>() { - }); - assertNotNull(products); - assertTrue(products.isEmpty()); - verify(institutionServiceMock, times(1)) - .getInstitutionProductUsers(institutionId, productId, Optional.empty(), Optional.empty()); - verifyNoMoreInteractions(institutionServiceMock); - } - - @Test - void getInstitutionProductUsers_notEmpty() throws Exception { - // given - String institutionId = "institutionId"; - String productId = "productId"; - SelfCareAuthority role = SelfCareAuthority.ADMIN; - final UserInfo userInfoModel = new UserInfo(); - userInfoModel.setId(randomUUID().toString()); - when(institutionServiceMock.getInstitutionProductUsers(any(), any(), any(), any())) - .thenReturn(singletonList(userInfoModel)); - // when - MvcResult result = mvc.perform(MockMvcRequestBuilders - .get(BASE_URL + "/{institutionId}/products/{productId}/users", institutionId, productId) - .queryParam("role", role.toString()) - .contentType(APPLICATION_JSON_VALUE) - .accept(APPLICATION_JSON_VALUE)) - .andExpect(status().is2xxSuccessful()) - .andReturn(); - // then - List products = objectMapper.readValue( - result.getResponse().getContentAsString(), - new TypeReference<>() { - }); - assertNotNull(products); - assertFalse(products.isEmpty()); - verify(institutionServiceMock, times(1)) - .getInstitutionProductUsers(institutionId, productId, Optional.of(role), Optional.empty()); - verifyNoMoreInteractions(institutionServiceMock); - } - @Test void updateInstitutionGeographicTaxonomy(@Value("classpath:stubs/geographicTaxonomyListDto.json") Resource geographicTaxonomyDto) throws Exception { // given @@ -466,60 +241,7 @@ void getInstitutionGeographicTaxonomy() throws Exception { .getGeographicTaxonomyList(institutionId); verifyNoMoreInteractions(institutionServiceMock); } - - @Test - void createInstitutionProductUser(@Value("classpath:stubs/createUserDto.json") Resource createUserDto) throws Exception { - // given - String institutionId = "institutionId"; - String productId = "productId"; - UserId userId = mockInstance(new UserId()); - when(institutionServiceMock.createUsers(any(), any(), any())) - .thenReturn(userId); - // when - mvc.perform(MockMvcRequestBuilders - .post(BASE_URL + "/{institutionId}/products/{productId}/users", institutionId, productId) - .content(createUserDto.getInputStream().readAllBytes()) - .contentType(APPLICATION_JSON_VALUE) - .accept(APPLICATION_JSON_VALUE)) - .andExpect(status().isCreated()) - .andExpect(content().contentType(APPLICATION_JSON)) - .andExpect(jsonPath("$.id", is(userId.getId().toString()))); - // then - verify(institutionServiceMock, times(1)) - .createUsers(Mockito.eq(institutionId), Mockito.eq(productId), Mockito.notNull()); - verifyNoMoreInteractions(institutionServiceMock); - } - - @Test - void addProductUserRole() throws Exception { - //given - String institutionId = "institutionId"; - String productId = "productId"; - String userId = UUID.randomUUID().toString(); - UserProductRoles productRoles = new UserProductRoles(); - productRoles.setProductRoles(Set.of("productRole")); - //when - MvcResult result = mvc.perform(MockMvcRequestBuilders - .put(BASE_URL + "/{institutionId}/products/{productId}/users/{userId}", institutionId, productId, userId) - .content(objectMapper.writeValueAsString(productRoles)) - .contentType(APPLICATION_JSON_VALUE) - .accept(APPLICATION_JSON_VALUE)) - .andExpect(status().isCreated()) - .andReturn(); - //then - assertEquals(0, result.getResponse().getContentLength()); - ArgumentCaptor userCaptor = ArgumentCaptor.forClass(it.pagopa.selfcare.dashboard.connector.model.user.CreateUserDto.class); - verify(institutionServiceMock, times(1)) - .addUserProductRoles(eq(institutionId), eq(productId), eq(userId), userCaptor.capture()); - it.pagopa.selfcare.dashboard.connector.model.user.CreateUserDto capturedUser = userCaptor.getValue(); - assertNull(capturedUser.getUser()); - assertEquals("", capturedUser.getEmail()); - assertEquals("", capturedUser.getName()); - assertEquals("", capturedUser.getSurname()); - assertEquals("", capturedUser.getTaxCode()); - capturedUser.getRoles().forEach(role -> assertTrue(productRoles.getProductRoles().contains(role.getProductRole()))); - } - + @Test void updateInstitutionDescription_ok() throws Exception { //given @@ -589,7 +311,7 @@ void getDelegationsUsingFrom_shouldGetData() throws Exception { } /** - * Method under test: {@link InstitutionController#getDelegationsUsingTo(String, String)} + * Method under test: {@link InstitutionController#getDelegationsUsingTo(String, String, String, String, GetDelegationsMode, Order, Integer, Integer)} */ @Test void getDelegationsUsingTo_shouldGetData() throws Exception { diff --git a/web/src/test/java/it/pagopa/selfcare/dashboard/web/security/PartyAuthoritiesRetrieverTest.java b/web/src/test/java/it/pagopa/selfcare/dashboard/web/security/PartyAuthoritiesRetrieverTest.java deleted file mode 100644 index 487ffee1a..000000000 --- a/web/src/test/java/it/pagopa/selfcare/dashboard/web/security/PartyAuthoritiesRetrieverTest.java +++ /dev/null @@ -1,156 +0,0 @@ -package it.pagopa.selfcare.dashboard.web.security; - -import it.pagopa.selfcare.commons.base.security.PartyRole; -import it.pagopa.selfcare.commons.base.security.SelfCareGrantedAuthority; -import it.pagopa.selfcare.dashboard.connector.api.MsCoreConnector; -import it.pagopa.selfcare.dashboard.connector.model.auth.AuthInfo; -import it.pagopa.selfcare.dashboard.connector.model.auth.ProductRole; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junit.jupiter.api.function.Executable; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.junit.jupiter.MockitoExtension; -import org.springframework.security.core.GrantedAuthority; - -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import static it.pagopa.selfcare.commons.base.security.PartyRole.MANAGER; -import static it.pagopa.selfcare.commons.base.security.PartyRole.SUB_DELEGATE; -import static it.pagopa.selfcare.commons.base.security.SelfCareAuthority.ADMIN; -import static org.junit.jupiter.api.Assertions.*; - -@ExtendWith(MockitoExtension.class) -class PartyAuthoritiesRetrieverTest { - - @Mock - private MsCoreConnector msCoreConnector; - - @InjectMocks - private PartyAuthoritiesRetriever authoritiesRetriever; - - - @Test - void retrieveAuthorities_nullAuthInfo() { - // given - Mockito.when(msCoreConnector.getAuthInfo(Mockito.any())) - .thenReturn(null); - // when - Collection authorities = authoritiesRetriever.retrieveAuthorities(); - // then - assertNull(authorities); - Mockito.verify(msCoreConnector, Mockito.times(1)) - .getAuthInfo(Mockito.isNull()); - Mockito.verifyNoMoreInteractions(msCoreConnector); - } - - - @Test - void retrieveAuthorities_emptyAuthInfo() { - // given - Mockito.when(msCoreConnector.getAuthInfo(Mockito.any())) - .thenReturn(Collections.emptyList()); - // when - Collection authorities = authoritiesRetriever.retrieveAuthorities(); - // then - assertNotNull(authorities); - assertTrue(authorities.isEmpty()); - Mockito.verify(msCoreConnector, Mockito.times(1)) - .getAuthInfo(Mockito.isNull()); - Mockito.verifyNoMoreInteractions(msCoreConnector); - } - - - @Test - void retrieveAuthorities_notEmptyAuthInfoAndEmptyProductsRole() { - // given - Mockito.when(msCoreConnector.getAuthInfo(Mockito.any())) - .thenReturn(Collections.singletonList(new AuthInfo() { - })); - // when - Executable executable = () -> authoritiesRetriever.retrieveAuthorities(); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - Assertions.assertEquals("An Institution id is required", e.getMessage()); - Mockito.verify(msCoreConnector, Mockito.times(1)) - .getAuthInfo(Mockito.isNull()); - Mockito.verifyNoMoreInteractions(msCoreConnector); - } - - - @Test - void retrieveAuthorities() { - // given - PartyRole role = MANAGER; - String institutionId = "institutionId"; - Mockito.when(msCoreConnector.getAuthInfo(Mockito.any())) - .thenReturn(List.of(new AuthInfo() { - @Override - public String getInstitutionId() { - return institutionId; - } - - @Override - public Collection getProductRoles() { - return Collections.singleton(new ProductRole() { - @Override - public String getProductRole() { - return "productRole1"; - } - - @Override - public String getProductId() { - return "productId1"; - } - - @Override - public PartyRole getPartyRole() { - return MANAGER; - } - }); - } - }, new AuthInfo() { - @Override - public String getInstitutionId() { - return institutionId; - } - - @Override - public Collection getProductRoles() { - return Collections.singleton(new ProductRole() { - @Override - public String getProductRole() { - return "productRole2"; - } - - @Override - public String getProductId() { - return "productId2"; - } - - @Override - public PartyRole getPartyRole() { - return SUB_DELEGATE; - } - }); - } - })); - // when - Collection authorities = authoritiesRetriever.retrieveAuthorities(); - // then - assertNotNull(authorities); - assertEquals(2, authorities.size()); - authorities.forEach(grantedAuthority -> { - assertEquals(institutionId, ((SelfCareGrantedAuthority) grantedAuthority).getInstitutionId()); - assertEquals(ADMIN.name(), grantedAuthority.getAuthority()); - }); - Mockito.verify(msCoreConnector, Mockito.times(1)) - .getAuthInfo(Mockito.isNull()); - Mockito.verifyNoMoreInteractions(msCoreConnector); - } - -} \ No newline at end of file diff --git a/web/src/test/java/it/pagopa/selfcare/dashboard/web/security/SelfCarePermissionEvaluatorTest.java b/web/src/test/java/it/pagopa/selfcare/dashboard/web/security/SelfCarePermissionEvaluatorTest.java deleted file mode 100644 index d9abdede6..000000000 --- a/web/src/test/java/it/pagopa/selfcare/dashboard/web/security/SelfCarePermissionEvaluatorTest.java +++ /dev/null @@ -1,376 +0,0 @@ -package it.pagopa.selfcare.dashboard.web.security; - -import it.pagopa.selfcare.commons.base.security.ProductGrantedAuthority; -import it.pagopa.selfcare.commons.base.security.SelfCareGrantedAuthority; -import it.pagopa.selfcare.dashboard.connector.api.MsCoreConnector; -import it.pagopa.selfcare.dashboard.connector.model.user.ProductInfo; -import it.pagopa.selfcare.dashboard.connector.model.user.UserInfo; -import it.pagopa.selfcare.dashboard.web.model.InstitutionResource; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junit.jupiter.api.function.Executable; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.security.authentication.TestingAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.GrantedAuthority; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static it.pagopa.selfcare.commons.base.security.PartyRole.MANAGER; -import static it.pagopa.selfcare.commons.base.security.PartyRole.OPERATOR; -import static it.pagopa.selfcare.commons.base.security.SelfCareAuthority.ADMIN; -import static it.pagopa.selfcare.commons.base.security.SelfCareAuthority.LIMITED; -import static org.junit.jupiter.api.Assertions.*; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.when; - -@ExtendWith(SpringExtension.class) -@ContextConfiguration(classes = {SelfCarePermissionEvaluator.class}) -class SelfCarePermissionEvaluatorTest { - - @MockBean - MsCoreConnector msCoreConnector; - - @Autowired - SelfCarePermissionEvaluator permissionEvaluator; - - - @Test - void hasPermission_withObjectDomain_nullAuth() { - // given - Authentication authentication = null; - Object targetDomainObject = new Object(); - Object permission = new Object(); - // when - Executable executable = () -> permissionEvaluator.hasPermission(authentication, targetDomainObject, permission); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - assertEquals("An authentication is required", e.getMessage()); - } - - - @Test - void hasPermission_withObjectDomain_nullPermission() { - // given - Authentication authentication = new TestingAuthenticationToken(null, null); - Object targetDomainObject = new Object(); - Object permission = null; - // when - Executable executable = () -> permissionEvaluator.hasPermission(authentication, targetDomainObject, permission); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - assertEquals("A permission is required", e.getMessage()); - } - - - @Test - void hasPermission_withObjectDomain_nullTargetDomainObject() { - // given - Authentication authentication = new TestingAuthenticationToken(null, null); - Object targetDomainObject = null; - Object permission = new Object(); - // when - boolean hasPermission = permissionEvaluator.hasPermission(authentication, targetDomainObject, permission); - // then - assertFalse(hasPermission); - } - - - @Test - void hasPermission_withObjectDomain_unsupportedTargetDomainObject() { - // given - Authentication authentication = new TestingAuthenticationToken(null, null); - Object targetDomainObject = new Object(); - Object permission = new Object(); - // when - boolean hasPermission = permissionEvaluator.hasPermission(authentication, targetDomainObject, permission); - // then - assertFalse(hasPermission); - } - - - @Test - void hasPermission_withObjectDomain_notPermitted_noAuthority() { - // given - String institutionId = "institutionId"; - Object targetDomainObject = new ProductAclDomain(institutionId, "notPermittedProductId"); - Object permission = new Object(); - List roleOnProducts = List.of(new ProductGrantedAuthority(MANAGER, "productRole", "productId")); - List authorities = List.of(new SelfCareGrantedAuthority(institutionId, roleOnProducts)); - TestingAuthenticationToken authentication = new TestingAuthenticationToken("username", "password", authorities); - // when - boolean hasPermission = permissionEvaluator.hasPermission(authentication, targetDomainObject, permission); - // then - assertFalse(hasPermission); - } - - @Test - void hasPermission_withObjectDomain_notPermitted_invalidRole() { - // given - String institutionId = "institutionId"; - String productId = "productId"; - Object targetDomainObject = new ProductAclDomain(institutionId, productId); - Object permission = LIMITED.toString(); - List roleOnProducts = List.of(new ProductGrantedAuthority(MANAGER, "productRole", productId)); - List authorities = List.of(new SelfCareGrantedAuthority(institutionId, roleOnProducts)); - TestingAuthenticationToken authentication = new TestingAuthenticationToken("username", "password", authorities); - // when - boolean hasPermission = permissionEvaluator.hasPermission(authentication, targetDomainObject, permission); - // then - assertFalse(hasPermission); - } - - @Test - void hasPermission_withObjectDomain_permitted() { - // given - String institutionId = "institutionId"; - String productId = "productId"; - Object targetDomainObject = new ProductAclDomain(institutionId, productId); - Object permission = ADMIN.toString(); - List roleOnProducts = List.of(new ProductGrantedAuthority(MANAGER, "productRole", productId)); - List authorities = List.of(new SelfCareGrantedAuthority(institutionId, roleOnProducts)); - TestingAuthenticationToken authentication = new TestingAuthenticationToken("username", "password", authorities); - // when - boolean hasPermission = permissionEvaluator.hasPermission(authentication, targetDomainObject, permission); - // then - assertTrue(hasPermission); - } - - @Test - void hasPermission_withObjectDomain_anyPermittedAsAdmin() { - // given - String institutionId = "institutionId"; - String productId = "productId"; - Object targetDomainObject = new ProductAclDomain(institutionId, productId); - Object permission = "ANY"; - List roleOnProducts = List.of(new ProductGrantedAuthority(MANAGER, "productRole", productId)); - List authorities = List.of(new SelfCareGrantedAuthority(institutionId, roleOnProducts)); - TestingAuthenticationToken authentication = new TestingAuthenticationToken("username", "password", authorities); - // when - boolean hasPermission = permissionEvaluator.hasPermission(authentication, targetDomainObject, permission); - // then - assertTrue(hasPermission); - } - - - @Test - void hasPermission_withObjectDomain_anyPermittedAsLimited() { - // given - String institutionId = "institutionId"; - String productId = "productId"; - Object targetDomainObject = new ProductAclDomain(institutionId, productId); - Object permission = "ANY"; - List roleOnProducts = List.of(new ProductGrantedAuthority(OPERATOR, "productRole", productId)); - List authorities = List.of(new SelfCareGrantedAuthority(institutionId, roleOnProducts)); - TestingAuthenticationToken authentication = new TestingAuthenticationToken("username", "password", authorities); - // when - boolean hasPermission = permissionEvaluator.hasPermission(authentication, targetDomainObject, permission); - // then - assertTrue(hasPermission); - } - - - @Test - void hasPermission_withTargetId_nullAuth() { - // given - Authentication authentication = null; - Serializable targetId = "targetId"; - String targetType = "targetType"; - Object permission = new Object(); - // when - Executable executable = () -> permissionEvaluator.hasPermission(authentication, targetId, targetType, permission); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - assertEquals("An authentication is required", e.getMessage()); - } - - - @Test - void hasPermission_withTargetId_nullTargetType() { - // given - Authentication authentication = new TestingAuthenticationToken(null, null); - Serializable targetId = "targetId"; - String targetType = null; - Object permission = new Object(); - // when - Executable executable = () -> permissionEvaluator.hasPermission(authentication, targetId, targetType, permission); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - assertEquals("A targetType is required", e.getMessage()); - } - - - @Test - void hasPermission_withTargetId_nullPermission() { - // given - Authentication authentication = new TestingAuthenticationToken(null, null); - Serializable targetId = "targetId"; - String targetType = "targetType"; - Object permission = null; - // when - Executable executable = () -> permissionEvaluator.hasPermission(authentication, targetId, targetType, permission); - // then - IllegalArgumentException e = assertThrows(IllegalArgumentException.class, executable); - assertEquals("A permission is required", e.getMessage()); - } - - - @Test - void hasPermission_withTargetId_nullTargetId() { - // given - Authentication authentication = new TestingAuthenticationToken(null, null); - Serializable targetId = "targetId"; - String targetType = "targetType"; - Object permission = new Object(); - // when - boolean hasPermission = permissionEvaluator.hasPermission(authentication, targetId, targetType, permission); - // then - assertFalse(hasPermission); - } - - - @Test - void hasPermission_withTargetId_unsupportedTargetType() { - // given - Authentication authentication = new TestingAuthenticationToken("username", "password"); - Serializable targetId = "targetId"; - String targetType = "unsupported_resource"; - Object permission = new Object(); - // when - boolean hasPermission = permissionEvaluator.hasPermission(authentication, targetId, targetType, permission); - // then - assertFalse(hasPermission); - } - - - @Test - void hasPermission_withTargetId_targetTypeInstitutionResource_notPermitted_noAuthority() { - // given - Serializable targetId = "notPermittedInstitutionId"; - String targetType = InstitutionResource.class.getSimpleName(); - Object permission = new Object(); - String institutionId = "institutionId"; - List roleOnProducts = List.of(new ProductGrantedAuthority(MANAGER, "productRole", "productId")); - List authorities = List.of(new SelfCareGrantedAuthority(institutionId, roleOnProducts)); - TestingAuthenticationToken authentication = new TestingAuthenticationToken("username", "password", authorities); - // when - boolean hasPermission = permissionEvaluator.hasPermission(authentication, targetId, targetType, permission); - // then - assertFalse(hasPermission); - } - - - @Test - void hasPermission_withTargetId_targetTypeInstitutionResource_notPermitted_invalidRole() { - // given - Serializable targetId = "institutionId"; - String targetType = InstitutionResource.class.getSimpleName(); - Object permission = LIMITED.toString(); - List roleOnProducts = List.of(new ProductGrantedAuthority(MANAGER, "productRole", "productId")); - List authorities = List.of(new SelfCareGrantedAuthority(targetId.toString(), roleOnProducts)); - TestingAuthenticationToken authentication = new TestingAuthenticationToken("username", "password", authorities); - // when - boolean hasPermission = permissionEvaluator.hasPermission(authentication, targetId, targetType, permission); - // then - assertFalse(hasPermission); - } - - - @Test - void hasPermission_withTargetId_targetTypeInstitutionResource_permitted() { - // given - Serializable targetId = "institutionId"; - String targetType = InstitutionResource.class.getSimpleName(); - Object permission = ADMIN.toString(); - List roleOnProducts = List.of(new ProductGrantedAuthority(MANAGER, "productRole", "productId")); - List authorities = List.of(new SelfCareGrantedAuthority(targetId.toString(), roleOnProducts)); - TestingAuthenticationToken authentication = new TestingAuthenticationToken("username", "password", authorities); - // when - boolean hasPermission = permissionEvaluator.hasPermission(authentication, targetId, targetType, permission); - // then - assertTrue(hasPermission); - } - - - @Test - void hasPermission_withTargetId_targetTypeInstitutionResource__anyPermittedAsAdmin() { - // given - Serializable targetId = "institutionId"; - String targetType = InstitutionResource.class.getSimpleName(); - Object permission = "ANY"; - List roleOnProducts = List.of(new ProductGrantedAuthority(MANAGER, "productRole", "productId")); - List authorities = List.of(new SelfCareGrantedAuthority(targetId.toString(), roleOnProducts)); - TestingAuthenticationToken authentication = new TestingAuthenticationToken("username", "password", authorities); - // when - boolean hasPermission = permissionEvaluator.hasPermission(authentication, targetId, targetType, permission); - // then - assertTrue(hasPermission); - } - - - @Test - void hasPermission_withTargetId_targetTypeInstitutionResource__anyPermittedAsLimited() { - // given - Serializable targetId = "institutionId"; - String targetType = InstitutionResource.class.getSimpleName(); - Object permission = "ANY"; - List roleOnProducts = List.of(new ProductGrantedAuthority(OPERATOR, "productRole", "productId")); - List authorities = List.of(new SelfCareGrantedAuthority(targetId.toString(), roleOnProducts)); - TestingAuthenticationToken authentication = new TestingAuthenticationToken("username", "password", authorities); - // when - boolean hasPermission = permissionEvaluator.hasPermission(authentication, targetId, targetType, permission); - // then - assertTrue(hasPermission); - } - - @Test - void hasPermission_withTargetId_targetTypeRelationshipId_notPermitted_invalidRole() { - // given - Serializable targetId = "relationshipId"; - String targetType = "relationshipId"; - Object permission = LIMITED.toString(); - UserInfo userInfo = getUserInfo(); - when(msCoreConnector.getUser(anyString())).thenReturn(userInfo); - List roleOnProducts = List.of(new ProductGrantedAuthority(MANAGER, "productRole", "productId")); - List authorities = List.of(new SelfCareGrantedAuthority(targetId.toString(), roleOnProducts)); - TestingAuthenticationToken authentication = new TestingAuthenticationToken("username", "password", authorities); - // when - boolean hasPermission = permissionEvaluator.hasPermission(authentication, targetId, targetType, permission); - // then - assertFalse(hasPermission); - } - - - @Test - void hasPermission_withTargetId_targetTypeRelationshipId_permitted() { - // given - Serializable targetId = "relationshipId"; - String targetType = "relationshipId"; - Object permission = ADMIN.toString(); - UserInfo userInfo = getUserInfo(); - when(msCoreConnector.getUser(anyString())).thenReturn(userInfo); - List roleOnProducts = List.of(new ProductGrantedAuthority(MANAGER, "productRole", "productId")); - List authorities = List.of(new SelfCareGrantedAuthority("institutionId", roleOnProducts)); - TestingAuthenticationToken authentication = new TestingAuthenticationToken("username", "password", authorities); - // when - boolean hasPermission = permissionEvaluator.hasPermission(authentication, targetId, targetType, permission); - // then - assertTrue(hasPermission); - } - - private static UserInfo getUserInfo() { - UserInfo userInfo = new UserInfo(); - userInfo.setInstitutionId("institutionId"); - Map map = new HashMap<>(); - map.put("productId", new ProductInfo()); - userInfo.setProducts(map); - return userInfo; - } - -} \ No newline at end of file