Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEVX-6472: Adding more Verify tests for Blacklist error response #246

Merged
merged 2 commits into from
Sep 6, 2022
Merged
Changes from 1 commit
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
69 changes: 57 additions & 12 deletions test/vonage/verify_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,51 @@ def test_request_method
assert_kind_of Vonage::Response, error.response
end

def test_blacklist_error_for_verify_with_network
superchilled marked this conversation as resolved.
Show resolved Hide resolved
uri = 'https://api.nexmo.com/verify/json'

params = {number: msisdn, brand: 'ExampleApp'}

stub_request(:post, uri).with(headers: headers, body: params.merge(api_key_and_secret)).to_return(error_response_blacklist_with_network)

error = assert_raises Vonage::ServiceError do
verify.request(params)
end

assert_kind_of Vonage::Error, error
assert_kind_of Vonage::Response, error.response
end

def test_blacklist_error_for_verify_with_request_id
uri = 'https://api.nexmo.com/verify/json'

params = {number: msisdn, brand: 'ExampleApp'}

stub_request(:post, uri).with(headers: headers, body: params.merge(api_key_and_secret)).to_return(error_response_blacklist_with_request_id)

error = assert_raises Vonage::ServiceError do
verify.request(params)
end

assert_kind_of Vonage::Error, error
assert_kind_of Vonage::Response, error.response
end

def test_blacklist_error_for_verify_with_network_and_request_id
uri = 'https://api.nexmo.com/verify/json'

params = {number: msisdn, brand: 'ExampleApp'}

stub_request(:post, uri).with(headers: headers, body: params.merge(api_key_and_secret)).to_return(error_response_blacklist_with_network_and_request_id)

error = assert_raises Vonage::ServiceError do
verify.request(params)
end

assert_kind_of Vonage::Error, error
assert_kind_of Vonage::Response, error.response
end

def test_check_method
uri = 'https://api.nexmo.com/verify/check/json'

Expand Down Expand Up @@ -164,45 +209,45 @@ def test_psd2_method
assert_kind_of Vonage::Response, error.response
end

def test_blacklist_error_with_network
uri = 'https://api.nexmo.com/verify/json'
def test_blacklist_error_for_psd2_with_network
uri = 'https://api.nexmo.com/verify/psd2/json'

params = {number: msisdn, brand: 'ExampleApp'}
params = {number: msisdn, payee: 'ExampleApp', amount: 48.00}

stub_request(:post, uri).with(headers: headers, body: params.merge(api_key_and_secret)).to_return(error_response_blacklist_with_network)

error = assert_raises Vonage::ServiceError do
verify.request(params)
verify.psd2(params)
end

assert_kind_of Vonage::Error, error
assert_kind_of Vonage::Response, error.response
end

def test_blacklist_error_with_request_id
uri = 'https://api.nexmo.com/verify/json'
def test_blacklist_error_for_psd2_with_request_id
uri = 'https://api.nexmo.com/verify/psd2/json'

params = {number: msisdn, brand: 'ExampleApp'}
params = {number: msisdn, payee: 'ExampleApp', amount: 48.00}

stub_request(:post, uri).with(headers: headers, body: params.merge(api_key_and_secret)).to_return(error_response_blacklist_with_request_id)

error = assert_raises Vonage::ServiceError do
verify.request(params)
verify.psd2(params)
end

assert_kind_of Vonage::Error, error
assert_kind_of Vonage::Response, error.response
end

def test_blacklist_error_with_network_and_request_id
uri = 'https://api.nexmo.com/verify/json'
def test_blacklist_error_for_psd2_with_network_and_request_id
uri = 'https://api.nexmo.com/verify/psd2/json'

params = {number: msisdn, brand: 'ExampleApp'}
params = {number: msisdn, payee: 'ExampleApp', amount: 48.00}

stub_request(:post, uri).with(headers: headers, body: params.merge(api_key_and_secret)).to_return(error_response_blacklist_with_network_and_request_id)

error = assert_raises Vonage::ServiceError do
verify.request(params)
verify.psd2(params)
end

assert_kind_of Vonage::Error, error
Expand Down