<commit_before>require 'spec_helper'

describe 'rundeck' do
  let(:facts) do
    {
      :osfamily        => 'Debian',
      :fqdn            => 'test.domain.com',
      :serialnumber    => 0,
      :rundeck_version => '',
      :puppetversion   => Puppet.version
    }
  end
  describe 'add file-based key storage' do
    let(:params) do
      {
        :file_keystorage_dir  => '/var/lib/rundeck/var/storage',
        :file_keystorage_keys => {
          'password_key' => {
            'value'        => 'gob<PASSWORD>',
            'path'         => 'foo/bar',
            'data_type'    => 'password',
            'content_type' => 'application/x-rundeck-data-password'
          },
          'public_key' => {
            'value'        => 'ssh-rsa AAAAB3rhwL1EoAIuI3hw9wZL146zjPZ6FIqgZKvO24fpZENYnNfmHn5AuOGBXYGTjeVPMzwV7o0mt3iRWk8J9Ujqvzp45IHfEAE7SO2frEIbfALdcwcNggSReQa0du4nd user@localhost',
            'path'         => 'foo/bar',
            'data_type'    => 'public',
            'content_type' => 'application/pgp-keys'
          }
        }
      }
    end

    # content and meta data for passwords
    it { should contain_file('/var/lib/rundeck/var/storage/content/keys/foo/bar/password_key.password') }
    it 'should generate valid *content* for password_key' do
      content = catalogue.resource('file', '/var/lib/rundeck/var/storage/content/keys/foo/bar/password_key.password')[:content]
      expect(content).to include('gobbledygook')
    end
    it { should contain_file('/var/lib/rundeck/var/storage/meta/keys/foo/bar/password_key.password') }
    it 'should generate valid *meta* for password_key' do
      content = catalogue.resource('file', '/var/lib/rundeck/var/storage/meta/keys/foo/bar/password_key.password')[:content]
      expect(content).to include('application/x-rundeck-data-password')
    end

    # content and meta data for public keys
    it { should contain_file('/var/lib/rundeck/var/storage/content/keys/foo/bar/public_key.public') }
    it 'should generate valid *content* for public_key' do
      content = catalogue.resource('file', '/var/lib/rundeck/var/storage/content/keys/foo/bar/public_key.public')[:content]
      expect(content).to include('ssh-rsa AAAAB3rhwL1EoAIuI3hw9wZL146zjPZ6FIqgZKvO24fpZENYnNfmHn5AuOGBXYGTjeVPMzwV7o0mt3iRWk8J9Ujqvzp45IHfEAE7SO2frEIbfALdcwcNggSReQa0du4nd user@localhost')
    end
    it { should contain_file('/var/lib/rundeck/var/storage/meta/keys/foo/bar/public_key.public') }
    it 'should generate valid *meta* for public_key' do
      content = catalogue.resource('file', '/var/lib/rundeck/var/storage/meta/keys/foo/bar/public_key.public')[:content]
      expect(content).to include('application/pgp-keys')
    end
  end
end
<commit_msg>Spec to check if exec resource type use provider shell<commit_after>require 'spec_helper'

describe 'rundeck' do
  let(:facts) do
    {
      :osfamily        => 'Debian',
      :fqdn            => 'test.domain.com',
      :serialnumber    => 0,
      :rundeck_version => '',
      :puppetversion   => Puppet.version
    }
  end
  describe 'add file-based key storage' do
    let(:params) do
      {
        :file_keystorage_dir  => '/var/lib/rundeck/var/storage',
        :file_keystorage_keys => {
          'password_key' => {
            'value'        => '<PASSWORD>',
            'path'         => 'foo/bar',
            'data_type'    => 'password',
            'content_type' => 'application/x-rundeck-data-password'
          },
          'public_key' => {
            'value'        => 'ssh-rsa AAAAB3rhwL1EoAIuI3hw9wZL146zjPZ6FIqgZKvO24fpZENYnNfmHn5AuOGBXYGTjeVPMzwV7o0mt3iRWk8J9Ujqvzp45IHfEAE7SO2frEIbfALdcwcNggSReQa0du4nd user@localhost',
            'path'         => 'foo/bar',
            'data_type'    => 'public',
            'content_type' => 'application/pgp-keys'
          }
        }
      }
    end

    # content and meta data for passwords
    it { should contain_exec('create foo/bar_password_key key path').with_provider('shell') }
    it { should contain_file('/var/lib/rundeck/var/storage/content/keys/foo/bar/password_key.password') }
    it 'should generate valid *content* for password_key' do
      content = catalogue.resource('file', '/var/lib/rundeck/var/storage/content/keys/foo/bar/password_key.password')[:content]
      expect(content).to include('<PASSWORD>')
    end
    it { should contain_exec('create foo/bar_password_key key path').with_provider('shell') }
    it { should contain_file('/var/lib/rundeck/var/storage/meta/keys/foo/bar/password_key.password') }
    it 'should generate valid *meta* for password_key' do
      content = catalogue.resource('file', '/var/lib/rundeck/var/storage/meta/keys/foo/bar/password_key.password')[:content]
      expect(content).to include('application/x-rundeck-data-password')
    end

    # content and meta data for public keys
    it { should contain_exec('create foo/bar_public_key key path').with_provider('shell') }
    it { should contain_file('/var/lib/rundeck/var/storage/content/keys/foo/bar/public_key.public') }
    it 'should generate valid *content* for public_key' do
      content = catalogue.resource('file', '/var/lib/rundeck/var/storage/content/keys/foo/bar/public_key.public')[:content]
      expect(content).to include('ssh-rsa AAAAB3rhwL1EoAIuI3hw9wZL146zjPZ6FIqgZKvO24fpZENYnNfmHn5AuOGBXYGTjeVPMzwV7o0mt3iRWk8J9Ujqvzp45IHfEAE7SO2frEIbfALdcwcNggSReQa0du4nd user@localhost')
    end
    it { should contain_exec('create foo/bar_public_key key path').with_provider('shell') }
    it { should contain_file('/var/lib/rundeck/var/storage/meta/keys/foo/bar/public_key.public') }
    it 'should generate valid *meta* for public_key' do
      content = catalogue.resource('file', '/var/lib/rundeck/var/storage/meta/keys/foo/bar/public_key.public')[:content]
      expect(content).to include('application/pgp-keys')
    end
  end
end

{'fraction_non_alphanumeric': 0.1304199385455787, 'fraction_numerical': 0.015363605326049846, 'mean_word_length': 3.0518672199170123, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '818758', 'n_tokens_mistral': 2101, 'n_tokens_neox': 2014, 'n_words': 301}