Sha256: 7c59dede29c604f2e67f90ed0c84de9ad6b09e875c1c016deaf0f413c1547e9e

Contents?: true

Size: 1.7 KB

Versions: 76

Compression:

Stored size: 1.7 KB

Contents

require 'spec_helper'

require 'puppet/node/environment'
require 'puppet/network/http'
require 'matchers/json'

describe Puppet::Network::HTTP::API::Master::V3::Environments do
  include JSONMatchers

  let(:environment) { Puppet::Node::Environment.create(:production, ["/first", "/second"], '/manifests') }
  let(:loader) { Puppet::Environments::Static.new(environment) }
  let(:handler) { Puppet::Network::HTTP::API::Master::V3::Environments.new(loader) }
  let(:request) { Puppet::Network::HTTP::Request.from_hash(:headers => { 'accept' => 'application/json' }) }
  let(:response) { Puppet::Network::HTTP::MemoryResponse.new }

  it "responds with all of the available environments" do
    handler.call(request, response)

    expect(response.code).to eq(200)
    expect(response.type).to eq("application/json")
    expect(JSON.parse(response.body)).to eq({
      "search_paths" => loader.search_paths,
      "environments" => {
        "production" => {
          "settings" => {
            "modulepath" => [File.expand_path("/first"), File.expand_path("/second")],
            "manifest" => File.expand_path("/manifests"),
            "environment_timeout" => 0,
            "config_version" => ""
          }
        }
      }
    })
  end

  it "the response conforms to the environments schema for unlimited timeout" do
    Puppet[:environment_timeout] = 'unlimited'

    handler.call(request, response)

    expect(response.body).to validate_against('api/schemas/environments.json')
  end

  it "the response conforms to the environments schema for integer timeout" do
    Puppet[:environment_timeout] = 1

    handler.call(request, response)

    expect(response.body).to validate_against('api/schemas/environments.json')
  end
end

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
puppet-6.29.0 spec/unit/network/http/api/master/v3/environments_spec.rb
puppet-6.29.0-x86-mingw32 spec/unit/network/http/api/master/v3/environments_spec.rb
puppet-6.29.0-x64-mingw32 spec/unit/network/http/api/master/v3/environments_spec.rb
puppet-6.29.0-universal-darwin spec/unit/network/http/api/master/v3/environments_spec.rb
puppet-6.28.0 spec/unit/network/http/api/master/v3/environments_spec.rb
puppet-6.28.0-x86-mingw32 spec/unit/network/http/api/master/v3/environments_spec.rb
puppet-6.28.0-x64-mingw32 spec/unit/network/http/api/master/v3/environments_spec.rb
puppet-6.28.0-universal-darwin spec/unit/network/http/api/master/v3/environments_spec.rb
puppet-6.27.0 spec/unit/network/http/api/master/v3/environments_spec.rb
puppet-6.27.0-x86-mingw32 spec/unit/network/http/api/master/v3/environments_spec.rb
puppet-6.27.0-x64-mingw32 spec/unit/network/http/api/master/v3/environments_spec.rb
puppet-6.27.0-universal-darwin spec/unit/network/http/api/master/v3/environments_spec.rb
puppet-6.26.0 spec/unit/network/http/api/master/v3/environments_spec.rb
puppet-6.26.0-x86-mingw32 spec/unit/network/http/api/master/v3/environments_spec.rb
puppet-6.26.0-x64-mingw32 spec/unit/network/http/api/master/v3/environments_spec.rb
puppet-6.26.0-universal-darwin spec/unit/network/http/api/master/v3/environments_spec.rb
puppet-6.25.1 spec/unit/network/http/api/master/v3/environments_spec.rb
puppet-6.25.1-x86-mingw32 spec/unit/network/http/api/master/v3/environments_spec.rb
puppet-6.25.1-x64-mingw32 spec/unit/network/http/api/master/v3/environments_spec.rb
puppet-6.25.1-universal-darwin spec/unit/network/http/api/master/v3/environments_spec.rb