Sha256: 1735054d94dc435bcf2ebc28da55ea327dbc44dc568c31f02f95866387181236

Contents?: true

Size: 1.66 KB

Versions: 66

Compression:

Stored size: 1.66 KB

Contents

require_relative 'test_helper'

# Internal: The test for Plaid::Auth.
class PlaidAuthTest < PlaidTest
  def setup
    create_item initial_products: [:auth]
  end

  def test_get
    auth_get_request = Plaid::AuthGetRequest.new
    auth_get_request.access_token = access_token

    response = client.auth_get(auth_get_request)
    assert_kind_of(Plaid::AuthGetResponse, response)

    refute_empty(response.accounts)
    refute_nil(response.numbers)
    assert_kind_of(Plaid::AuthGetNumbers, response.numbers)

    account_id = response.accounts[0].account_id
    auth_get_request = Plaid::AuthGetRequest.new

    options_payload = {}
    options_payload[:account_ids] = [account_id]

    auth_get_request.access_token = access_token
    auth_get_request.options = options_payload

    response = client.auth_get(auth_get_request)
    assert_equal 1, response.numbers.ach.size
  end

  def test_get_invalid_access_token
    auth_get_request = Plaid::AuthGetRequest.new
    auth_get_request.access_token = BAD_STRING

    begin
      client.auth_get(auth_get_request)
    rescue Plaid::ApiError => e
      json_response = JSON.parse(e.response_body)
      assert_equal(json_response["error_code"], "INVALID_ACCESS_TOKEN")
    end
  end

  def test_get_invalid_options
    auth_get_request = Plaid::AuthGetRequest.new

    options_payload = {}
    options_payload[:account_ids] = [BAD_STRING]

    auth_get_request.access_token = access_token
    auth_get_request.options = options_payload

    begin
      client.auth_get(auth_get_request)
    rescue Plaid::ApiError => e
      json_response = JSON.parse(e.response_body)
      assert_equal(json_response["error_code"], "INVALID_FIELD")
    end
  end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
plaid-14.0.0 test/test_auth.rb
plaid-14.0.0.beta.5 test/test_auth.rb
plaid-14.0.0.beta.4 test/test_auth.rb
plaid-14.0.0.beta.3 test/test_auth.rb
plaid-14.0.0.beta.2 test/test_auth.rb
plaid-14.0.0.beta.1 test/test_auth.rb