You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is my usecase: my application authenticates against an OAuth2 server, and I want to test how my app behaves during the user authentication phase. Usually it goes like this:
users try to access to a protected endpoint
the endpoints redirects to the authentication server
the authentication server logs the users in if needed and get user consent if needed
it redirects back to a given endpoint in the application
that application endpoints performs a new request to the authentication server and gets a token that authenticates the user
Currently in my tests, I run a basic authentication server wsgi application in a thread. You can see a real world example in pytest-iam, but a nominal case looks for example like:
deftest_nominal_case(iam_server, user, testclient)
# attempt to access a protected pageres=testclient.get("/login")
# authorization code request (already logged in an consented)res=requests.get(res.location, allow_redirects=False)
# access to the application redirection URIres=testclient.get(res.headers["Location"])
While this is functional, making the call to requests by hand (or any other http lib) is cumbersome, and I think this would be nice if webtest could manage this. This would make the test looks like this:
deftest_nominal_case(iam_server, user, testclient)
# attempt to access a protected pageres=testclient.get("/login")
# authorization code request (already logged in an consented)res=res.follow()
# access to the application redirection URIres=res.follow()
There may be restrictions to set up, like for instance only perform requests for given domains like localhost.
What do you think?
Should this belong in webtest or in another library? We could think of a lib webtest-requests that would bring this behavior for instance.
If this could be done in webtest, what http lib should be used?
The text was updated successfully, but these errors were encountered:
Hi, to me you have to mock/avoid external calls. So this feature makes no sense in webtest itself. Maybe it's doable in another library but be aware, this will be very tricky.
Nowadays, I hear more often Playwright > Cypress > Selenium. There are other similar tools, but they all have quirks and other considerations, such as who backs the tool.
Here is my usecase: my application authenticates against an OAuth2 server, and I want to test how my app behaves during the user authentication phase. Usually it goes like this:
Currently in my tests, I run a basic authentication server wsgi application in a thread. You can see a real world example in pytest-iam, but a nominal case looks for example like:
While this is functional, making the call to
requests
by hand (or any other http lib) is cumbersome, and I think this would be nice if webtest could manage this. This would make the test looks like this:There may be restrictions to set up, like for instance only perform requests for given domains like localhost.
What do you think?
Should this belong in webtest or in another library? We could think of a lib
webtest-requests
that would bring this behavior for instance.If this could be done in webtest, what http lib should be used?
The text was updated successfully, but these errors were encountered: