File: puppetserver_spec.rb

package info (click to toggle)
ruby-puppetserver-ca-cli 2.7.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 696 kB
  • sloc: ruby: 6,970; sh: 4; makefile: 3
file content (43 lines) | stat: -rw-r--r-- 1,386 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
require 'spec_helper'
require 'puppetserver/ca/config/puppetserver'

RSpec.describe 'Puppetserver::Ca::Config::PuppetServer' do
  it 'overrides defaults with settings from the config file' do
    Dir.mktmpdir do |tmpdir|
      puppetserver_conf = File.join(tmpdir, 'ca.conf')
      File.open(puppetserver_conf, 'w') do |f|
      f.puts(<<-CONF)
      certificate-authority : {
          cadir: "/etc/fake/path/ca"
          cert-inventory: "/etc/fake/inventory.txt"
      }
      CONF
      end

      conf = Puppetserver::Ca::Config::PuppetServer.new(puppetserver_conf)
      conf.load
      expect(conf.settings[:cadir]).to eq('/etc/fake/path/ca')
      expect(conf.settings[:cacert]).to eq('/etc/fake/path/ca/ca_crt.pem')
      expect(conf.settings[:cert_inventory]).to eq('/etc/fake/inventory.txt')
    end
  end

  it 'logs errors that occur during HOCON parsing' do
    Dir.mktmpdir do |tmpdir|
      puppetserver_conf = File.join(tmpdir, 'ca.conf')
      File.open(puppetserver_conf, 'w') do |f|
      f.puts(<<-CONF)
      certificate-authority :
          cadir: "/etc/fake/path/ca"
          cert-inventory: "/etc/fake/inventory.txt"
      }
      CONF
      end

      conf = Puppetserver::Ca::Config::PuppetServer.new(puppetserver_conf)
      conf.load
      expect(conf.errors.size).to eq(1)
      expect(conf.errors[0]).to match(/Expecting close brace/)
    end
  end
end