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

Inconsistencies between implementation and API spec #83

Closed
71 tasks done
patriciagarcia opened this issue Feb 18, 2016 · 11 comments
Closed
71 tasks done

Inconsistencies between implementation and API spec #83

patriciagarcia opened this issue Feb 18, 2016 · 11 comments
Assignees

Comments

@patriciagarcia
Copy link
Contributor

patriciagarcia commented Feb 18, 2016

It seems that the current implementation is not completely compatible with the API spec, here is the list of differences I found, for creating follow up issues.

Some things to take into account:

  • to look for inconsistencies, I only checked the tests, not the actual implementation, I thought it was a better idea because this way I can find all the missing tests too.
  • sometimes the bug is in the API spec, sometimes in the code, when I say "it should do x instead of y", I mean that it should be that according to the spec. When the problem is in the spec, I mention it explicitly.
  • some of the comments are not even bugs but something I am not sure it's right, in that case it's mentioned as "Question".
  • some of them are repeated in many calls and they might be better solved by creating a test helper that can be reused (for example with the 409 and 401 and 400 errors).
  • please, don't dismiss them lightly assuming that is the API what is wrong (instead of the implementation), the API spec took a lot of work and discussion, everything that is in there has been thought carefully. That doesn't mean there is no mistakes, of course! but it means that if something it's going to be changed it should be considered carefully too ;-). Also, it should be considered if it affects other parts of the spec.

Let me know if there are any questions!

Session

PUT /session

PUT /session?include=account.profile

GET /session

DELETE /session

Account

PUT /session/account

GET /session/account

PATCH /session/account

DELETE /session/account

  • in the test 'without valid session' the error to return should be 401, "Session invalid" instead of 404
  • When authorization is required but missing, return with 401 #94 missing test: should return 401, "Authorization header missing" if the request misses the authorization header
  • add test for DELETE /session/account?include=foobar and test that server returns 400 bad request as per JSON API spec

Profile

GET /session/account/profile

PATCH /session/account/profile

Requests

In all relevant /requests routes

  • add test for <METHOD> /requests?include=foobar and test that server returns 400 bad request as per JSON API spec

POST /requests

Admins

User account collection

POST /accounts

GET /accounts

GET /accounts/id

PATCH /accounts/id

DELETE /accounts/id

@passcod
Copy link

passcod commented Feb 18, 2016

Also, unless I've missed it, the spec doesn't mention that admins don't have a profile, as this issue suggests.

@gr2m
Copy link
Member

gr2m commented Feb 18, 2016

the handling of admins is specific to Hoodie, it’s out of scope of the generic account JSON API spec

@passcod
Copy link

passcod commented Feb 18, 2016

That's fine, but the spec has this line:

Every account has an associated profile, by default, an empty one is created when creating the account.

Which to me parses as:

Every account has an associated profile.
By default, an empty one is created when creating the account.

So are Hoodie admins non-compliant or should the spec mention that profiles are actually optional? Or alternatively, should this line in the spec be parsed as:

Every account has an associated profile by default.
An empty one is created when creating the account.

@gr2m
Copy link
Member

gr2m commented Feb 18, 2016

yes, I’m sorry, Hoodie admins are not actual accounts that you can sign in with, they are only used to manage your app settings, other accounts, etc.

So we implement the Spec for normal user accounts in hoodie-server-account, Admins are treated differently, but that is special to Hoodie and does not need to be specified in the Spec. The Spec is not tied to Hoodie

@breun
Copy link
Contributor

breun commented Feb 21, 2016

The second item under PUT /session says Invalid credentials -> Invalid password, but it should be the other way around. :o)

@gr2m
Copy link
Member

gr2m commented Feb 21, 2016

fixed, thanks @breun

@gr2m
Copy link
Member

gr2m commented Feb 24, 2016

according to JSON API spec: the query string ?include= with any unsupported path should return 400 Bad Request. Add this error to the spec and add a test and the implementation for it to the code.

I suggest we simply reference the JSON API query parameters instead of repeating the JSON API spec in our own. I’ve started a PR here: hoodiehq/account-json-api#23 any thoughts?

@gr2m
Copy link
Member

gr2m commented Feb 25, 2016

I think all issues regarding the spec not mentioning query arguments like PUT /session?include=account.profile have been addressed by hoodiehq/account-json-api#23@patriciagarcia would love your feedback on this

@gr2m
Copy link
Member

gr2m commented Feb 28, 2016

@patriciagarcia I’m going and rewording your list to make it simpler to create starter issues out of them. I removed this these

POST /requests

missing error to add to the spec: for requests that don't support authentication, it returns 403 if an authorization header is provided.

I think if authentication is not needed, it can be simply ignored, no need to throw an error? Maybe there is a test case for that though :)

GET /accounts

Question: what error should be returned when the user is not an admin? I'd say 401. This needs to be tested and added to the API spec.

we already have the 401 Session invalid in the spec. I’ve reworded it to make sure we have a test for that

GET /accounts

  • according to JSON API spec: the query string ?include=<path> with any unsupported path should return 404 Bad Request. Add this error to the spec and add a test and the implementation for it to the code.

gr2m added a commit that referenced this issue Feb 28, 2016
resolves the  errors mentiond in
#83

* * *

This commit was sponsored by Neighbourhoodie

You can hire Neighbourhoodie for all your
Hoodie / CouchDB / Offline First needs
http://go.hood.ie/thehoodiefirm
gr2m added a commit that referenced this issue Feb 29, 2016
resolves the  errors mentiond in
#83

* * *

This commit was sponsored by Neighbourhoodie

You can hire Neighbourhoodie for all your
Hoodie / CouchDB / Offline First needs
http://go.hood.ie/thehoodiefirm
@gr2m
Copy link
Member

gr2m commented Oct 15, 2016

@patriciagarcia hey Pat, I know it’s been a looooooong while, but can you recall why you suggested to "Also remove call to invalid-type-error.js (!)" for PATCH /accounts/123?

gr2m added a commit that referenced this issue Oct 15, 2016
gr2m added a commit that referenced this issue Oct 16, 2016
@gr2m
Copy link
Member

gr2m commented Oct 16, 2016

yay finally created issues for all the things that Patricia found :) Took only 8 months but hey ✌️ Thanks again for your great help Patricia 👏

@gr2m gr2m closed this as completed Oct 16, 2016
@gr2m gr2m removed the in progress label Oct 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants