Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PPANTT-223] feat: Add FdR QI KPI sub key #533

Merged
merged 25 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6d568d0
fix: Activation date (#524)
gioelemella Nov 22, 2024
c3164f9
Bump to version 2.32.3 [skip ci]
pagopa-github-bot Nov 22, 2024
d55badd
fix: Cron logs metadata (#525)
gioelemella Nov 25, 2024
91ff4fe
Bump to version 2.32.4 [skip ci]
pagopa-github-bot Nov 25, 2024
bcc90a9
[PPANTT-209] chore: Change ACA api key name (#526)
gioelemella Nov 28, 2024
c209c69
Bump to version 2.32.5 [skip ci]
pagopa-github-bot Nov 28, 2024
a8fc761
Bump to version 2.32.6 [skip ci]
pagopa-github-bot Dec 2, 2024
5c66d2c
[PPANTT-215] feat: Send emails to CIs in UAT & PROD (#527)
svariant Dec 3, 2024
a591eb4
Bump to version 2.33.0 [skip ci]
pagopa-github-bot Dec 3, 2024
8fa059d
[PPANTT-218] fix: Deploy gha (#528)
gioelemella Dec 3, 2024
efec42e
fix: helm (#529)
gioelemella Dec 3, 2024
d72a8fc
Bump to version 2.33.1 [skip ci]
pagopa-github-bot Dec 3, 2024
6f5c6c5
[PPANTT-215] feat: Add environment info in mail content (#530)
gioelemella Dec 4, 2024
788b9d4
Bump to version 2.34.0 [skip ci]
pagopa-github-bot Dec 4, 2024
0eeae78
[PPANTT-222] fix: BO external authorizer config (#531)
gioelemella Dec 6, 2024
22f5bab
Bump to version 2.34.1 [skip ci]
pagopa-github-bot Dec 6, 2024
6dfb998
[PPANTT-223] added new api key subscription for Fdr KPI API
gioelemella Dec 16, 2024
036201a
[PPANTT-223] improved tests
gioelemella Dec 16, 2024
5e55c05
[PPANTT-223] updated subscription info
gioelemella Dec 17, 2024
efe1f03
[PPANTT-223] updated prefix id
gioelemella Dec 17, 2024
99a7059
[PPANTT-223] removed authorized entities configuration for new key an…
gioelemella Dec 17, 2024
c9f2a62
[PPANTT-223] updated openapi
gioelemella Dec 17, 2024
b73f287
[PPANTT-183] rollback changes
gioelemella Dec 17, 2024
55085c1
[PPANTT-223] update auth config
gioelemella Dec 19, 2024
c2dfdb2
Merge branch 'next' into PPANTT-223-new-fdr-kpi-api-sub-key
gioelemella Dec 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 1 addition & 42 deletions .github/workflows/deploy_with_github_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,8 @@ permissions:
contents: read

jobs:
create_runner:
name: Create Runner
runs-on: ubuntu-22.04
environment:
name: ${{ inputs.environment }}
outputs:
runner_name: ${{ steps.create_github_runner.outputs.runner_name }}
steps:
- name: Create GitHub Runner
id: create_github_runner
# from https://github.com/pagopa/eng-github-actions-iac-template/tree/main/azure/github-self-hosted-runner-azure-create-action
uses: pagopa/eng-github-actions-iac-template/azure/github-self-hosted-runner-azure-create-action@main
with:
client_id: ${{ secrets.CD_CLIENT_ID }}
tenant_id: ${{ secrets.TENANT_ID }}
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
container_app_environment_name: ${{ vars.CONTAINER_APP_ENVIRONMENT_NAME }}
resource_group_name: ${{ vars.CONTAINER_APP_ENVIRONMENT_RESOURCE_GROUP_NAME }} # RG of the runner
pat_token: ${{ secrets.BOT_TOKEN_GITHUB }}
self_hosted_runner_image_tag: "latest"

deploy:
needs: [ create_runner ]
runs-on: [ self-hosted, "${{ needs.create_runner.outputs.runner_name }}" ]
runs-on: [ self-hosted-job, "${{ inputs.environment }}" ]
name: Deploy on AKS
environment: ${{ inputs.environment }}
steps:
Expand All @@ -93,25 +71,6 @@ jobs:
run: |
helm uninstall ${{ env.APP_NAME }}${{inputs.suffix_name}} -n ${{ vars.NAMESPACE }}

cleanup_runner:
name: Cleanup Runner
needs: [ create_runner, deploy ]
if: ${{ success() || failure() }}
runs-on: ubuntu-22.04
environment: ${{ inputs.environment }}
steps:
- name: Cleanup GitHub Runner
id: cleanup_github_runner
# from https://github.com/pagopa/eng-github-actions-iac-template/tree/main/azure/github-self-hosted-runner-azure-cleanup-action
uses: pagopa/eng-github-actions-iac-template/azure/github-self-hosted-runner-azure-cleanup-action@main
with:
client_id: ${{ secrets.CD_CLIENT_ID }}
tenant_id: ${{ secrets.TENANT_ID }}
subscription_id: ${{ secrets.SUBSCRIPTION_ID }}
resource_group_name: ${{ vars.CONTAINER_APP_ENVIRONMENT_RESOURCE_GROUP_NAME }}
runner_name: ${{ needs.create_runner.outputs.runner_name }}
pat_token: ${{ secrets.BOT_TOKEN_GITHUB }}

update_openapi:
needs: [ deploy ]
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v2
name: pagopa-selfcare-ms-backoffice
description: Microservice that manage api keys for pagopa product from selfcare
type: application
version: 0.435.0
appVersion: "2.32.2-1-next"
version: 0.442.0
appVersion: "2.34.1"
dependencies:
- name: microservice-chart
version: 2.4.0
Expand Down
3 changes: 2 additions & 1 deletion helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend
tag: "2.32.2-1-next"
tag: "2.34.1"
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down Expand Up @@ -82,6 +82,7 @@ microservice-chart:
GEC_SERVICE_URL: https://api.dev.platform.pagopa.it
FORWARDER_SERVICE_URL: https://api.dev.platform.pagopa.it
TAXONOMY_SERVICE_URL: https://api.platform.pagopa.it
ENABLE_SEND_EMAIL: 'false'
AZURE_RESOURCE_GROUP: pagopa-d-api-rg
AZURE_SERVICE_NAME: pagopa-d-apim
APPCONFIGURATION_ENDPOINT: 'https://pagopa-d-selfcare-appconfiguration.azconfig.io'
Expand Down
3 changes: 2 additions & 1 deletion helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend
tag: "2.32.2-1-next" #improve
tag: "2.34.1" #improve
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down Expand Up @@ -85,6 +85,7 @@ microservice-chart:
GEC_SERVICE_URL: https://api.platform.pagopa.it
FORWARDER_SERVICE_URL: https://api.platform.pagopa.it
TAXONOMY_SERVICE_URL: https://api.platform.pagopa.it
ENABLE_SEND_EMAIL: 'true'
AZURE_RESOURCE_GROUP: pagopa-p-api-rg
AZURE_SERVICE_NAME: pagopa-p-apim
APPCONFIGURATION_ENDPOINT: 'https://pagopa-p-selfcare-appconfiguration.azconfig.io'
Expand Down
3 changes: 2 additions & 1 deletion helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ microservice-chart:
fullnameOverride: ""
image:
repository: ghcr.io/pagopa/pagopa-selfcare-ms-backoffice-backend
tag: "2.32.2-1-next" #improve
tag: "2.34.1" #improve
pullPolicy: Always
livenessProbe:
httpGet:
Expand Down Expand Up @@ -83,6 +83,7 @@ microservice-chart:
GEC_SERVICE_URL: https://api.uat.platform.pagopa.it
FORWARDER_SERVICE_URL: https://api.uat.platform.pagopa.it
TAXONOMY_SERVICE_URL: https://api.platform.pagopa.it
ENABLE_SEND_EMAIL: 'true'
AZURE_RESOURCE_GROUP: pagopa-u-api-rg
AZURE_SERVICE_NAME: pagopa-u-apim
APPCONFIGURATION_ENDPOINT: 'https://pagopa-u-selfcare-appconfiguration.azconfig.io'
Expand Down
5 changes: 3 additions & 2 deletions openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Microservice to manage PagoPA Backoffice",
"termsOfService": "https://www.pagopa.gov.it/",
"title": "SelfCare Backoffice",
"version": "2.32.2-1-next"
"version": "2.34.1"
},
"servers": [
{
Expand Down Expand Up @@ -8965,6 +8965,7 @@
"BIZ",
"FDR_ORG",
"FDR_PSP",
"QI_FDR_KPI",
"BO_EXT_EC",
"BO_EXT_PSP",
"PRINT_NOTICE",
Expand Down Expand Up @@ -17049,4 +17050,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<version>2.5.14</version>
</parent>
<artifactId>pagopa-selfcare-ms-backoffice</artifactId>
<version>2.32.2-1-next</version>
<version>2.34.1</version>
<name>SelfCare Backoffice</name>
<description>Microservice to manage PagoPA Backoffice</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class AwsSesClient {

private final String environment;

private final Boolean enableSendEmail;

private final String testEmailAddress;

private final String pagopaOperatorEmailAddress;
Expand All @@ -46,15 +48,16 @@ public AwsSesClient(
ExternalApiClient externalApiClient,
@Value("${info.properties.environment}") String environment,
@Value("${institution.subscription.test-email}") String testEmailAddress,
@Value("${institution.subscription.pagopa-operator-email}") String pagopaOperatorEmailAddress
) {
@Value("${institution.subscription.pagopa-operator-email}") String pagopaOperatorEmailAddress,
@Value("${institution.subscription.enable-send-email}") Boolean enableSendEmail) {
this.sesClient = sesClient;
this.from = from;
this.templateEngine = templateEngine;
this.externalApiClient = externalApiClient;
this.environment = environment;
this.testEmailAddress = testEmailAddress;
this.pagopaOperatorEmailAddress = pagopaOperatorEmailAddress;
this.enableSendEmail = enableSendEmail;
}

/**
Expand All @@ -72,7 +75,7 @@ public AwsSesClient(
*/
public void sendEmail(EmailMessageDetail email, boolean sendEmailToPagopaOperator) {
String taxCode = email.getInstitutionTaxCode();
if (isNotProdWithoutTestEmail() || isProdWithNullDestinationInstitutionTaxCode(taxCode)) {
if (hasNotRequiredData(taxCode)) {
log.warn("Skip send email process");
return;
}
Expand Down Expand Up @@ -111,6 +114,7 @@ public void sendEmail(EmailMessageDetail email) {

private SendEmailRequest buildEmailRequest(EmailMessageDetail email, String[] toAddressList, boolean sendEmailToPagopaOperator) {
String html = this.templateEngine.process(email.getHtmlBodyFileName(), email.getHtmlBodyContext());
String subject = isNotProd() ? String.format("[%s] %s", this.environment, email.getSubject()) : email.getSubject();

return SendEmailRequest.builder()
.source(this.from)
Expand All @@ -122,7 +126,7 @@ private SendEmailRequest buildEmailRequest(EmailMessageDetail email, String[] to
}
})
.message(m -> m
.subject(c -> c.data(email.getSubject()))
.subject(c -> c.data(subject))
.body(b -> b
.html(c -> c.data(html).charset(StandardCharsets.UTF_8.name()))
.text(c -> c.data(email.getTextBody()))
Expand All @@ -132,7 +136,7 @@ private SendEmailRequest buildEmailRequest(EmailMessageDetail email, String[] to
}

private String[] getToAddressList(String taxCode, SelfcareProductUser destinationUserType) {
if (!this.environment.equals("PROD")) {
if (Boolean.FALSE.equals(this.enableSendEmail)) {
return new String[]{testEmailAddress};
}
Optional<Institution> optionalInstitution = this.externalApiClient.getInstitutionsFiltered(taxCode)
Expand All @@ -158,11 +162,11 @@ private String[] getToAddressList(String taxCode, SelfcareProductUser destinatio
.toArray(new String[0]);
}

private boolean isProdWithNullDestinationInstitutionTaxCode(String taxCode) {
return this.environment.equals("PROD") && taxCode == null;
private boolean isNotProd() {
return !this.environment.equals("PROD");
}

private boolean isNotProdWithoutTestEmail() {
return !this.environment.equals("PROD") && StringUtils.isBlank(testEmailAddress);
private boolean hasNotRequiredData(String taxCode) {
return Boolean.FALSE.equals(this.enableSendEmail) ? StringUtils.isBlank(testEmailAddress) : taxCode == null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ public enum Subscription {
BIZ("/products/bizevents", "BIZ - Recupero ricevute Ente Creditore", "biz-", CI, null, false),
FDR_ORG("/products/fdr-org", "FdR - Flussi di Rendicontazione (EC)", "fdrorg-", CI, "fdr", true),
FDR_PSP("/products/fdr-psp", "FdR - Flussi di Rendicontazione (PSP)", "fdrpsp-", PSP, "fdr", true),
QI_FDR_KPI("/products/qi-fdr-kpi", "FdR - Quality Improvement KPI API", "qifdrkpiservice-", PSP, "qi", true),
BO_EXT_EC("/apis/%s-backoffice-external-ec-api-v1", "Backoffice External (EC)", "selfcareboexternalec-", CI, "backoffice_external", false),
BO_EXT_PSP("/apis/%s-backoffice-external-psp-api-v1", "Backoffice External (PSP)", "selfcareboexternalpsp-", PSP, "backoffice_external", false),
PRINT_NOTICE("/products/pagopa_notices_service_external", "Stampa Avvisi", "printnotice-", CI, null, false),
ACA("/products/aca", "ACA - paCreatePosition", "aca-", CI, "aca", true);
ACA("/products/aca", "ACA - Conferimento delle posizioni debitorie", "aca-", CI, "aca", true);

private final String scope;
private final String displayName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,8 @@ private Set<String> getAllBrokersOrThrowException() {
updateMDCError(e, "Export CI Broker");
String errMsg = "[Export-CI] - An error occurred while extracting broker list, export aborted";
log.error(errMsg, e);
throw new AppException(AppError.BROKER_CI_EXPORT_SCHEDULER_SETUP_ERROR, e, errMsg);
} finally {
MDC.clear();
throw new AppException(AppError.BROKER_CI_EXPORT_SCHEDULER_SETUP_ERROR, e, errMsg);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import lombok.extern.slf4j.Slf4j;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
Expand All @@ -35,6 +36,8 @@
@Slf4j
public class CommissionBundleMailNotificationScheduler {

private final String environment;

private static final String VALID_FROM_DATE_FORMAT = "yyyy-MM-dd";

private final BundleAllPages bundleAllPages;
Expand All @@ -44,10 +47,12 @@ public class CommissionBundleMailNotificationScheduler {
private final AwsSesClient awsSesClient;

public CommissionBundleMailNotificationScheduler(
@Value("${info.properties.environment}") String environment,
BundleAllPages bundleAllPages,
ApiConfigClient apiConfigClient,
AwsSesClient awsSesClient
) {
this.environment = environment;
this.bundleAllPages = bundleAllPages;
this.apiConfigClient = apiConfigClient;
this.awsSesClient = awsSesClient;
Expand Down Expand Up @@ -111,7 +116,7 @@ private void sendMail(String expireAt, Bundle bundle, String notifyTaxCode, Stri
EmailMessageDetail messageDetail = EmailMessageDetail.builder()
.institutionTaxCode(notifyTaxCode)
.subject(BUNDLE_EXPIRE_SUBJECT)
.textBody(String.format(BUNDLE_EXPIRE_BODY, bundle.getName(), bundle.getPspBusinessName(), pspTaxCode, expireAt))
.textBody(String.format(BUNDLE_EXPIRE_BODY, bundle.getName(), bundle.getPspBusinessName(), pspTaxCode, expireAt, getEnvParam()))
.htmlBodyFileName("expiringBundleEmail.html")
.htmlBodyContext(buildEmailHtmlBodyContext(bundle.getName(), bundle.getPspBusinessName(), pspTaxCode, expireAt))
.destinationUserType(SelfcareProductUser.ADMIN)
Expand Down Expand Up @@ -144,8 +149,16 @@ private Context buildEmailHtmlBodyContext(
properties.put("pspName", pspBusinessName);
properties.put("pspTaxCode", pspTaxCode);
properties.put("expireAt", expireAt);
properties.put("environment", getEnvParam());

context.setVariables(properties);
return context;
}

private String getEnvParam() {
if (this.environment.equals("PROD")) {
return "";
}
return String.format(".%s", this.environment.toLowerCase());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,8 @@ private Set<String> getAllBrokersOrThrowException() {
updateMDCError(e, "Export Broker IBAN");
String errMsg = "[Export IBANs] - An error occurred while extracting broker list, export aborted";
log.error(errMsg, e);
throw new AppException(AppError.BROKER_IBAN_EXPORT_SCHEDULER_SETUP_ERROR, e, errMsg);
} finally {
MDC.clear();
throw new AppException(AppError.BROKER_IBAN_EXPORT_SCHEDULER_SETUP_ERROR, e, errMsg);
}
}

Expand Down
Loading
Loading