Sha256: 3c066831ac7df62227affcc748c1a68e38f38a96ae5ee7bcef789f26820b075b

Contents?: true

Size: 1.2 KB

Versions: 3

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

require 'test_helper'

#  was the web request successful?
#  was the user redirected to the right page?
#  was the user successfully authenticated?
#  was the correct object stored in the response?
#  was the appropriate message delivered in the json payload?

class Overrides::RefreshTokenControllerTest < ActionDispatch::IntegrationTest
  include OverridesControllersRoutes

  describe Overrides::RefreshTokenController do
    before do
      DeviseJwtAuth.default_refresh_token_path = '/evil_user_auth/refresh_token'

      @resource = create(:user, :confirmed)
      @auth_headers = get_cookie_header(DeviseJwtAuth.refresh_token_name,
                                        @resource.create_refresh_token)

      get DeviseJwtAuth.default_refresh_token_path, params: {}, headers: @auth_headers

      @resp = JSON.parse(response.body)
    end

    teardown do
      DeviseJwtAuth.default_refresh_token_path = '/auth/refresh_token'
    end

    test 'response valid' do
      assert_equal 200, response.status
    end

    test 'controller was overridden' do
      assert_equal Overrides::RefreshTokenController::OVERRIDE_PROOF,
                   @resp['override_proof']
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
devise_jwt_auth-0.4.1 test/controllers/overrides/refresh_token_controller_test.rb
devise_jwt_auth-0.4.0 test/controllers/overrides/refresh_token_controller_test.rb
devise_jwt_auth-0.3.0 test/controllers/overrides/refresh_token_controller_test.rb