fervidus / secure_linux_cis

Apache License 2.0
16 stars 33 forks source link

Custom postfix module in spec tests - why? #80

Open canihavethisone opened 3 years ago

canihavethisone commented 3 years ago

I am trying to understand why spec/unit tests fail with the camptocamp-postfix module that is specified in metadata, and instead use a puppet-postfix module served in fixtures from a github repo?

This restricts unit tests to require internet connectivity to resolve the postfix module from "https://github.com/fervidus/puppet-postfix.git". However, acceptance tests and real-world use of the module work with the camptocamp-postfix specified in metadata.

Any clarification of why this is so and if it can be fixed is appreciated.

bryanjbelanger commented 3 years ago

I didn't even realize this was occurring. If camp to camp works let's use it.

canihavethisone commented 3 years ago

I got spec tests to work using camptocamp-postfix (as per the metadata, ie the actual module used) but need to stub additional os facts. I don't have that info handy but will post it here when I find it.

canihavethisone commented 3 years ago

Found it. The camptocamp-postfix module requires the os[family] fact to be resolvable, so in my wrapping module's spec/unit test I provide the following facts hash (as an example):

    let(:facts) do
      facts.merge(
        operatingsystem: 'CentOS',
        os: {
          family: 'RedHat',
          name: 'CentOS',
          architecture: 'amd64',
          release: {
            major: '8',
          },
        },
        mountpoints: {
          '/': {
            filesystem: 'xfs',
            device: '/dev/root',
          },
        },
      )
    end

I guess this could be added to secure_linux_cis/spec/default_module_facts.yml, however it should probably be added to the facts hash for each OS. Grepping the camptocamp-postfix module for 'master_os_template' (the cause of the error thrown when using it for spec tests in fixtures) reports the following finds:

data/os/Alpine.yaml:postfix::params::master_os_template: "postfix/master.cf.debian.erb" data/os/Solaris.yaml:postfix::params::master_os_template: "postfix/master.cf.Solaris.erb" data/osfamily/Suse.yaml:postfix::params::master_os_template: "postfix/master.cf.sles.erb" data/osfamily/RedHat.yaml:postfix::params::master_os_template: 'postfix/master.cf.redhat.erb' data/osfamily/Debian.yaml:postfix::params::master_os_template: 'postfix/master.cf.debian.erb' data/osfamily/Suse/11.yaml:postfix::params::master_os_template: "postfix/master.cf.SLES%{::operatingsystemrelease}.erb" manifests/params.pp:# [master_os_template] - (string) Path to the master template manifests/params.pp: String $master_os_template, manifests/files.pp: $postfix::params::master_os_template,