Sha256: 6a67d76345af562fa4752c02e1cf86701b57252307ce07cb1b866715a867f2a0

Contents?: true

Size: 678 Bytes

Versions: 15

Compression:

Stored size: 678 Bytes

Contents

module Ctws
  module ControllerSpecHelper
    # generate tokens from user id
    def token_generator(user_id)
      Ctws::JsonWebToken.encode(user_id: user_id)
    end

    # generate expired tokens from user id
    def expired_token_generator(user_id)
      Ctws::JsonWebToken.encode({ user_id: user_id }, (Time.now.to_i - 10))
    end

    # return valid headers
    def valid_headers
      {
        "Authorization" => token_generator(ctws_user.id),
        "Content-Type" => "application/json"
      }
    end

    # return invalid headers
    def invalid_headers
      {
        "Authorization" => nil,
        "Content-Type" => "application/json"
      }
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
ctws-0.3.0.beta spec/support/ctws/controller_spec_helper.rb
ctws-0.2.3.beta spec/support/ctws/controller_spec_helper.rb
ctws-0.2.2.beta spec/support/ctws/controller_spec_helper.rb
ctws-0.2.1.beta spec/support/ctws/controller_spec_helper.rb
ctws-0.2.0.beta spec/support/ctws/controller_spec_helper.rb
ctws-0.1.14.beta spec/support/ctws/controller_spec_helper.rb
ctws-0.1.13.alpha spec/support/ctws/controller_spec_helper.rb
ctws-0.1.12.alpha spec/support/ctws/controller_spec_helper.rb
ctws-0.1.11.alpha spec/support/ctws/controller_spec_helper.rb
ctws-0.1.10.alpha spec/support/ctws/controller_spec_helper.rb
ctws-0.1.9.alpha spec/support/ctws/controller_spec_helper.rb
ctws-0.1.8.alpha spec/support/ctws/controller_spec_helper.rb
ctws-0.1.7.alpha spec/support/ctws/controller_spec_helper.rb
ctws-0.1.6.alpha spec/support/ctws/controller_spec_helper.rb
ctws-0.1.5.alpha spec/support/ctws/controller_spec_helper.rb