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

Question: How to test an API with credentials? #208

Open
jhjacobs81 opened this issue Nov 6, 2024 · 2 comments
Open

Question: How to test an API with credentials? #208

jhjacobs81 opened this issue Nov 6, 2024 · 2 comments

Comments

@jhjacobs81
Copy link

Is it possible to test an api with credentials? so i can post my login details to /api/login and have it saved for future testing?

Or maybe i am overlooking something?

@jonrosner
Copy link
Contributor

What kind of authentication system do you use? If you use something token based than you can simply store the token in an environment.

@jhjacobs81
Copy link
Author

jhjacobs81 commented Nov 7, 2024

hello Jon, thank you for responding :)

currently i do this:
curl -c cookies.txt -X POST http://127.0.0.1:8080/login -H "Content-Type: application/json" -d '{ "Username": "user", "Password": "password" }'

which will generate a cookies.txt like this:
127.0.0.1:8080 FALSE / TRUE 1733555692 AppName MTczMDk2MzY5M3xEWDhFQVFMX2dBQUJFQUVRQUFBZl80QUFBUVp6ZEhKcGJtY01DUUFIZFhObGNsOXBaQVIxYVc1MEJnSUFHQT09fLtMohuQTYQ_xjDYdRxghTX1E_2NRVIyfgtvCnppCpbW

and then on subsequent request i do this:
curl -b cookies.txt -X POST http://127.0.0.1:8080/create -H "Content-Type: application/json" -d '{ "Username": "user1", "Password": "userpass" }'

its a session based webapp

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

2 participants