Skip to content
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

PXP-11248 PXP-11258 "POST /auth/mapping" anonymous support #164

Merged
merged 4 commits into from
Mar 12, 2024

Conversation

paulineribeyre
Copy link
Contributor

@paulineribeyre paulineribeyre commented Mar 11, 2024

Jira Tickets: PXP-11248 and PXP-11258

Update to #163
Goes with uc-cdis/guppy#254
Reason for this change: uc-cdis/guppy#254 (comment)


Tested in QA - Arborist logs when logic from uc-cdis/guppy#254 kicks in:

  • Old or new arborist + old guppy (hits GET endpoint only):
- Authenticated call:
INFO: Attempting to get username from jwt...
DEBUG: decoding token: <redacted>
INFO: found username in jwt: <redacted>
"GET /auth/mapping HTTP/1.1" 200

- Anonymous call:
"GET /auth/mapping HTTP/1.1" 200
  • Old arborist + new guppy (hits POST endpoint, falls back on GET endpoint):
- Authenticated call:
INFO: tried to handle auth mapping request but input was invalid: could not parse JSON: unexpected end of JSON input
INFO: must specify exactly one of `username` or `clientID`
"POST /auth/mapping HTTP/1.1" 400 87 "" "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"
INFO: Attempting to get username from jwt...
DEBUG: decoding token: <redacted>
INFO: found username in jwt: <redacted>
"GET /auth/mapping HTTP/1.1" 200

- Anonymous call:
INFO: tried to handle auth mapping request but input was invalid: could not parse JSON: unexpected end of JSON input
INFO: must specify exactly one of `username` or `clientID`
"POST /auth/mapping HTTP/1.1" 400
"GET /auth/mapping HTTP/1.1" 200
  • New arborist + new guppy (hits POST endpoint only):
- Authenticated call:
INFO: Attempting to get username or client ID from jwt...
DEBUG: decoding token: <redacted>
INFO: found username in jwt: <redacted>
"POST /auth/mapping HTTP/1.1" 200

- Anonymous call:
"POST /auth/mapping HTTP/1.1" 200

New Features

  • POST /auth/mapping: return "anonymous" access when the user is unauthenticated, matching the behavior of the GET /auth/mapping endpoint (previously the POST endpoint returned an error in this case)

@@ -3243,7 +3250,19 @@ func TestServer(t *testing.T) {
w := httptest.NewRecorder()
req := newRequest("POST", "/auth/mapping", nil)
handler.ServeHTTP(w, req)
assert.Equal(t, w.Code, http.StatusBadRequest, "expected a 400 response")
assert.Equal(t, w.Code, http.StatusOK, "expected a 200 OK")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from what I can see 3117 - 2129 and 3253 - 3265 seem to be the same set of code. Would it be possible to encapsulate this behavior in a separate function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@coveralls
Copy link

Coverage Status

coverage: 75.22% (-0.2%) from 75.406%
when pulling 4e7be2d on fix/post-mapping-anon
into 2904a31 on master.

Copy link

@thanh-nguyen-dang thanh-nguyen-dang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm 👍

@paulineribeyre paulineribeyre merged commit 936ef1b into master Mar 12, 2024
6 checks passed
@paulineribeyre paulineribeyre deleted the fix/post-mapping-anon branch March 12, 2024 17:07
grugna added a commit to chicagopcdc/arborist that referenced this pull request Apr 30, 2024
PXP-11248 PXP-11258 "POST /auth/mapping" anonymous support (uc-cdis#164)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants