feat!: update validate_provider_config? endpoint
This commit is contained in:
parent
975e56efc6
commit
a9f0dc35f9
@ -58,7 +58,7 @@ class Whatsapp::Providers::WhatsappBaileysService < Whatsapp::Providers::BaseSer
|
|||||||
|
|
||||||
def validate_provider_config?
|
def validate_provider_config?
|
||||||
response = HTTParty.get(
|
response = HTTParty.get(
|
||||||
"#{provider_url}/status",
|
"#{provider_url}/status/auth",
|
||||||
headers: api_headers
|
headers: api_headers
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -163,8 +163,8 @@ describe Whatsapp::Providers::WhatsappBaileysService do
|
|||||||
describe '#validate_provider_config?' do
|
describe '#validate_provider_config?' do
|
||||||
context 'when response is successful' do
|
context 'when response is successful' do
|
||||||
it 'returns true' do
|
it 'returns true' do
|
||||||
stub_request(:get, "#{whatsapp_channel.provider_config['provider_url']}/status")
|
stub_request(:get, "#{whatsapp_channel.provider_config['provider_url']}/status/auth")
|
||||||
.with(headers: { 'Content-Type' => 'application/json', 'x-api-key' => whatsapp_channel.provider_config['api_key'] })
|
.with(headers: stub_headers(whatsapp_channel))
|
||||||
.to_return(status: 200, body: '', headers: {})
|
.to_return(status: 200, body: '', headers: {})
|
||||||
|
|
||||||
expect(service.validate_provider_config?).to be true
|
expect(service.validate_provider_config?).to be true
|
||||||
@ -173,8 +173,8 @@ describe Whatsapp::Providers::WhatsappBaileysService do
|
|||||||
|
|
||||||
context 'when response is unsuccessful' do
|
context 'when response is unsuccessful' do
|
||||||
it 'logs the error and returns false' do
|
it 'logs the error and returns false' do
|
||||||
stub_request(:get, "#{whatsapp_channel.provider_config['provider_url']}/status")
|
stub_request(:get, "#{whatsapp_channel.provider_config['provider_url']}/status/auth")
|
||||||
.with(headers: { 'Content-Type' => 'application/json', 'x-api-key' => whatsapp_channel.provider_config['api_key'] })
|
.with(headers: stub_headers(whatsapp_channel))
|
||||||
.to_return(status: 400, body: 'error message', headers: {})
|
.to_return(status: 400, body: 'error message', headers: {})
|
||||||
allow(Rails.logger).to receive(:error).with('error message')
|
allow(Rails.logger).to receive(:error).with('error message')
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user