Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions config/textify.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
'sender_id' => env('DHOROLA_SENDER_ID'),
'base_uri' => env('DHOROLA_BASE_URI', 'https://api.dhorolasms.net'),
'timeout' => env('DHOROLA_TIMEOUT', 30),
'verify_ssl' => env('DHOROLA_VERIFY_SSL', true),
'verify_ssl' => env('DHOROLA_VERIFY_SSL', false),
],

'bulksmsbd' => [
Expand All @@ -92,7 +92,7 @@
'campaign_id' => env('MIMSMS_CAMPAIGN_ID'),
'base_uri' => env('MIMSMS_BASE_URI', 'https://api.mimsms.com'),
'timeout' => env('MIMSMS_TIMEOUT', 30),
'verify_ssl' => env('MIMSMS_VERIFY_SSL', true),
'verify_ssl' => env('MIMSMS_VERIFY_SSL', false),
],

'esms' => [
Expand All @@ -101,7 +101,7 @@
'sender_id' => env('ESMS_SENDER_ID'),
'base_uri' => env('ESMS_BASE_URI', 'https://login.esms.com.bd'),
'timeout' => env('ESMS_TIMEOUT', 30),
'verify_ssl' => env('ESMS_VERIFY_SSL', true),
'verify_ssl' => env('ESMS_VERIFY_SSL', false),
],

'revesms' => [
Expand All @@ -113,7 +113,7 @@
'base_uri' => env('REVESMS_BASE_URI', 'https://smpp.revesms.com:7790'),
'balance_uri' => env('REVESMS_BALANCE_URI', 'https://smpp.revesms.com'),
'timeout' => env('REVESMS_TIMEOUT', 30),
'verify_ssl' => env('REVESMS_VERIFY_SSL', true),
'verify_ssl' => env('REVESMS_VERIFY_SSL', false),
],

'alphasms' => [
Expand All @@ -122,7 +122,7 @@
'sender_id' => env('ALPHASMS_SENDER_ID'),
'base_uri' => env('ALPHASMS_BASE_URI', 'https://api.sms.net.bd'),
'timeout' => env('ALPHASMS_TIMEOUT', 30),
'verify_ssl' => env('ALPHASMS_VERIFY_SSL', true),
'verify_ssl' => env('ALPHASMS_VERIFY_SSL', false),
],

// Global SMS Providers
Expand All @@ -141,7 +141,7 @@
'from' => env('NEXMO_FROM', 'Vonage APIs'),
'client_ref' => env('NEXMO_CLIENT_REF'), // Optional: Custom reference for tracking
'timeout' => env('NEXMO_TIMEOUT', 30),
'verify_ssl' => env('NEXMO_VERIFY_SSL', true),
'verify_ssl' => env('NEXMO_VERIFY_SSL', false),
],
],

