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
{{ message }}
This repository was archived by the owner on Nov 23, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Nov 23, 2026. It is now read-only.
Add tests for all auth and access token refresh flows #7232
We have fixed every auth and access token refresh scenario that we could come up with:
oCIS / oidc with refresh token (i.e. offline_access in requested scopes) works
oCIS / oidc without refresh token (i.e. token renewal via iframe) works
oCIS / oauth2 with refresh token (i.e. offline_access in requested scopes) works
oc10 / oauth2 without refresh token (i.e. token renewal via iframe) works.
It's pretty cumbersome to set up all the environments and test everything manually. To give us more confidence in changes - especially when updating oidc-client-ts, we would like to have acceptance tests that test all of the above flows.
Expected behaviour
Tests fail when something breaks with the lib we're using or the way we're using it.
@fschade @ScharfViktor @phil-davis@individual-it do you have ideas how to achieve this with playwright / the e2e test suite?
As a side note: The access token lifetime is currently hardcoded in both the oauth2 oc10 app and the idp service in ocis.
oCIS / oidc with refresh token (i.e. offline_access in requested scopes) works
oCIS / oidc without refresh token (i.e. token renewal via iframe) works
Should we have to configure web to achieve either of the above behavior? which is the default? or both works at the same time?
What type of test scenario/flow is best suited for this?
- login
- do something
- wait for token expiry
- do something
By default offline_access is not in the requested scopes, so first mentioned scenario is the default behaviour (no refresh token => token renewal will happen with the currently valid access token just seconds before it expires).
Like @dschmidt wrote, adding offline_access to WEB_OIDC_SCOPE will cause web to have a refresh token, so that it can obtain a new access token even if the current access token expired. That's the second scenario.
For both scenarios:
login
do something to confirm that the login worked (e.g. create a folder in the web ui)
wait for token expiry (both scenarios will obtain a new access token)
do something to confirm that the token renewal worked (e.g. navigate into the folder)
On top of that, for the second scenario (with offline_access / refresh token) it would be great to have an additional test that navigates away from web entirely and comes back after the access token has expired to validate that a new access token is obtained. Validation can again happen by navigating into a folder or whatever else is easy as an action that requires authentication.
Maybe that's obvious anyhow, but it would be great to somehow validate that the right mechanism was used.
What I'm saying is: that the page still works after token timeout in itself does not guarantee that iframe or refresh token mechanism were used (except for the "on top case" @kulmann brought up), so it wouldn't catch a bug in our code that accidentally completely disables token refresh mechanism e.g.
Maybe that's obvious anyhow, but it would be great to somehow validate that the right mechanism was used. What I'm saying is: that the page still works after token timeout in itself does not guarantee that iframe or refresh token mechanism were used (except for the "on top case" @kulmann brought up), so it wouldn't catch a bug in our code that accidentally completely disables token refresh mechanism e.g.
So basically the "on top" case for the first scenario, but this time having the test succeed if the user needs to login again after navigating back to web? :-) Or do you want to have checks that go down into the business logic of oidc-client-ts?
I'm not sure how we can test it meaningfully - but in doubt maybe we can check for the presence of the iframe or something like that.. otherwise it's probably hard to know which endpoints of the IDP have been used, dunno
Activity
kulmann commentedon Jul 7, 2022
@fschade @ScharfViktor @phil-davis @individual-it do you have ideas how to achieve this with playwright / the e2e test suite?
As a side note: The access token lifetime is currently hardcoded in both the
oauth2oc10 app and theidpservice in ocis.individual-it commentedon Jul 8, 2022
added to the backlog for now, let's chat about this next week
SagarGi commentedon Nov 7, 2022
@individual-it since e2e tests will be done by
owncoudthemselves for now. So putting this to backlog.saw-jan commentedon Jul 24, 2024
Is it still a thing?
CC @ScharfViktor @kulmann
kulmann commentedon Jul 24, 2024
Would still be super nice, yes. Basically as a regression test for the whole token renewal flow.
We currently support ocis with oidc and either with or without refresh token. From the original description, test that:
The access token timeout can be configured via
IDP_ACCESS_TOKEN_EXPIRATION(in seconds) for the built in idp. Don't go below 30 seconds.Do you have capacity to work on this @saw-jan ?
saw-jan commentedon Jul 24, 2024
We need to know what these flows mean:
Should we have to configure web to achieve either of the above behavior? which is the default? or both works at the same time?
What type of test scenario/flow is best suited for this?
dschmidt commentedon Jul 24, 2024
Adding
offline_accesstoWEB_OIDC_SCOPEshould get you refresh_tokens and is iirc/hopefully all you need to enable its usage in oC Webkulmann commentedon Jul 24, 2024
By default
offline_accessis not in the requested scopes, so first mentioned scenario is the default behaviour (no refresh token => token renewal will happen with the currently valid access token just seconds before it expires).Like @dschmidt wrote, adding
offline_accesstoWEB_OIDC_SCOPEwill cause web to have a refresh token, so that it can obtain a new access token even if the current access token expired. That's the second scenario.For both scenarios:
On top of that, for the second scenario (with offline_access / refresh token) it would be great to have an additional test that navigates away from web entirely and comes back after the access token has expired to validate that a new access token is obtained. Validation can again happen by navigating into a folder or whatever else is easy as an action that requires authentication.
saw-jan commentedon Jul 24, 2024
Great. THanks for the clarification.
We will put it to QA project board
dschmidt commentedon Jul 24, 2024
Maybe that's obvious anyhow, but it would be great to somehow validate that the right mechanism was used.
What I'm saying is: that the page still works after token timeout in itself does not guarantee that iframe or refresh token mechanism were used (except for the "on top case" @kulmann brought up), so it wouldn't catch a bug in our code that accidentally completely disables token refresh mechanism e.g.
kulmann commentedon Jul 24, 2024
So basically the "on top" case for the first scenario, but this time having the test succeed if the user needs to login again after navigating back to web? :-) Or do you want to have checks that go down into the business logic of oidc-client-ts?
dschmidt commentedon Jul 24, 2024
I'm not sure how we can test it meaningfully - but in doubt maybe we can check for the presence of the iframe or something like that.. otherwise it's probably hard to know which endpoints of the IDP have been used, dunno