-
Notifications
You must be signed in to change notification settings - Fork 25
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
[#171211343] Adds user-data-processing API #584
Conversation
Affected stories
Generated by 🚫 dangerJS |
can you please fix the tests in userDataProcessingService.test.ts ? Cannot find module 'generated/backend/SpidLevel' from 'userDataProcessingService.test.ts' |
api_backend.yaml
Outdated
post: | ||
operationId: upsertUserDataProcessing | ||
summary: Set User's data processing choices | ||
description: Upsert user data processing for the current authenticated user. |
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.
can you change this with the actual use case (something like "Let the authenticated user express his will to retrieve or delete his stored data"
api_backend.yaml
Outdated
$ref: "#/definitions/ProblemJson" | ||
"/user-data-processing/{choice}": | ||
x-swagger-router-controller: UserDataProcessingController | ||
post: |
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.
it looks like this is a get (not a post)
api_backend.yaml
Outdated
post: | ||
operationId: getUserDataProcessing | ||
summary: Get User's data processing | ||
description: Get user data processing for the current authenticated user and the given choice. |
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.
same as above (more friendly description)
api_backend.yaml
Outdated
description: User data processing retrieved | ||
schema: | ||
$ref: "#/definitions/UserDataProcessing" | ||
"400": |
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.
in which case does this return 400 ?
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.
In theory this doesn't return 400 in any case, because backend matches session_token with the fiscalCode stored in Redis Cache, but on the other side io-functions-app provides 400 as a return code. Do i have to remove it?
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.
yes if the method cannot return 400
description: Not found. | ||
schema: | ||
$ref: "#/definitions/ProblemJson" | ||
"429": |
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.
it is not clear on why this may return 429 and upsertUserDataProcessing does not
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.
it's my fault, this may return 429 as GetUserDataProcessing ( IResponseErrorTooManyRequests is provided by the controller's method )
jest.clearAllMocks(); | ||
}); | ||
|
||
it("calls the getUserDataProcessing on the UserDataProcessingService with valid values", async () => { |
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.
test descriptions must begin with "should .." and describe the expectation. ie.
it("should return a successful response in case a valid payload is provided")
same for every other description.
@@ -0,0 +1,76 @@ | |||
/** | |||
* This controller handles reading the user profile from the |
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.
it looks like this description is outdated
(take care when cut&pasting pls : )
Codecov Report
@@ Coverage Diff @@
## master #584 +/- ##
==========================================
+ Coverage 82.82% 82.92% +0.10%
==========================================
Files 46 48 +2
Lines 1339 1394 +55
Branches 235 242 +7
==========================================
+ Hits 1109 1156 +47
- Misses 219 226 +7
- Partials 11 12 +1
Continue to review full report at Codecov.
|
api_backend.yaml
Outdated
required: true | ||
responses: | ||
'200': | ||
description: User Data processing created. |
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.
description: User Data processing created. | |
description: User Data processing created / updated. |
api_backend.yaml
Outdated
description: User data processing retrieved | ||
schema: | ||
$ref: "#/definitions/UserDataProcessing" | ||
"400": |
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.
yes if the method cannot return 400
expect(res.kind).toEqual("IResponseErrorInternal"); | ||
}); | ||
|
||
it("returns a 500 response if the response from the getUserDataProcessing API returns something wrong", async () => { |
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.
it("returns a 500 response if the response from the getUserDataProcessing API returns something wrong", async () => { | |
it("should return an error if getUserDataProcessing API returns invalid data", async () => { |
}); | ||
}); | ||
|
||
it("returns an 429 HTTP error from getUserDataProcessing upstream API", async () => { |
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.
should...
expect(res.kind).toEqual("IResponseErrorTooManyRequests"); | ||
}); | ||
|
||
it("returns an error if the getUserDataProcessing API returns an error", async () => { |
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.
ditto
}); | ||
}); | ||
|
||
it("should return a BadRequestError response by calling upsertUserDataProcessing on the UserDataProcessingService with empty user and valid upsert user", async () => { |
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.
it("should return a BadRequestError response by calling upsertUserDataProcessing on the UserDataProcessingService with empty user and valid upsert user", async () => { | |
it("should return a bad request response if request user is empty in the request", async () => { |
the fact that we're calling UserDataProcessingController#upsertUserDataProcessing
is inferred by the describe call
expect(res.kind).toEqual("IResponseErrorTooManyRequests"); | ||
}); | ||
|
||
it("returns an error if the upsertUserDataProcessing API returns an error", async () => { |
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.
should..
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
it("returns an upserted user data processing from the API", async () => { |
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.
should..
lgtm. @BurnedMarshal can you please take a look at this PR ? |
Adds UserDataProcessing API to let the authenticated user express the will to retrieve or delete her own data (stored into application infrastructure).