Closed marfavi closed 1 year ago
Kudos, SonarCloud Quality Gate passed!
Merging #429 (dfd6165) into develop (2bb7da1) will increase coverage by
4.74%
. The diff coverage is100.00%
.
@@ Coverage Diff @@
## develop #429 +/- ##
===========================================
+ Coverage 71.44% 76.19% +4.74%
===========================================
Files 114 115 +1
Lines 1194 1218 +24
===========================================
+ Hits 853 928 +75
+ Misses 341 290 -51
Flag | Coverage Δ | |
---|---|---|
unittests | 76.19% <100.00%> (+4.74%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
Impacted Files | Coverage Δ | |
---|---|---|
lib/utils/mutex.dart | 100.00% <100.00%> (+100.00%) |
:arrow_up: |
lib/utils/reactivation_authenticator.dart | 100.00% <100.00%> (+100.00%) |
:arrow_up: |
lib/utils/throttler.dart | 100.00% <100.00%> (ø) |
Summary
This pull request introduces changes to the
reactivation_authenticator.dart
file, including a bug fix. The utility classmutex.dart
is also rewritten (but unused), and a new utility classthrottler.dart
is added. All these files have corresponding tests.Closes #416 Closes #492
Bug fixes
Fixed a bug where the user was not evicted if the token was expired. The method
ReactivationAuthenticator.authenticate()
now checks the request body type against theLoginDto
type to check if a failed request was an attempt to refresh the token; if it was, we stop execution to avoid infinite recursion. This change fixes #492.Utility classes
Mutex
utility class and added tests for it.Throttler
. This class allows you to limit the rate at which some tasks are executed by ensuring that only one task can run through theThrottler
at any given time. If a task is already running through theThrottler
, an attempt to throttle a task will instead return the currently running task.Task
class to support asynchronous operations, alongside other fpdart utilities such asOption
,Unit
, and thebool.match()
extension where appropriate.ReactivationAuthenticator
The
ReactivationAuthenticator
class has been rewritten to use the newThrottler
class instead of theMutex
class. TheReactivationAuthenticator
class has also been simplified and cleaned up.For example, we no longer needs to maintain internal state about whether we should throttle a token refresh attempt, and we don't need to check whether a
Mutex
is locked, since theThrottler
class handles both cases for us.The class is also tested with full coverage. This change closes #416.
Service locator
initHttp()
inservice_locator.dart
.service_locator.dart
, theReactivationAuthenticator
class is now registered in two steps:ReactivationAuthenticator
is registered as a singleton using the constructorReactivationAuthenticator.uninitialized()
.ReactivationAuthenticator.initialize()
is called to initialize theReactivationAuthenticator
with theAccountRemoteDataSource
to use.