Sha256: afbeb97fff4a31289e192fdc40fecfe14dc78335e9ef6baed0885d4e365e3df9

Contents?: true

Size: 1.59 KB

Versions: 3

Compression:

Stored size: 1.59 KB

Contents

require './test/test_base.rb'

class RingCentralSdkTest < Test::Unit::TestCase
  def setup
    @rcsdk = RingCentralSdk.new(
      'my_app_key',
      'my_app_secret',
      RingCentralSdk::RC_SERVER_SANDBOX
    )
  end

  def test_main
    assert_equal 'RingCentralSdk::REST::Client', @rcsdk.class.name

    assert_raise do
      @rcsdk.request(nil)
    end

    rcsdk = RingCentralSdk.new(
      'my_app_key',
      'my_app_secret',
      RingCentralSdk::RC_SERVER_SANDBOX
    )
    assert_equal 'RingCentralSdk::REST::Client', rcsdk.class.name
  end

  def test_login
    stub_token_hash = data_auth_token
    stub_token = OAuth2::AccessToken::from_hash(@rcsdk.oauth2client, stub_token_hash)

    OAuth2::Strategy::Password.any_instance.stubs(:get_token).returns(stub_token)
    rcsdk = RingCentralSdk.new(
      'my_app_key',
      'my_app_secret',
      RingCentralSdk::RC_SERVER_SANDBOX,
      {:username => 'my_username', :password => 'my_password'}
    )
  end

  def data_auth_token
    json = '{
  "access_token": "my_test_access_token",
  "token_type": "bearer",
  "expires_in": 3599,
  "refresh_token": "my_test_refresh_token",
  "refresh_token_expires_in": 604799,
  "scope": "ReadCallLog DirectRingOut EditCallLog ReadAccounts Contacts EditExtensions ReadContacts SMS EditPresence RingOut EditCustomData ReadPresence EditPaymentInfo Interoperability Accounts NumberLookup InternalMessages ReadCallRecording EditAccounts Faxes EditReportingSettings ReadClientInfo EditMessages VoipCalling ReadMessages",
  "owner_id": "1234567890"
      }'
    data = JSON.parse(json, :symbolize_names=>true)
    return data
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ringcentral_sdk-1.1.1 test/test_setup.rb
ringcentral_sdk-1.1.0 test/test_setup.rb
ringcentral_sdk-1.0.0 test/test_setup.rb