Skip to content

Commit

Permalink
IMN-577 Add authorization mocks (#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
taglioni-r authored Jun 17, 2024
1 parent 4690079 commit 6886a3a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { RefreshableInteropToken, genericLogger } from "pagopa-interop-commons";
import {
getMockAgreement,
getMockClient,
getMockDescriptorPublished,
getMockEService,
getMockPurpose,
Expand Down Expand Up @@ -52,12 +53,7 @@ import {
} from "../src/index.js";
import { ApiClientComponent } from "../src/model/models.js";
import { agreementStateToClientState } from "../src/utils.js";
import {
addOneClient,
addOneEService,
getMockClient,
readModelService,
} from "./utils.js";
import { addOneClient, addOneEService, readModelService } from "./utils.js";

describe("Authorization Updater processMessage", () => {
const testCorrelationId = generateId();
Expand Down
20 changes: 1 addition & 19 deletions packages/authorization-updater/test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ import {
writeInReadmodel,
} from "pagopa-interop-commons-test";
import { inject, afterEach } from "vitest";
import {
Client,
EService,
clientKind,
generateId,
toReadModelEService,
} from "pagopa-interop-models";
import { Client, EService, toReadModelEService } from "pagopa-interop-models";
import { readModelServiceBuilder } from "../src/readModelService.js";

export const { cleanup, readModelRepository } = setupTestContainersVitest(
Expand All @@ -30,15 +24,3 @@ export const addOneEService = async (eservice: EService): Promise<void> => {
export const addOneClient = async (client: Client): Promise<void> => {
await writeInReadmodel(client, clients);
};

export const getMockClient = (): Client => ({
id: generateId(),
consumerId: generateId(),
name: "Test client",
purposes: [],
description: "Client description",
users: [],
kind: clientKind.consumer,
createdAt: new Date(),
keys: [],
});
25 changes: 25 additions & 0 deletions packages/commons-test/src/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import {
purposeVersionState,
Document,
AgreementAttribute,
Key,
Client,
clientKind,
keyUse,
} from "pagopa-interop-models";
import { AuthData } from "pagopa-interop-commons";

Expand Down Expand Up @@ -223,3 +227,24 @@ export const getMockDocument = (): Document => ({
checksum: "checksum",
uploadDate: new Date(),
});

export const getMockClient = (): Client => ({
id: generateId(),
consumerId: generateId(),
name: "Test client",
purposes: [],
description: "Client description",
users: [],
kind: clientKind.consumer,
createdAt: new Date(),
keys: [],
});

export const getMockKey = (): Key => ({
name: "test key",
createdAt: new Date(),
kid: generateId(),
encodedPem: generateId(),
algorithm: "",
use: keyUse.sig,
});

0 comments on commit 6886a3a

Please sign in to comment.