Sha256: aa3048d57afad3bac7ce1bfdf034176f1d122bf0be0bbd0bf780ab2f5c2cd66f

Contents?: true

Size: 1.82 KB

Versions: 9

Compression:

Stored size: 1.82 KB

Contents

require_relative '../test_helper'

describe Fastly::Syslog do

  let(:client)     { Fastly.new(user: 'test@example.com', password: 'password') }
  let(:service_id) { SecureRandom.hex(6) }
  let(:version)    { 1 }
  let(:syslog) { Fastly::Syslog.new({ name: 'test_syslog', service_id: service_id, version: 1 }, client) }

  before {
    stub_request(:post, "#{Fastly::Client::DEFAULT_URL}/login").to_return(body: '{}', status: 200, headers: { 'Set-Cookie' => 'tasty!' })
  }

  describe '#item' do
    it 'translates response_condition attribute properly' do
      response_condition = 'never_syslog'

      response_body = JSON.dump(
        'placement' => nil,
        'format_version' => '2',
        'hostname' => nil,
        'response_condition' => response_condition,
        'address' => '10.2.2.2',
        'public_key' => nil,
        'updated_at' => '2017-12-13T16:28:09Z',
        'message_type' => 'classic',
        'ipv4' => '10.2.2.2',
        'tls_hostname' => nil,
        'name' => syslog.name,
        'port' => '514',
        'use_tls' => '0',
        'service_id' => service_id,
        'tls_ca_cert' => nil,
        'token' => nil,
        'version' => version,
        'deleted_at' => nil,
        'created_at' => '2017-12-12T21:44:45Z',
        'format' => '%h %l %u %t \'%r\' %>s %b',
      )

      get_item_url = "#{Fastly::Client::DEFAULT_URL}/service/#{service_id}/version/#{version}/logging/syslog/#{syslog.name}"
      get_service_url = "#{Fastly::Client::DEFAULT_URL}/service/#{service_id}/version/#{version}"

      stub_request(:get, get_service_url).to_return(status: 200, body: '{}', headers: {})
      stub_request(:get, get_item_url).to_return(body: response_body, status: 200)

      item = client.get_syslog(service_id, version, syslog.name)
      assert_equal response_condition, item.response_condition
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
fastly-2.5.3 test/fastly/syslog_test.rb
fastly-2.5.2 test/fastly/syslog_test.rb
fastly-2.5.1 test/fastly/syslog_test.rb
fastly-2.5.0 test/fastly/syslog_test.rb
fastly-2.4.0 test/fastly/syslog_test.rb
fastly-2.3.1 test/fastly/syslog_test.rb
fastly-2.3.0 test/fastly/syslog_test.rb
fastly-2.2.0 test/fastly/syslog_test.rb
fastly-2.1.0 test/fastly/syslog_test.rb