Skip to content

Commit

Permalink
Feature/smtp settings fix (#967)
Browse files Browse the repository at this point in the history
* Update dependency plotly.js-dist to v2.30.1

* Update dependency axios to v1.6.8

* smtp settings fix

* updating releasenotes

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
  • Loading branch information
dgershman and renovate[bot] authored Mar 16, 2024
1 parent 2d08419 commit 888e604
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 12 deletions.
3 changes: 2 additions & 1 deletion RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Release Notes

### 4.3.1 (UNRELEASED)
*
* Fixes for call blasting and post call handling [#960]
* Fixes for invalid SMTP settings error message in the upgrade advisor.

### 4.3.0 (March 11, 2024)
* Added feature for SPAD playback `spad_option`.
Expand Down
2 changes: 1 addition & 1 deletion app/Services/UpgradeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function getStatus()

if ($this->settings->has('smtp_host')) {
foreach ($this->settings->emailSettings() as $setting) {
if ($this->settings->has($setting)) {
if (!$this->settings->has($setting)) {
return $this->getState(false, "Missing required email setting: " . $setting, $warnings);
}
}
Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 56 additions & 0 deletions tests/Feature/UpgradeAdvisorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,62 @@
);
})->with(['GET', 'POST']);

test('test with smtp settings missing', function ($method) {
$settingsService = new SettingsService();
$settingsService->set("smtp_host", "bro");
$settingsService->set("smtp_username", "bro");
$settingsService->set("smtp_password", "bro");
$settingsService->set("smtp_secure", false);
$settingsService->set("smtp_from_address", "[email protected]");
$settingsService->set("smtp_from_name", "name");
$this->twilioService->shouldReceive("client")->withArgs([])->andReturn($this->twilioClient);
$this->twilioService->shouldReceive("settings")->andReturn($settingsService);
$geocodingService = mock(GeocodingService::class)->makePartial();
app()->instance(SettingsService::class, instance: $settingsService);

$geocodingService
->shouldReceive("ping")
->withArgs(["91409"])
->andReturn((object)['status' => 'OK'])
->once();
app()->instance(GeocodingService::class, $geocodingService);

$timezoneService = mock(TimeZoneService::class)->makePartial();
$timezoneService
->shouldReceive("getTimeZoneForCoordinates")
->withAnyArgs()
->andReturn((object)['status' => 'OK'])
->once();
app()->instance(TimeZoneService::class, $timezoneService);

$this->twilioService->client()->shouldReceive('getAccountSid')->andReturn("123");
$incomingPhoneNumberContext = mock('\Twilio\Rest\Api\V2010\Account\InstanceContext');
$incomingPhoneNumberInstance= mock('\Twilio\Rest\Api\V2010\Account\IncomingPhoneNumberInstance');
$incomingPhoneNumberInstance->voiceUrl = "http://localhost:3100/yap/index.php";
$incomingPhoneNumberContext->shouldReceive('read')->withNoArgs()
->andReturn([$incomingPhoneNumberInstance])->once();

// mocking TwilioRestClient->incomingPhoneNumbers->read();
$this->twilioService->client()->incomingPhoneNumbers = $incomingPhoneNumberContext;

app()->instance(TwilioService::class, $this->twilioService);

$response = $this->call($method, '/upgrade-advisor.php');
$response
->assertStatus(200)
->assertHeader("Content-Type", "application/json")
->assertJson(
[
"status"=>true,
"message"=>"Ready To Yap!",
"warnings"=>sprintf(""),
"version"=>$settingsService->version(),
"db"=>100,
"build"=>"local"
]
);
})->with(['GET', 'POST']);

//test('bad google maps api key', function () {
// $settings = new SettingsService();
// $GLOBALS['google_maps_endpoint'] = 'https://maps.googleapis.com/maps/api/geocode/json?key=bad_key';
Expand Down

0 comments on commit 888e604

Please sign in to comment.