TireSwingSoftware / openassign-server

OpenAssign server intended for use by a separate client via RPC
BSD 3-Clause "New" or "Revised" License
6 stars 2 forks source link

AssignmentManager view methods must require auth_token param #95

Closed mhrivnak closed 12 years ago

mhrivnak commented 12 years ago

All view methods must list 'auth_token' as the first positional argument after "self" so that this code may function:

https://github.com/TireSwingSoftware/openassign-server/blob/dev/pr_services/rpc/service.py#L206

Wrong: def exam_view(self, *args, **kwargs)

Right: exam_view(self, auth_token, *args, **kwargs):

If not, the rpc.service code will raise an exception.

jc0n commented 12 years ago

Looks good to me. I don't think there is anything that needs to be changed in the tests. The problem here was the use of an implicit design contract (via the getargspec line you cited). If you want to strictly enforce this contract it may be reasonable to add validation that all service methods accept a required positional argument 'auth_token' this could easily be done in the service_method decorator with an assertion.

mhrivnak commented 12 years ago

I agree that the decorator should validate the presence of that argument. Feel free to make it so.

jc0n commented 12 years ago

There are some service methods ie. UserManager.login and a couple of others which dont take an auth_token. I think we would have to make another decorator for those to do only what service_method does now. Then we don't have to change as much since nearly all the service methods take an auth_token.