Skip to content
Merged
12 changes: 12 additions & 0 deletions locales/en/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -4179,6 +4179,18 @@
"rateLimitToast": "Non riusciamo ad attivare il servizio SEND, riprova più tardi",
"activationErrorMessage": "Non riusciamo ad attivare il servizio SEND"
}
},
"lollipopPlayground": {
"environmentTitle": "Environment",
"uatLabel": "Use UAT",
"uatDescription": "Sends Service Activation and AAR requests to the UAT environment",
"playgroundTitle": "Lollipop Playground",
"postBodyLabel": "Post Body",
"postBodyPlaceholder": "{\n p1: \"a string\",\n p2: {\n p3: true\n }\n}",
"responseStatusCode": "Response Status Code",
"responseBody": "Response Body",
"requestGet": "GET",
"requestPost": "POST"
}
},
"fci": {
Expand Down
12 changes: 12 additions & 0 deletions locales/it/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -4306,6 +4306,18 @@
"rateLimitToast": "Non riusciamo ad attivare il servizio SEND, riprova più tardi",
"activationErrorMessage": "Non riusciamo ad attivare il servizio SEND"
}
},
"lollipopPlayground": {
"environmentTitle": "Ambiente",
"uatLabel": "Usa UAT",
"uatDescription": "Manda le richieste AAR e quelle di attivazione servizio all'ambiente di UAT",
"playgroundTitle": "Lollipop Playground",
"postBodyLabel": "Body della post",
"postBodyPlaceholder": "{\n p1: \"a string\",\n p2: {\n p3: true\n }\n}",
"responseStatusCode": "Status Code risposta",
"responseBody": "Body della risposta",
"requestGet": "GET",
"requestPost": "POST"
}
},
"fci": {
Expand Down
5 changes: 3 additions & 2 deletions scripts/generate-api-models.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

IO_BACKEND_VERSION=v17.5.2
# need to change after merge on io-services-metadata
IO_SERVICES_METADATA_VERSION=1.0.94
IO_SERVICES_METADATA_VERSION=1.0.95
# Session manager version
IO_SESSION_MANAGER_VERSION=1.8.0
# IO Wallet user function version
IO_WALLET_USER_FUNC_VERSION=4.1.11
# Send function version
SEND_FUNC_VERSION=1.4.3
SEND_FUNC_VERSION=1.5.5

declare -a apis=(
# Backend APIs
Expand Down Expand Up @@ -41,6 +41,7 @@ declare -a apis=(
# PN APIs
"./definitions/pn https://raw.githubusercontent.com/pagopa/io-backend/$IO_BACKEND_VERSION/api_pn.yaml"
"./definitions/pn/aar https://raw.githubusercontent.com/pagopa/io-messages/refs/tags/send-func@$SEND_FUNC_VERSION/apps/send-func/openapi/aar-notification.yaml"
"./definitions/pn/lollipop-lambda https://raw.githubusercontent.com/pagopa/io-messages/refs/tags/send-func@$SEND_FUNC_VERSION/apps/send-func/openapi/lollipop-integration-check.yaml"
# FCI APIs
"./definitions/fci https://raw.githubusercontent.com/pagopa/io-backend/$IO_BACKEND_VERSION/api_io_sign.yaml"
# ITW APIs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,9 @@ exports[`featuresPersistor should match snapshot 1`] = `
"loginEngagement": {
"hasSendEngagementScreenBeenDismissed": false,
},
"lollipopLambda": {
"type": "idle",
},
"tempAarMandate": {
"mandate": {
"kind": "undefined",
Expand Down
79 changes: 79 additions & 0 deletions ts/features/pn/lollipopLambda/api/__tests__/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { LollipopConfig } from "../../../../lollipop";
import { KeyInfo } from "../../../../lollipop/utils/crypto";
import { SessionToken } from "../../../../../types/SessionToken";
import { createSendLollipopLambdaClient } from "../index";
import * as lollipopFetchModule from "../../../../lollipop/utils/fetch";

const mockFetch = jest.fn();
jest.mock("../../../../lollipop/utils/fetch", () => ({
lollipopFetch: jest.fn(() => mockFetch)
}));

const mockCreateClient = jest.fn();
jest.mock("../../../../../../definitions/pn/lollipop-lambda/client", () => ({
createClient: jest.fn(input => mockCreateClient(input))
}));

describe("createSendLollipopLambdaClient", () => {
afterEach(() => {
jest.clearAllMocks();
});

it("should invoke `createClient` with input 'baseUrl', the result of `lollipopFetch` and a 'withDefaults' function", () => {
const baseUrl = "https://localhost:3000";
const sessionToken = "session-token-123" as SessionToken;
const keyInfo: KeyInfo = {
keyTag: "aTag",
publicKey: {
kty: "RSA",
alg: "anAlg",
e: "asd",
n: "dsa"
},
publicKeyThumbprint: "qwe"
};

const spiedOnLollipopFetch = jest.spyOn(
lollipopFetchModule,
"lollipopFetch"
);

createSendLollipopLambdaClient(baseUrl, sessionToken, keyInfo);

expect(mockCreateClient.mock.calls.length).toBe(1);
expect(mockCreateClient.mock.calls[0].length).toBe(1);

const createClientParams = mockCreateClient.mock.calls[0][0];
expect(createClientParams.baseUrl).toBe(baseUrl);
expect(createClientParams.fetchApi).toBe(mockFetch);
expect(createClientParams.withDefaults).toBeInstanceOf(Function);

expect(spiedOnLollipopFetch.mock.calls.length).toBe(1);
expect(spiedOnLollipopFetch.mock.calls[0].length).toBe(2);
const nonceObj = spiedOnLollipopFetch.mock.calls[0][0] as LollipopConfig;
expect(nonceObj.nonce).not.toBeUndefined();
expect(spiedOnLollipopFetch.mock.calls[0][1]).toBe(keyInfo);
});

it("should create a `withDefaults` function that adds Bearer token to params", () => {
const baseUrl = "https://localhost:3000";
const sessionToken = "my-session-token" as SessionToken;
const keyInfo: KeyInfo = {};

createSendLollipopLambdaClient(baseUrl, sessionToken, keyInfo);

const createClientParams = mockCreateClient.mock.calls[0][0];
const withDefaults = createClientParams.withDefaults;

const mockOp = jest.fn(params => params);
const wrappedOp = withDefaults(mockOp);

const inputParams = { someParam: "value" };
wrappedOp(inputParams);

expect(mockOp).toHaveBeenCalledWith({
...inputParams,
Bearer: `Bearer ${sessionToken}`
});
});
});
24 changes: 24 additions & 0 deletions ts/features/pn/lollipopLambda/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { v4 as uuid } from "uuid";
import { createClient } from "../../../../../definitions/pn/lollipop-lambda/client";
import { SessionToken } from "../../../../types/SessionToken";
import { lollipopFetch } from "../../../lollipop/utils/fetch";
import { KeyInfo } from "../../../lollipop/utils/crypto";

export const createSendLollipopLambdaClient = (
baseUrl: string,
sessionToken: SessionToken,
keyInfo: KeyInfo
) =>
createClient<"Bearer">({
baseUrl,
fetchApi: lollipopFetch({ nonce: uuid() }, keyInfo),
withDefaults: op => params =>
op({
...params,
Bearer: `Bearer ${sessionToken}`
})
});

export type SendLollipopLambdaClient = ReturnType<
typeof createSendLollipopLambdaClient
>;
Loading
Loading