-
Notifications
You must be signed in to change notification settings - Fork 0
[IOPAE-2127] activation functions implementation #1342
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
Open
leopoldo94
wants to merge
11
commits into
master
Choose a base branch
from
IOPAE-2127-upser-and-get-activation-implementation
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
387ef6a
openapi spec for activations api
leopoldo94 e02b5ed
fix open api to integrate headers from apim and and fix the activatio…
leopoldo94 428fd12
add json for upsert and get activation api
leopoldo94 9f74871
rename variables to distinguish between two storage account
leopoldo94 b9ee9ba
add implementation for upsert and get activation api
leopoldo94 e41273c
add events for tracking
leopoldo94 f93f5aa
add utils for managing special services
leopoldo94 7b81a9b
rename variable to distinguish between storage accounts
leopoldo94 29a75b6
add unit test for the new api
leopoldo94 563ca25
fix unit test after refactoring
leopoldo94 51287eb
changeset
leopoldo94 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"io-services-cms-webapp": minor | ||
"@io-services-cms/models": patch | ||
--- | ||
|
||
Add Upsert and Get Service activation API |
19 changes: 19 additions & 0 deletions
19
apps/io-services-cms-webapp/GetServiceActivation/function.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"authLevel": "anonymous", | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "req", | ||
"route": "activations", | ||
"methods": ["post"] | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "res" | ||
} | ||
], | ||
"scriptFile": "../dist/main.js", | ||
"entryPoint": "httpEntryPoint" | ||
} |
19 changes: 19 additions & 0 deletions
19
apps/io-services-cms-webapp/UpsertServiceActivation/function.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"bindings": [ | ||
{ | ||
"authLevel": "anonymous", | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "req", | ||
"route": "activations", | ||
"methods": ["put"] | ||
}, | ||
{ | ||
"type": "http", | ||
"direction": "out", | ||
"name": "res" | ||
} | ||
], | ||
"scriptFile": "../dist/main.js", | ||
"entryPoint": "httpEntryPoint" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
apps/io-services-cms-webapp/src/utils/__tests__/special-services.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { describe, expect, it } from "vitest"; | ||
import * as E from "fp-ts/lib/Either"; | ||
import { ResponseErrorForbiddenNotAuthorized } from "@pagopa/ts-commons/lib/responses"; | ||
import { authorizedForSpecialServicesTask } from "../special-services"; | ||
|
||
describe("authorizedForSpecialServicesTask", () => { | ||
it("should return the category if it is SPECIAL_CATEGORY", async () => { | ||
const result = await authorizedForSpecialServicesTask("SPECIAL")(); | ||
expect(E.isRight(result)).toBe(true); | ||
if (E.isRight(result)) { | ||
expect(result.right).toBe("SPECIAL"); | ||
} | ||
}); | ||
|
||
it("should return a forbidden error if the category is not SPECIAL_CATEGORY", async () => { | ||
const result = await authorizedForSpecialServicesTask("STANDARD")(); | ||
expect(E.isLeft(result)).toBe(true); | ||
if (E.isLeft(result)) { | ||
expect(result.left).toEqual(ResponseErrorForbiddenNotAuthorized); | ||
} | ||
}); | ||
|
||
it("should return a forbidden error if the category is undefined", async () => { | ||
const result = await authorizedForSpecialServicesTask(undefined)(); | ||
expect(E.isLeft(result)).toBe(true); | ||
if (E.isLeft(result)) { | ||
expect(result.left).toEqual(ResponseErrorForbiddenNotAuthorized); | ||
} | ||
}); | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ServiceLifecycle } from "@io-services-cms/models"; | ||
import { | ||
IResponseErrorForbiddenNotAuthorized, | ||
ResponseErrorForbiddenNotAuthorized, | ||
} from "@pagopa/ts-commons/lib/responses"; | ||
import * as O from "fp-ts/lib/Option"; | ||
import * as TE from "fp-ts/lib/TaskEither"; | ||
import { pipe } from "fp-ts/lib/function"; | ||
|
||
const SPECIAL_CATEGORY: ServiceLifecycle.definitions.Service["data"]["metadata"]["category"] = | ||
"SPECIAL"; | ||
|
||
// Authorization check: only services of SPECIAL_CATEGORY can proceed | ||
export const authorizedForSpecialServicesTask = ( | ||
category: ServiceLifecycle.definitions.Service["data"]["metadata"]["category"], | ||
): TE.TaskEither< | ||
IResponseErrorForbiddenNotAuthorized, | ||
ServiceLifecycle.definitions.Service["data"]["metadata"]["category"] | ||
> => | ||
pipe( | ||
O.fromNullable(category), | ||
O.filter((cat) => cat === SPECIAL_CATEGORY), | ||
TE.fromOption(() => ResponseErrorForbiddenNotAuthorized), | ||
); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
suggestion(non-blocking): we can refactor it into a more understandable form