django-ninja-extra
django-ninja-extra copied to clipboard
How to Implement Testcase with NINJA JWT Authentication ?
I have implemented Ninja JWT Authentication with Ninja Extra.
@api_controller("post/", tags=["Post"])
class PostController:
@route.post("", response=PostOut, auth=JWTAuth())
def create_post(self, payload: PostIn):
post = Post.Object.Create(**payload.dict())
resturn post
I want to implement TestPostController But how I apply NINJA JWT with that?
@recervictory please look at this issue and tell me if its helpful to you https://github.com/eadwinCode/django-ninja-extra/issues/3
I am totally new to Django, I am not able to implement that. I want to add headers={'HTTP_AUTHORIZATION': 'Bearer' +self.access_token } in the response post method but is showing Unauthorized. My code is like this...
response= self.client.post("", json=dict(description="Sample Post", ,headers={'Authorization': 'Bearer' + access_token })
@recervictory Your code is not enough to understand the problem you are facing
@recervictory i posted my example of how i test the APIs with Ninja JWT in the issue too - maybe this helps :)
https://github.com/eadwinCode/django-ninja-extra/issues/3#issuecomment-1473551557