<commit_before>require 'spec_helper'

powershell = 'powershell.exe -ExecutionPolicy RemoteSigned'

describe 'iis::manage_site', :type => :define do
  describe 'when managing the iis site using default params' do
    let(:title) { 'myWebSite' }
    let(:params) { {
        :app_pool    => 'myAppPool.example.com',
        :host_header => 'myHost.example.com',
        :site_path   => 'C:\inetpub\wwwroot\myWebSite',
    } }

    it { should include_class('iis::param::powershell') }

    it { should contain_exec('CreateSite-myWebSite').with({
      'command' => "#{powershell} -Command \"Import-Module WebAdministration; New-WebSite -Name \\\"myWebSite\\\" -Port 80 -IP * -HostHeader \\\"myHost.example.com\\\" -PhysicalPath \\\"C:\\inetpub\\wwwroot\\myWebSite\\\" -ApplicationPool \\\"myAppPool.example.com\\\"\"",
      'onlyif'  => "#{powershell} -Command \"Import-Module WebAdministration; if((Test-Path \"IIS:\\Sites\\myWebSite\")) { exit 1 } else { exit 0 }\"",
    })}
  end

  describe 'when managing the iis site passing in all parameters' do
    let(:title) { 'myWebSite' }
    let(:params) {{
        :app_pool    => 'myAppPool.example.com',
        :host_header => 'myHost.example.com',
        :site_path   => 'C:\inetpub\wwwroot\path',
        :port        => '1080',
        :ip_address  => '127.0.0.1',
        :ensure      => 'present',
    }}

    it { should include_class('iis::param::powershell') }

    it { should contain_exec('CreateSite-myWebSite').with({
      'command' => "#{powershell} -Command \"Import-Module WebAdministration; New-WebSite -Name \\\"myWebSite\\\" -Port 1080 -IP 127.0.0.1 -HostHeader \\\"myHost.example.com\\\" -PhysicalPath \\\"C:\\inetpub\\wwwroot\\path\\\" -ApplicationPool \\\"myAppPool.example.com\\\"\"",
      'onlyif'  => "#{powershell} -Command \"Import-Module WebAdministration; if((Test-Path \"IIS:\\Sites\\myWebSite\")) { exit 1 } else { exit 0 }\"",
    })}
  end

  describe 'when managing the iis site and setting ensure to present' do
    let(:title) { 'myWebSite' }
    let(:params) { {
        :app_pool    => 'myAppPool.example.com',
        :host_header => 'myHost.example.com',
        :site_path   => 'C:\inetpub\wwwroot\myWebSite',
        :ensure      => 'present',
    } }

    it { should contain_exec('CreateSite-myWebSite').with({
      'command' => "#{powershell} -Command \"Import-Module WebAdministration; New-WebSite -Name \\\"myWebSite\\\" -Port 80 -IP * -HostHeader \\\"myHost.example.com\\\" -PhysicalPath \\\"C:\\inetpub\\wwwroot\\myWebSite\\\" -ApplicationPool \\\"myAppPool.example.com\\\"\"",
      'onlyif'  => "#{powershell} -Command \"Import-Module WebAdministration; if((Test-Path \"IIS:\\Sites\\myWebSite\")) { exit 1 } else { exit 0 }\"",
    })}
  end

  describe 'when managing the iis site and setting ensure to installed' do
    let(:title) { 'myWebSite' }
    let(:params) { {
        :app_pool    => 'myAppPool.example.com',
        :host_header => 'myHost.example.com',
        :site_path   => 'C:\inetpub\wwwroot\myWebSite',
        :ensure      => 'installed',
    } }

    it { should contain_exec('CreateSite-myWebSite').with({
      'command' => "#{powershell} -Command \"Import-Module WebAdministration; New-WebSite -Name \\\"myWebSite\\\" -Port 80 -IP * -HostHeader \\\"myHost.example.com\\\" -PhysicalPath \\\"C:\\inetpub\\wwwroot\\myWebSite\\\" -ApplicationPool \\\"myAppPool.example.com\\\"\"",
      'onlyif'  => "#{powershell} -Command \"Import-Module WebAdministration; if((Test-Path \"IIS:\\Sites\\myWebSite\")) { exit 1 } else { exit 0 }\"",
    })}
  end

  describe 'when managing the iis site and setting ensure to absent' do
    let(:title) { 'myWebSite' }
    let(:params) { {
        :app_pool    => 'myAppPool.example.com',
        :host_header => 'myHost.example.com',
        :site_path   => 'C:\inetpub\wwwroot\myWebSite',<commit_msg>Fixed spec tests to include the new optional param -Ssl:<commit_after>require 'spec_helper'

powershell = 'powershell.exe -ExecutionPolicy RemoteSigned'

describe 'iis::manage_site', :type => :define do
  describe 'when managing the iis site using default params' do
    let(:title) { 'myWebSite' }
    let(:params) { {
        :app_pool    => 'myAppPool.example.com',
        :host_header => 'myHost.example.com',
        :site_path   => 'C:\inetpub\wwwroot\myWebSite',
    } }

    it { should include_class('iis::param::powershell') }

    it { should contain_exec('CreateSite-myWebSite').with({
      'command' => "#{powershell} -Command \"Import-Module WebAdministration; New-WebSite -Name \\\"myWebSite\\\" -Port 80 -IP * -HostHeader \\\"myHost.example.com\\\" -PhysicalPath \\\"C:\\inetpub\\wwwroot\\myWebSite\\\" -ApplicationPool \\\"myAppPool.example.com\\\" -Ssl:$false \"",
      'onlyif'  => "#{powershell} -Command \"Import-Module WebAdministration; if((Test-Path \"IIS:\\Sites\\myWebSite\")) { exit 1 } else { exit 0 }\"",
    })}
  end

  describe 'when managing the iis site passing in all parameters' do
    let(:title) { 'myWebSite' }
    let(:params) {{
        :app_pool    => 'myAppPool.example.com',
        :host_header => 'myHost.example.com',
        :site_path   => 'C:\inetpub\wwwroot\path',
        :port        => '1080',
        :ip_address  => '127.0.0.1',
        :ensure      => 'present',
    }}

    it { should include_class('iis::param::powershell') }

    it { should contain_exec('CreateSite-myWebSite').with({
      'command' => "#{powershell} -Command \"Import-Module WebAdministration; New-WebSite -Name \\\"myWebSite\\\" -Port 1080 -IP 127.0.0.1 -HostHeader \\\"myHost.example.com\\\" -PhysicalPath \\\"C:\\inetpub\\wwwroot\\path\\\" -ApplicationPool \\\"myAppPool.example.com\\\" -Ssl:$false \"",
      'onlyif'  => "#{powershell} -Command \"Import-Module WebAdministration; if((Test-Path \"IIS:\\Sites\\myWebSite\")) { exit 1 } else { exit 0 }\"",
    })}
  end

  describe 'when managing the iis site and setting ensure to present' do
    let(:title) { 'myWebSite' }
    let(:params) { {
        :app_pool    => 'myAppPool.example.com',
        :host_header => 'myHost.example.com',
        :site_path   => 'C:\inetpub\wwwroot\myWebSite',
        :ensure      => 'present',
    } }

    it { should contain_exec('CreateSite-myWebSite').with({
      'command' => "#{powershell} -Command \"Import-Module WebAdministration; New-WebSite -Name \\\"myWebSite\\\" -Port 80 -IP * -HostHeader \\\"myHost.example.com\\\" -PhysicalPath \\\"C:\\inetpub\\wwwroot\\myWebSite\\\" -ApplicationPool \\\"myAppPool.example.com\\\" -Ssl:$false \"",
      'onlyif'  => "#{powershell} -Command \"Import-Module WebAdministration; if((Test-Path \"IIS:\\Sites\\myWebSite\")) { exit 1 } else { exit 0 }\"",
    })}
  end

  describe 'when managing the iis site and setting ensure to installed' do
    let(:title) { 'myWebSite' }
    let(:params) { {
        :app_pool    => 'myAppPool.example.com',
        :host_header => 'myHost.example.com',
        :site_path   => 'C:\inetpub\wwwroot\myWebSite',
        :ensure      => 'installed',
    } }

    it { should contain_exec('CreateSite-myWebSite').with({
      'command' => "#{powershell} -Command \"Import-Module WebAdministration; New-WebSite -Name \\\"myWebSite\\\" -Port 80 -IP * -HostHeader \\\"myHost.example.com\\\" -PhysicalPath \\\"C:\\inetpub\\wwwroot\\myWebSite\\\" -ApplicationPool \\\"myAppPool.example.com\\\" -Ssl:$false \"",
      'onlyif'  => "#{powershell} -Command \"Import-Module WebAdministration; if((Test-Path \"IIS:\\Sites\\myWebSite\")) { exit 1 } else { exit 0 }\"",
    })}
  end

  describe 'when managing the iis site and setting ensure to absent' do
    let(:title) { 'myWebSite' }
    let(:params) { {
        :app_pool    => 'myAppPool.example.com',
        :host_header => 'myHost.example.com',
        :site_path   => 'C:\inetpub\wwwroot\myWebSite',
{'fraction_non_alphanumeric': 0.19168266154830454, 'fraction_numerical': 0.008701215611004478, 'mean_word_length': 2.8294953454189122, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 18, 'xml': 0}, 'pii_count': 4, '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': '2341792', 'n_tokens_mistral': 2727, 'n_tokens_neox': 2554, 'n_words': 536}