Expand Down
2 changes: 1 addition & 1 deletion src/Providers/Bangladeshi/AlphaSmsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected function getClientConfig(): array
return [
'base_uri' => $this->config['base_uri'] ?? 'https://api.sms.net.bd',
'timeout' => $this->config['timeout'] ?? 30,
'verify' => $this->config['verify_ssl'] ?? true,
'verify' => $this->config['verify_ssl'] ?? false,
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Providers/Bangladeshi/DhorolaSmsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected function getClientConfig(): array
return [
'base_uri' => $this->config['base_uri'] ?? 'https://api.dhorolasms.net',
'timeout' => $this->config['timeout'] ?? 30,
'verify' => $this->config['verify_ssl'] ?? true,
'verify' => $this->config['verify_ssl'] ?? false,
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Providers/Bangladeshi/EsmsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected function getClientConfig(): array
return [
'base_uri' => $this->config['base_uri'] ?? 'https://login.esms.com.bd',
'timeout' => $this->config['timeout'] ?? 30,
'verify' => $this->config['verify_ssl'] ?? true,
'verify' => $this->config['verify_ssl'] ?? false,
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Providers/Bangladeshi/MimSmsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected function getClientConfig(): array
return [
'base_uri' => $this->config['base_uri'] ?? 'https://api.mimsms.com',
'timeout' => $this->config['timeout'] ?? 30,
'verify' => $this->config['verify_ssl'] ?? true,
'verify' => $this->config['verify_ssl'] ?? false,
];
}

Expand Down
4 changes: 2 additions & 2 deletions src/Providers/Bangladeshi/ReveSmsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected function getClientConfig(): array
return [
'base_uri' => $this->config['base_uri'] ?? 'https://smpp.revesms.com:7790',
'timeout' => $this->config['timeout'] ?? 30,
'verify' => $this->config['verify_ssl'] ?? true,
'verify' => $this->config['verify_ssl'] ?? false,
];
}

Expand Down Expand Up @@ -140,7 +140,7 @@ public function getBalance(): float
$balanceClient = new \GuzzleHttp\Client([
'base_uri' => $balanceUri,
'timeout' => $this->config['timeout'] ?? 30,
'verify' => $this->config['verify_ssl'] ?? true,
'verify' => $this->config['verify_ssl'] ?? false,
]);

$response = $balanceClient->get('/sms/smsConfiguration/smsClientBalance.jsp', [
Expand Down
2 changes: 1 addition & 1 deletion src/Providers/BaseProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ protected function getClientConfig(): array
{
return [
'timeout' => $this->config['timeout'] ?? 30,
'verify' => $this->config['verify_ssl'] ?? true,
'verify' => $this->config['verify_ssl'] ?? false,
];
}

Expand Down
100 changes: 100 additions & 0 deletions tests/SslVerificationTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php

declare(strict_types=1);

use DevWizard\Textify\Providers\Bangladeshi\AlphaSmsProvider;
use DevWizard\Textify\Providers\Bangladeshi\DhorolaSmsProvider;
use DevWizard\Textify\Providers\Bangladeshi\EsmsProvider;
use DevWizard\Textify\Providers\Bangladeshi\MimSmsProvider;
use DevWizard\Textify\Providers\Bangladeshi\ReveSmsProvider;

/**
* Helper function to get client config using reflection
*/
function getClientConfig($provider): array
{
$reflection = new ReflectionClass($provider);
$method = $reflection->getMethod('getClientConfig');
$method->setAccessible(true);

return $method->invoke($provider);
}

it('defaults SSL verification to false for all providers', function () {

// Test ReveSmsProvider
$reveProvider = new ReveSmsProvider([
'apikey' => 'test_key',
'secretkey' => 'test_secret',
'client_id' => 'test_client',
]);
$reveConfig = getClientConfig($reveProvider);
expect($reveConfig['verify'])->toBeFalse();

// Test AlphaSmsProvider
$alphaProvider = new AlphaSmsProvider([
'api_key' => 'test_key',
]);
$alphaConfig = getClientConfig($alphaProvider);
expect($alphaConfig['verify'])->toBeFalse();

// Test DhorolaSmsProvider
$dhorolaProvider = new DhorolaSmsProvider([
'api_key' => 'test_key',
'sender_id' => 'test_sender',
]);
$dhorolaConfig = getClientConfig($dhorolaProvider);
expect($dhorolaConfig['verify'])->toBeFalse();

// Test EsmsProvider
$esmsProvider = new EsmsProvider([
'api_token' => 'test_token',
'sender_id' => 'test_sender',
]);
$esmsConfig = getClientConfig($esmsProvider);
expect($esmsConfig['verify'])->toBeFalse();

// Test MimSmsProvider
$mimProvider = new MimSmsProvider([
'username' => 'test@example.com',
'apikey' => 'test_key',
]);
$mimConfig = getClientConfig($mimProvider);
expect($mimConfig['verify'])->toBeFalse();
});

it('allows SSL verification to be explicitly enabled', function () {
// Test that explicit verify_ssl=true works
$reveProvider = new ReveSmsProvider([
'apikey' => 'test_key',
'secretkey' => 'test_secret',
'client_id' => 'test_client',
'verify_ssl' => true,
]);
$reveConfig = getClientConfig($reveProvider);
expect($reveConfig['verify'])->toBeTrue();

// Test that explicit verify_ssl=false works
$alphaProvider = new AlphaSmsProvider([
'api_key' => 'test_key',
'verify_ssl' => false,
]);
$alphaConfig = getClientConfig($alphaProvider);
expect($alphaConfig['verify'])->toBeFalse();
});

it('ensures ReveSmsProvider balance client also respects SSL verification setting', function () {
// Create a provider with SSL verification disabled
$provider = new ReveSmsProvider([
'apikey' => 'test_key',
'secretkey' => 'test_secret',
'client_id' => 'test_client',
'verify_ssl' => false,
]);

// Verify the getBalance method exists
expect(method_exists($provider, 'getBalance'))->toBeTrue();

// Verify that the provider is properly configured
expect($provider)->toBeInstanceOf(ReveSmsProvider::class);
});