require 'spec_helper'

describe 'openconnect' do
  context 'supported operating systems' do
    ['Debian'].each do |osfamily|
      describe "openconnect class without any parameters on #{osfamily}" do
        let(:params) {{ }}
        let(:facts) {{
          :osfamily => osfamily,
        }}

        it { should include_class('openconnect::params') }

        it { should contain_class('openconnect::install') }
        it { should contain_class('openconnect::config') }
        it { should contain_class('openconnect::service') }
      end
    end
  end

  context 'unsupported operating system' do
    describe 'openconnect class without any parameters on CentOS/RedHat' do
      let(:facts) {{
        :osfamily        => 'RedHat',
        :operatingsystem => 'CentOS',
      }}

      it { expect { should }.to raise_error(Puppet::Error, /CentOS not supported/) }
    end
  end
end

require 'spec_helper'

describe 'openconnect' do
  context 'supported operating systems' do
    ['Debian'].each do |osfamily|
      describe "openconnect class without any parameters on #{osfamily}" do
        let(:params) {{ }}
        let(:facts) {{
          :osfamily => osfamily,
        }}

        it { should include_class('openconnect::params') }

        it { should contain_class('openconnect::install') }
        it { should contain_class('openconnect::config') }
        it { should contain_class('openconnect::service') }

        # FIXME
        it 'should not allow required params to be bypassed' do
          expect { should }.to raise_error(Puppet::Error, /Must pass/)
        end
      end
    end
  end

  context 'unsupported operating system' do
    describe 'openconnect class without any parameters on CentOS/RedHat' do
      let(:facts) {{
        :osfamily        => 'RedHat',
        :operatingsystem => 'CentOS',
      }}

      it { expect { should }.to raise_error(Puppet::Error, /CentOS not supported/) }
    end
  end
end

Add a failing test for undef params
Add a failing test for undef params

I've been using this pattern whereby the parent class proxies params to the
relevant sub-classes to provide a single entry point, whilst keeping the
defaults and validation as close to the classes that use them.

However this brings up an issue with Puppet 3.x whereby the `undef` defaults
in the parent class appear to be cast as empty strings. Meaning that
`include openconnect` doesn't raise a warning and the templates get rendered
with empty strings.

Adding this test here as a reminded, until we figure out the desired
solution.
