Send test SMS with the credentials entered in the console - #270
Merged
Merged
Conversation
"Test SMS Provider" failed with "Credentials are required to create a Client" even with a Twilio SID and token filled in (fleetbase/fleetbase#680). The test endpoints apply the entered credentials to config, but the Twilio manager copies its settings when it is built and is cached twice: as a container singleton and in the facade's static cache. Under Octane that facade cache outlives the request, and the provider's singleton closure reads the worker's base config rather than the request's copy. So a test send used whatever the worker first built: empty credentials when none were saved (the reported error), or the saved ones instead of those just entered. - After applying the entered credentials, both test endpoints rebuild the manager from this request's config and clear the facade cache. A stand-in bound in place of the real manager is left alone. - Once the test send is done the facade cache is cleared again, so the credentials under test are not reused by later requests in the worker. Fixes fleetbase/fleetbase#680
Merged
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #270 +/- ##
===========================================
Coverage 100.00% 100.00%
- Complexity 7410 7417 +7
===========================================
Files 430 430
Lines 24357 24374 +17
===========================================
+ Hits 24357 24374 +17
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes fleetbase/fleetbase#680.
Why
In Admin → System Config → Services, Test SMS Provider failed with "Credentials are required to create a Client" even though a Twilio SID and token were filled in.
testSmsProviderConfigandtestTwilioConfigdo apply the entered credentials to config, but the Twilio client never used them:Managercopies its connection settings when it's built, and it's cached twice: as thetwiliocontainer singleton and in the facade's static cache.A test send therefore used whatever client the worker built first. That meant empty credentials when none were saved yet (the reported error), or the saved credentials instead of the ones just entered, which makes the test report success for the wrong account.
What changed
refreshTwilioClient). A stand-in bound in place of the real manager is left alone.releaseTwilioClient). The credentials under test then can't be reused by later requests in the same worker, such as verification codes or notifications.Verification
[HTTP 401] Authentication Errorfrom Twilio every time;Managerbound like the provider's (closure over the config at boot, already resolved) is rebuilt with the entered credentials, for both endpoints.SettingControlleris at 100% coverage. php-cs-fixer and the date-drift check are clean.