test/remote_test.rb in 3scale_client-2.2.7 vs test/remote_test.rb in 3scale_client-2.2.8
- old
+ new
@@ -1,9 +1,9 @@
require 'test/unit'
require '3scale/client'
-if ENV['TEST_3SCALE_PROVIDER_KEY'] &&
+if ENV['TEST_3SCALE_PROVIDER_KEY'] &&
ENV['TEST_3SCALE_APP_IDS'] &&
ENV['TEST_3SCALE_APP_KEYS']
class ThreeScale::RemoteTest < Test::Unit::TestCase
def setup
@provider_key = ENV['TEST_3SCALE_PROVIDER_KEY']
@@ -22,15 +22,30 @@
end
def test_successful_authorize
@app_keys.each do |app_key|
response = @client.authorize(:app_id => @app_ids[0], :app_key => app_key)
- assert response.success?, "Authorize should succeed for app_id=#{@app_ids[0]} and app_key=#{app_key}, but it didn't"
+ assert response.success?, "Authorize should succeed for app_id=#{@app_ids[0]} and app_key=#{app_key}, but it failed with: '#{response.error_message}'"
end
end
def test_failed_authorize
response = @client.authorize(:app_id => 'invalid-id')
+ assert !response.success?
+ assert_equal 'application_not_found', response.error_code
+ assert_equal 'application with id="invalid-id" was not found', response.error_message
+ end
+
+ def test_successful_oauth_authorize
+ @app_keys.each do |app_key|
+ response = @client.oauth_authorize(:app_id => @app_ids[0])
+ assert response.success?, "Authorize should succeed for app_id=#{@app_ids[0]} and app_key=#{app_key}, but it failed with: '#{response.error_message}'"
+ assert_equal app_key, response.app_key
+ end
+ end
+
+ def test_failed_oauth_authorize
+ response = @client.oauth_authorize(:app_id => 'invalid-id')
assert !response.success?
assert_equal 'application_not_found', response.error_code
assert_equal 'application with id="invalid-id" was not found', response.error_message
end