Skip to content

Commit

Permalink
Change to remove API exception messages
Browse files Browse the repository at this point in the history
  • Loading branch information
okcomputer93 committed Aug 11, 2022
1 parent 89c4a4c commit 4652755
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/easy_broker/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ module EasyBroker
DEFAULT_API_ROOT_URL = 'https://api.easybroker.com/v1'
STAGING_API_ROOT_URL = 'https://api.stagingeb.com/v1'
AUTHORIZATION_HEADER = 'X-Authorization'
COUNTRY_CODE_HEADER = 'Country-Code'
COUNTRY_CODE_HEADER = 'Country-Code'
end
2 changes: 1 addition & 1 deletion lib/easy_broker/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def initialize(message, response)

class AuthenticationError < Error
def initialize(response)
super(response["error"], response)
super('Invalid API Key or missing configurations', response)
end
end
end
22 changes: 4 additions & 18 deletions test/api_client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,18 @@ def test_country_code_header
end

def test_get_without_country_code_header
invalid_country_error = 'You need to provide a valid country code in which your integration works'
exception = assert_raises EasyBroker::AuthenticationError do
stub_verb_request(:get, 'test').to_return(
status: 401,
body: {
error: invalid_country_error
}.to_json
)
assert_raises EasyBroker::AuthenticationError do
stub_verb_request(:get, 'test').to_return(status: 401)
client.get('test')
end
assert_equal invalid_country_error, exception.message
end

def test_get_without_invalid_api_key
@client = EasyBroker::ApiClient.new
invalid_api_key_error = 'Your API key is invalid.'
exception = assert_raises EasyBroker::AuthenticationError do
stub_verb_request(:get, 'test').to_return(
status: 401,
body: {
error: invalid_api_key_error
}.to_json
)
assert_raises EasyBroker::AuthenticationError do
stub_verb_request(:get, 'test').to_return(status: 401)
client.get('test')
end
assert_equal invalid_api_key_error, exception.message
end

def test_logger
Expand Down

0 comments on commit 4652755

Please sign in to comment.