-
Notifications
You must be signed in to change notification settings - Fork 266
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
Bug/2763 bug fix not refactor #2821
Conversation
LGTM |
@@ -15,6 +15,9 @@ | |||
- Fix: bug when tenants are over 44 bytes long (#2811) | |||
- Add: Support for null values in string filters (#2359) | |||
- Fix: Partial sanity check for custon url, only if the url contains no replacements using ${xxx} (#2280, #2279) | |||
- Fix: if entity::type is given but as an empty string, an error is returned (#1985) |
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.
I'd suggest to explain in which operations this fix has been done. Maybe this?
"Fix: if subject.entities*.type is given but as an empty string in POST /v2/subscriptions or PATCH /v2/subscriptions/{sub} , an error is returned (#1985)"
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.
The checks are done in low level functions, parseEntity() and parseEntityObject(). Should be valid for all V2 requests that have entites, including GET /v2/entities and probably more ops.
Do you still want a list of all the ops in CNR ?
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.
So you mean that before this PR entity creation with "type": ""
was failing? A bit surprissing... I think we already have .test in place that check min and max length for all id-kind fields (entity id/type, attr name/type, md name/type)...
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.
That was my understanding, I may be wrong.
In the json parse stage (parseEntity() and parseEntityObject()), there were no checks for empty 'type'. Perhaps there are checks that cover part of the request set somewhere else ... ?
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.
So, from what I've seen now, it seems all cases (except for /v2/subscriptions) of empty entity::type were caught already. just as @fgalan predicted :-), changing the CNR line
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.
Fixed in a93291f
@@ -15,6 +15,9 @@ | |||
- Fix: bug when tenants are over 44 bytes long (#2811) | |||
- Add: Support for null values in string filters (#2359) | |||
- Fix: Partial sanity check for custon url, only if the url contains no replacements using ${xxx} (#2280, #2279) | |||
- Fix: if entity::type is given but as an empty string, an error is returned (#1985) | |||
- Fix: admin requests with errors now return '400 Bad Request', not '200 OK' |
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.
"adming request" could be a big obscure, and example would help. I mean:
"Fix: admin requests (e.g. GET /version) with errors now return '400 Bad Request', not '200 OK'"
Btw, issue number is missing at the end of the line. If the fix is not related with any issue, that's perfect (asking only to check if that is the case...)
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.
Sure, an example may make it easier to understand.
No, no issue here, as far as I know, see PR description:
admin requests with errors now return '400 Bad Request', not '200 OK' (no issue, I think)
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.
Fixed in 8fa9c69
@@ -109,7 +109,7 @@ std::string OrionError::smartRender(ApiVersion apiVersion) | |||
*/ | |||
std::string OrionError::setStatusCodeAndSmartRender(ApiVersion apiVersion, HttpStatusCode* scP) | |||
{ | |||
if (apiVersion == V2) | |||
if ((apiVersion == V2) || (apiVersion == ADMIN_API)) |
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.
Great to see that the addition has not broken anything... setStatusCodeAndSmartRender() modifyication were hard in the past (at least to me...)
NTC
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.
Yeah, I am not so sure. Seeing a few really strange errors in functests ...
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.
Errors under control again, fixed in f422157 (this line is intact, the problem was elsewhere)
|
||
echo "02. Make sure the entity doesn't exist in the database" | ||
echo "======================================================" | ||
echo "db.entities.findOne()" | mongo ftest |
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.
Why don't use the GET /v2/entities operation to check it? We should use keep direct mongo queries only as last resort measure when the API doesn't provide alternatives.
(Btw, I think we have a mongoCmd() function for test harness to avoid direct calls to mongo shell)
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.
Sure, GET /v2/entities works also. As we usually do. Not sure why I implemented like this (paranoia perhaps)
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.
Fixed in 159bd5f
@@ -0,0 +1,56 @@ | |||
# Copyright 2016 Telefonica Investigacion y Desarrollo, S.A.U |
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.
Looking again, I don't see the .test covering #1985.... Maybe you missed git add
before commit? ;)
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.
I can't find one. I have created the directory but there is no functest inside ...
Also can't find any modified functest for this ...
Must check this, understand what's happened here.
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.
There wasn't any, and the problem wasn't even fixed.
I just assumed (and forgot about the functest), that the low level parse functions would take care of this (as they should). However subscriptions use their own implementation of entity parsing ...
Fixed in f422157
…s/restrict_chars_entity.test
…restrict_chars_entity.test
…763_bug_fix_not_refactor
alarmMgr.badInput(clientIp, "invalid JSON type for entity id"); | ||
ciP->httpStatusCode = SccBadRequest;; | ||
OrionError oe(SccBadRequest, "invalid JSON type for entity id", "BadRequest"); | ||
const char* errorText = "Invalid JSON type for entity id"; |
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.
Move to errorMessages.h
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.
Fixed in bc960d4
alarmMgr.badInput(clientIp, "'id' is not a valid attribute"); | ||
ciP->httpStatusCode = SccBadRequest;; | ||
OrionError oe(SccBadRequest, "invalid input, 'id' as attribute", "BadRequest"); | ||
const char* errorText = "invalid input, 'id' as attribute"; |
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.
Move to errorMessages.h
return oe.toJson(); | ||
} | ||
} | ||
else if (name == "type") | ||
{ | ||
if (type != "String") | ||
{ | ||
alarmMgr.badInput(clientIp, "invalid JSON type for entity type"); | ||
const char* errorText = "Invalid JSON type for entity type"; |
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.
Move to errorMessages.h
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.
Fixed in bc960d4
|
||
if (eP->type.empty()) | ||
{ | ||
const char* errorText = "entity type length: 0, min length supported: 1"; |
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.
Move to errorMessages.h (in fact, I think the text is already there in a previous define)
{ | ||
return "Invalid characters in entity type"; | ||
return "entity type length: 0, min length supported: 1"; |
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.
Move to errorMessages.h
@@ -384,6 +384,10 @@ static std::string parseEntitiesVector(ConnectionInfo* ciP, std::vector<EntID>* | |||
{ | |||
return badInput(ciP, "max type length exceeded"); | |||
} | |||
if (typeOpt.value.empty()) | |||
{ | |||
return badInput(ciP, "entity type length: 0, min length supported: 1"); |
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.
Move to errorMessages.h
--SHELL-- | ||
|
||
# | ||
# 01. Attempt to create a subscription with an empty entity type, see error |
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.
To make this complet and align with
"Fix: if entity::type is given but as an empty string, in payload of POST /v2/subscriptions or PATCH /v2/subscriptions/{sub}, an error is returned (#1985)"
I'd suggest to add
- Successfull creation of a subscription
- Attemp to update the existing subscription with an empty entity type, see error
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.
Fixed in bc960d4
LGTM |
Three fixes: