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 Verify tests for Blacklist error response #241

Merged
merged 2 commits into from
Aug 25, 2022
Merged
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
66 changes: 66 additions & 0 deletions test/vonage/verify_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,27 @@ def error_response
}
end

def error_response_blacklist_with_network
{
headers: response_headers,
body: '{"status":"7","error_text":"The number you are trying to verify is blacklisted for verification","network":"25503"}'
}
end

def error_response_blacklist_with_request_id
{
headers: response_headers,
body: '{"request_id":"8g88g88eg8g8gg9g90","status":"7","error_text":"The number you are trying to verify is blacklisted for verification"}'
}
end

def error_response_blacklist_with_network_and_request_id
{
headers: response_headers,
body: '{"request_id":"8g88g88eg8g8gg9g90","status":"7","error_text":"The number you are trying to verify is blacklisted for verification","network":"25503"}'
}
end

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

Expand Down Expand Up @@ -142,4 +163,49 @@ def test_psd2_method
assert_kind_of Vonage::Error, error
assert_kind_of Vonage::Response, error.response
end

def test_blacklist_error_with_network
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_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_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
end