-
Notifications
You must be signed in to change notification settings - Fork 24
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
feat: [SIW-1697] Added wallet instance revoke endpoint #1154
Conversation
Jira Pull Request LinkThis Pull Request refers to the following Jira issue SIW-1697 |
req.body, | ||
SetCurrentWalletInstanceStatusBody.decode, | ||
E.mapLeft((errors) => | ||
ResponseErrorInternal( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about
ResponseErrorInternal( | |
ResponseErrorValidation( |
@@ -183,4 +227,21 @@ export default class IoWalletController { | |||
), | |||
TE.map((response) => response.value.id) | |||
); | |||
|
|||
// TODO SIW-1706 | |||
private readonly ensureFiscalCodeIsAllowed: ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about adding tests? ie.
import { FiscalCode, NonEmptyString } from "@pagopa/ts-commons/lib/strings";
import * as TE from "fp-ts/TaskEither";
import { getResponseErrorForbiddenNotAuthorized } from "@pagopa/ts-commons/lib/responses";
import IoWalletController from "../../src/controllers/ioWalletController";
import IoWalletService from "../../src/services/ioWalletService";
// Mock the IoWalletService
const ioWalletServiceMock = {
getSubscription: jest.fn(),
} as unknown as IoWalletService;
const ioWalletController = new IoWalletController(ioWalletServiceMock);
describe("ensureFiscalCodeIsAllowed", () => {
it("should return right when the fiscal code is allowed", async () => {
// Mock successful response from getSubscription
ioWalletServiceMock.getSubscription.mockReturnValueOnce(
TE.right({
kind: "IResponseSuccessJson",
value: { state: "ACTIVE" },
})
);
const fiscalCode: FiscalCode = "VALIDFISCALCODE" as FiscalCode;
const result = await ioWalletController.ensureFiscalCodeIsAllowed(fiscalCode)();
expect(result).toEqual(TE.right(undefined));
});
it("should return left when the fiscal code is not allowed", async () => {
// Mock unsuccessful response from getSubscription
ioWalletServiceMock.getSubscription.mockReturnValueOnce(TE.left(new Error()));
const fiscalCode: FiscalCode = "INVALIDFISCALCODE" as FiscalCode;
const result = await ioWalletController.ensureFiscalCodeIsAllowed(fiscalCode)();
expect(result).toEqual(
TE.left(getResponseErrorForbiddenNotAuthorized("Not authorized to perform this action"))
);
});
it("should return left when the fiscal code is invalid", async () => {
const fiscalCode: FiscalCode = "" as FiscalCode; // Empty fiscal code
const result = await ioWalletController.ensureFiscalCodeIsAllowed(fiscalCode)();
expect(result).toEqual(
TE.left(getResponseErrorForbiddenNotAuthorized("Not authorized to perform this action"))
);
});
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ensureFiscalCodeIsAllowed
is a private method
Quality Gate passedIssues Measures |
List of Changes
PUT /wallet-instances/current/status
endpoint for user wallet instance revoke503
as response status in wallet endpointMotivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: