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

How to Implement Testcase with NINJA JWT Authentication ? #22

Closed
recervictory opened this issue Jul 14, 2022 · 4 comments
Closed

How to Implement Testcase with NINJA JWT Authentication ? #22

recervictory opened this issue Jul 14, 2022 · 4 comments

Comments

@recervictory
Copy link

recervictory commented Jul 14, 2022

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?

@eadwinCode
Copy link
Owner

@recervictory please look at this issue and tell me if its helpful to you #3

@recervictory
Copy link
Author

recervictory commented Jul 18, 2022

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 })

@eadwinCode
Copy link
Owner

@recervictory Your code is not enough to understand the problem you are facing

@FabianClemenz
Copy link

@recervictory i posted my example of how i test the APIs with Ninja JWT in the issue too - maybe this helps :)

#3 (comment)

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

3 participants