Sha256: f7b57b24f61ac84888cb3cf97f388fb5ab616ffab9f4e53d709e56c0118d40d0

Contents?: true

Size: 1.7 KB

Versions: 124

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::Server::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::Server::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

124 entries across 124 versions & 1 rubygems

Version Path
puppet-8.3.0 spec/unit/network/http/api/server/v3/environments_spec.rb
puppet-8.3.0-x86-mingw32 spec/unit/network/http/api/server/v3/environments_spec.rb
puppet-8.3.0-x64-mingw32 spec/unit/network/http/api/server/v3/environments_spec.rb
puppet-8.3.0-universal-darwin spec/unit/network/http/api/server/v3/environments_spec.rb
puppet-8.4.0 spec/unit/network/http/api/server/v3/environments_spec.rb
puppet-8.4.0-x86-mingw32 spec/unit/network/http/api/server/v3/environments_spec.rb
puppet-8.4.0-x64-mingw32 spec/unit/network/http/api/server/v3/environments_spec.rb
puppet-8.4.0-universal-darwin spec/unit/network/http/api/server/v3/environments_spec.rb
puppet-7.28.0 spec/unit/network/http/api/server/v3/environments_spec.rb
puppet-7.28.0-x86-mingw32 spec/unit/network/http/api/server/v3/environments_spec.rb
puppet-7.28.0-x64-mingw32 spec/unit/network/http/api/server/v3/environments_spec.rb
puppet-7.28.0-universal-darwin spec/unit/network/http/api/server/v3/environments_spec.rb
puppet-8.3.1 spec/unit/network/http/api/server/v3/environments_spec.rb
puppet-8.3.1-x86-mingw32 spec/unit/network/http/api/server/v3/environments_spec.rb
puppet-8.3.1-x64-mingw32 spec/unit/network/http/api/server/v3/environments_spec.rb
puppet-8.3.1-universal-darwin spec/unit/network/http/api/server/v3/environments_spec.rb
puppet-7.27.0 spec/unit/network/http/api/server/v3/environments_spec.rb
puppet-7.27.0-x86-mingw32 spec/unit/network/http/api/server/v3/environments_spec.rb
puppet-7.27.0-x64-mingw32 spec/unit/network/http/api/server/v3/environments_spec.rb
puppet-7.27.0-universal-darwin spec/unit/network/http/api/server/v3/environments_spec.rb