-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: Accept contentType params for DID URL Resolution [DEV-4722] #325
Conversation
fa1dcad
to
35be15c
Compare
df4017b
to
35169aa
Compare
69bc0f2
to
252c4fc
Compare
f0f5f2f
to
0f83b53
Compare
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.
Maybe the functionality of the overall task is meant to be delivered across different PR’s and I’m struggling to see the big picture, but AFAIK I don’t see anything in here that’s handling or testing what happens when the correct header/profile for URL dereferencing is supplied, but the resource is not JSON/text. (At the very least, it’s not in the tests.) Might be a function of no resources being created that are image or non-text/JSON perhaps?
"As-is" situations where only the resource is returned I'm less worried about.
services/helpers.go
Outdated
@@ -39,3 +40,48 @@ func PrepareQueries(c echo.Context) (rawQuery string, flag *string) { | |||
func GetDidParam(c echo.Context) (string, error) { | |||
return url.QueryUnescape(c.Param("did")) | |||
} | |||
|
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.
A separate note about function and variable names here: this is not getting the "header". It's specifically the Accept header. So it could be misleading that a lot of the function and variable names are called "header". I would suggest renaming functions and variables to call them "acceptHeader" or similar. (There's a similar comment I have made about variables called contentType
below.)
} | ||
|
||
var context string | ||
if contentType == types.DIDJSONLD || contentType == types.JSONLD { |
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.
Bit confused as to why this contentType
is relevant for dereferencing? These are purely about DID Resolution?
As in...if it's a resource, will it ever be these two content types?
Side note: we seem to be using a lot of different terms: sometimes header
(see previous comment on "header" vs "accept header"), sometimes contentType
like here). It's quite variable.
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.
we should populdate context if it's jsonLD right. This condition is for that.
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 you should, I was talking about inconsistent variable naming
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.
Unless I'm missing something, I don't see a test case here that would logically return "Accept: application/ld+json;profile="https://w3id.org/did-url-dereferencing" → Returns resource + metadata in a single response", since both of the test cases defined here would just return the resource which is JSON?
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.
EDIT: Maybe just needs better test descriptions
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 would also like to see a test case where the Accept
header is exactly the same string that a browser like Chrome sends, and cross-checking the results (since it doesn't have the DID URL dereferencing profile, you should not get resource + metadata back)
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.
They are added under data_with_metadata folder
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.
Hence the "EDIT". The follow-up is about adding Chrome-like Accept header to test the "default" case of loading in a browser.
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.
This seems to be test cases where there are completely invalid DID or resource IDs, but I don't see anything where the Accept headers are changed and test cases related to that?
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.
EDIT: Maybe just needs better test descriptions
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.
when accept headers are different for /resource endpoint the tests are present with the data/ directory, it's not a failure
Only the tests for application/ld+json;profile="https://w3id.org/did-url-dereferencing"
is within data_with_metadata
tests/integration/rest/resource/data_with_metadata/positive_test.go
Outdated
Show resolved
Hide resolved
tests/integration/rest/resource/data_with_metadata/positive_test.go
Outdated
Show resolved
Hide resolved
58fc643
to
f2a826e
Compare
f2a826e
to
632ab18
Compare
Duplicate of #340 |
No description provided.