Sha256: 00f9e6f2f1c5b1beae5f9a58ba3047b251d4122af2543a07592b67c1c32c55ae

Contents?: true

Size: 923 Bytes

Versions: 22

Compression:

Stored size: 923 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'

describe LHC::Auth do
  before(:each) do
    LHC.config.interceptors = [LHC::Auth]
  end

  it 'adds body authentication to the existing request body' do
    stub_request(:post, "http://local.ch/")
      .with(body: {
        message: 'body',
        userToken: 'dheur5hrk3'
      }.to_json)

    LHC.post('http://local.ch', auth: { body: { userToken: 'dheur5hrk3' } }, body: {
               message: 'body'
             })
  end

  it 'adds body authentication to an empty request body' do
    stub_request(:post, "http://local.ch/")
      .with(body: {
        userToken: 'dheur5hrk3'
      }.to_json)

    LHC.post('http://local.ch', auth: { body: { userToken: 'dheur5hrk3' } })
  end

  it 'adds nothing if request method is GET' do
    stub_request(:get, "http://local.ch/")

    LHC.get('http://local.ch', auth: { body: { userToken: 'dheur5hrk3' } })
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
lhc-15.2.1 spec/interceptors/auth/body_spec.rb
lhc-15.2.0 spec/interceptors/auth/body_spec.rb
lhc-15.1.3 spec/interceptors/auth/body_spec.rb
lhc-15.1.2 spec/interceptors/auth/body_spec.rb
lhc-15.1.1 spec/interceptors/auth/body_spec.rb
lhc-15.1.0 spec/interceptors/auth/body_spec.rb
lhc-16.0.0.pre.pro2162.2 spec/interceptors/auth/body_spec.rb
lhc-16.0.0.pre.pro2162 spec/interceptors/auth/body_spec.rb
lhc-15.0.1 spec/interceptors/auth/body_spec.rb
lhc-15.0.0 spec/interceptors/auth/body_spec.rb
lhc-14.0.0 spec/interceptors/auth/body_spec.rb
lhc-13.4.0.pre.pro1766.1 spec/interceptors/auth/body_spec.rb
lhc-13.2.0 spec/interceptors/auth/body_spec.rb
lhc-13.1.0 spec/interceptors/auth/body_spec.rb
lhc-13.0.0 spec/interceptors/auth/body_spec.rb
lhc-12.3.0 spec/interceptors/auth/body_spec.rb
lhc-12.2.1 spec/interceptors/auth/body_spec.rb
lhc-12.2.0 spec/interceptors/auth/body_spec.rb
lhc-12.1.3 spec/interceptors/auth/body_spec.rb
lhc-12.1.2 spec/interceptors/auth/body_spec.rb