Sha256: d9e15b012adf812dfbd9d649c5a1150d69df08317c55cd587f365205587df4fa

Contents?: true

Size: 1.18 KB

Versions: 17

Compression:

Stored size: 1.18 KB

Contents

require 'test_helper'

class ProxyControllerTest < ActionController::TestCase

  def setup
    @shop = disco_app_shops(:widget_store)
    @secret = ShopifyApp.configuration.secret
  end

  def teardown
    @shop = nil
    @secret = nil
  end

  test 'app proxy request without authentication information returns unauthorized' do
    get(:index)
    assert_response :unauthorized
  end

  test 'app proxy request with incorrect authentication information returns unauthorized' do
    get :index, params: proxy_params(shop: @shop.shopify_domain).merge(signature: 'invalid_signature')
    assert_response :unauthorized
  end

  test 'app proxy request with correct authentication information returns ok and has shop context' do
    get :index, params: proxy_params(shop: @shop.shopify_domain)
    assert_response :ok
    assert_equal @shop, assigns(:shop)
  end

  test 'app proxy request with correct authentication information but unknown shop returns 404' do
    get :index, params: proxy_params(shop: 'unknown.myshopify.com')
    assert_response :not_found
  end

  private

    def proxy_params(**params)
      params.merge(signature: DiscoApp::ProxyService.calculated_signature(params, @secret))
    end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
disco_app-0.16.1.pre.sidekiq.pre.6.pre.release test/controllers/proxy_controller_test.rb
disco_app-0.14.1 test/controllers/proxy_controller_test.rb
disco_app-0.14.2 test/controllers/proxy_controller_test.rb
disco_app-0.15.0 test/controllers/proxy_controller_test.rb
disco_app-0.16.0 test/controllers/proxy_controller_test.rb
disco_app-0.17.0 test/controllers/proxy_controller_test.rb
disco_app-0.18.0 test/controllers/proxy_controller_test.rb
disco_app-0.18.2 test/controllers/proxy_controller_test.rb
disco_app-0.14.4 test/controllers/proxy_controller_test.rb
disco_app-0.18.3 test/controllers/proxy_controller_test.rb
disco_app-0.18.6 test/controllers/proxy_controller_test.rb
disco_app-0.14.3 test/controllers/proxy_controller_test.rb
disco_app-0.16.1 test/controllers/proxy_controller_test.rb
disco_app-0.15.2 test/controllers/proxy_controller_test.rb
disco_app-0.18.4 test/controllers/proxy_controller_test.rb
disco_app-0.18.1 test/controllers/proxy_controller_test.rb
disco_app-0.14.0 test/controllers/proxy_controller_test.rb