Sha256: 19729a5eeeedb6206b9f9d4bc199860c60a6f05d35d30b0fbb4d1db1d81cf918

Contents?: true

Size: 1.16 KB

Versions: 42

Compression:

Stored size: 1.16 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, 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, 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, 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

42 entries across 42 versions & 1 rubygems

Version Path
disco_app-0.12.7.pre.puma.pre.3 test/controllers/proxy_controller_test.rb
disco_app-0.13.6.pre.puma.pre.3 test/controllers/proxy_controller_test.rb