-
Notifications
You must be signed in to change notification settings - Fork 240
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
Fix incorrect 200 for a 401 from NMAgent #1799
Conversation
blocked on lints |
is this related to #1787? |
@rbtr, yes. As CNS is expected to just relay NMA's response (byte64 encoded) back to DNC for any decision making, we shouldn't be handling the error status code in CNA's server-side logic. I have closed my PR with an appropriate comment. |
Lints cleared. Please review. |
2de29b7
to
02f40b4
Compare
02f40b4
to
5228ceb
Compare
@rbtr approval needed again when you get a chance |
In scenarios where the subnet token does not match (leading to a 401 from NMAgent), CNS returns a 200 for the PublishStatusCode. This is incorrect, and a 401 should be returned instead. This leads clients of CNS to take incorrect action on, what they believe to be, a successful response.
It's important that we ensure that PublishResponseBody is, indeed, JSON. Also, that JSON needs to have an httpStatusCode property with its value set to the response code returned from NMAgent (in this test case, a 401).
The UnpublishStatusCode was not being set by CNS, which could lead to misbehavior from clients that expect it to be set appropriately. This uses the StatusCode provided by the nmagent.Error to propagate the httpStatusCode.
5228ceb
to
620dd55
Compare
One of these lints is inappropriate in a test, so it's been silenced (adding context to the HTTP Request). The other one is marginal, but easy to fix, so there's now a check for an error from JSON encoding.
In scenarios where the subnet token does not match (leading to a 401 from NMAgent), CNS returns a 200 for the PublishStatusCode. This is incorrect, and a 401 should be returned instead. This leads clients of CNS to take incorrect action on, what they believe to be, a successful response.
In scenarios where the subnet token does not match (leading to a 401 from NMAgent), CNS returns a 200 for the PublishStatusCode. This is incorrect, and a 401 should be returned instead. This leads clients of CNS to take incorrect action on, what they believe to be, a successful response.