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
I have a wrapper class that encapsulates Okta SDK functionality & facilitates okta login/auth for the rest of my app.
I'd like to write tests for that wrapper class, replacing the key parts of the Okta SDK with stubs/fakes, but the SDK types' visibility makes that difficult. How can I stub out WebAuthentication().login(...)?
I'm able to provide my own WebAuthentication instance in my tests, which is good. WebAuthentication.authorizationCodeFlow is a public var (also good!). If AuthorizationCodeFlow was an interface I could implement myself (or if AuthFoundationDefaults exposes an AuthorizationCodeFlow factory lambda I could override), I think I could stub authorizationCodeFlow.resume(uri, flowContext) and be able to write the tests I want.
Alternatively, if WebAuthentication itself was an interface I could implement, I could stub the entire login call; I think that would suffice as well.
New or Affected Resource(s)
Affected resources.... web authentication? Not sure how to answer this.
Provide a documentation link
N/A
Additional Information?
If there's an additional path forward you can come up with that I've missed, please let me know!
The text was updated successfully, but these errors were encountered:
Hi @erawhctim, there are a few ways that you can make test-specific code for this in the current state:
Create an Interface (ie LoginManager), and create an app-specific and test-specific class. The app-specific class can call WebAuthentication, and the test-specific class can return stubbed credentials
Describe the feature request?
I have a wrapper class that encapsulates Okta SDK functionality & facilitates okta login/auth for the rest of my app.
I'd like to write tests for that wrapper class, replacing the key parts of the Okta SDK with stubs/fakes, but the SDK types' visibility makes that difficult. How can I stub out
WebAuthentication().login(...)
?I'm able to provide my own
WebAuthentication
instance in my tests, which is good.WebAuthentication.authorizationCodeFlow
is a publicvar
(also good!). IfAuthorizationCodeFlow
was an interface I could implement myself (or ifAuthFoundationDefaults
exposes anAuthorizationCodeFlow
factory lambda I could override), I think I could stubauthorizationCodeFlow.resume(uri, flowContext)
and be able to write the tests I want.Alternatively, if
WebAuthentication
itself was an interface I could implement, I could stub the entirelogin
call; I think that would suffice as well.New or Affected Resource(s)
Affected resources.... web authentication? Not sure how to answer this.
Provide a documentation link
N/A
Additional Information?
If there's an additional path forward you can come up with that I've missed, please let me know!
The text was updated successfully, but these errors were encountered: