Skip to content

Commit

Permalink
Merge branch 'IMN_801_purpose-platformstate-writer-v2' into IMN_800_p…
Browse files Browse the repository at this point in the history
…urpose-platformstate-writer-v1
  • Loading branch information
shuyec committed Oct 1, 2024
2 parents 949687c + 225362e commit 472ba4a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
8 changes: 5 additions & 3 deletions packages/purpose-platformstate-writer/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export const readTokenEntriesByGSIPKPurposeId = async (
): Promise<TokenGenerationStatesClientPurposeEntry[]> => {
const input: QueryInput = {
TableName: config.tokenGenerationReadModelTableNameTokenGeneration,
IndexName: "GSIPK_purposeId",
IndexName: "Purpose",
KeyConditionExpression: `GSIPK_purposeId = :gsiValue`,
ExpressionAttributeValues: {
":gsiValue": { S: purposeId },
Expand Down Expand Up @@ -321,7 +321,9 @@ export const updatePurposeEntriesInTokenGenerationStatesTable = async (
S: catalogEntry.state,
},
":descriptorAudience": {
S: catalogEntry.descriptorAudience,
L: catalogEntry.descriptorAudience.map((item) => ({
S: item,
})),
},
":descriptorVoucherLifespan": {
N: catalogEntry.descriptorVoucherLifespan.toString(),
Expand Down Expand Up @@ -422,7 +424,7 @@ export const readPlatformAgreementEntryByGSIPKConsumerIdEServiceId = async (
): Promise<PlatformStatesAgreementEntry | undefined> => {
const input: QueryInput = {
TableName: config.tokenGenerationReadModelTableNamePlatform,
IndexName: "GSIPK_consumerId_eserviceId",
IndexName: "Agreement",
KeyConditionExpression: `GSIPK_consumerId_eserviceId = :gsiValue`,
ExpressionAttributeValues: {
":gsiValue": { S: gsiPKConsumerIdEServiceId },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ describe("integration tests", () => {
const previousDescriptorEntry: PlatformStatesCatalogEntry = {
PK: catalogEntryPK,
state: itemState.active,
descriptorAudience: "pagopa.it",
descriptorAudience: ["pagopa.it"],
descriptorVoucherLifespan: mockDescriptor.voucherLifespan,
version: 2,
updatedAt: new Date().toISOString(),
Expand Down Expand Up @@ -1796,7 +1796,6 @@ describe("integration tests", () => {
);
});

// FIX: duplicate description
it("should update the entry if the message version is more recent and the purpose is suspended by the consumer and the producer", async () => {
const previousEntryVersion = 1;
const messageVersion = 2;
Expand Down
14 changes: 7 additions & 7 deletions packages/purpose-platformstate-writer/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
PutItemCommand,
PutItemInput,
} from "@aws-sdk/client-dynamodb";
import { setupTestContainersVitest } from "pagopa-interop-commons-test/index.js";
import {
genericInternalError,
PlatformStatesAgreementEntry,
Expand All @@ -25,14 +24,11 @@ import {
PurposeVersionState,
PurposeVersionV1,
} from "pagopa-interop-models";
import { afterEach, inject } from "vitest";
import { inject } from "vitest";
import { unmarshall } from "@aws-sdk/util-dynamodb";
import { match } from "ts-pattern";

export const config = inject("tokenGenerationReadModelConfig");
export const { cleanup } = setupTestContainersVitest();

afterEach(cleanup);

// TODO: same function as catalog-platformstate-writer
export const writeTokenStateEntry = async (
Expand All @@ -52,7 +48,9 @@ export const writeTokenStateEntry = async (
S: tokenStateEntry.descriptorState!,
},
descriptorAudience: {
S: tokenStateEntry.descriptorAudience!,
L: tokenStateEntry.descriptorAudience!.map((item) => ({
S: item,
})),
},
// descriptorVoucherLifespan: {
// N: tokenStateEntry.descriptorVoucherLifespan!.toString(),
Expand Down Expand Up @@ -261,7 +259,9 @@ export const writeCatalogEntry = async (
S: catalogEntry.state,
},
descriptorAudience: {
S: catalogEntry.descriptorAudience,
L: catalogEntry.descriptorAudience.map((item) => ({
S: item,
})),
},
descriptorVoucherLifespan: {
N: catalogEntry.descriptorVoucherLifespan.toString(),
Expand Down

0 comments on commit 472ba4a

Please sign in to comment.