summaryrefslogtreecommitdiff
path: root/test/functional/api/identities_controller_test.rb
blob: bb5608e61aef03c3576d3291a973b5dc2c4c28a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require_relative '../../test_helper'

class Api::IdentitiesControllerTest < ApiControllerTest

  test "api monitor can fetch identity" do
    monitor_auth do
      identity = create_identity
      api_get :show, :id => identity.address, :format => 'json'
      assert_response :success
      assert_equal identity, assigns(:identity)

      api_get :show, :id => "blahblahblah", :format => 'json'
      assert_response :not_found
    end
  end


  test "anonymous cannot fetch identity" do
    identity = create_identity
    api_get :show, :id => identity.address, :format => 'json'
    assert_response :forbidden
  end

  def create_identity
    FactoryBot.create :identity
  end
end