<commit_before>require_relative '../../../../spec_helper'

describe 'loadbalancer::balance', :type => :define do
  context 'external load balancer' do
    let(:title) { 'giraffe' }
    let(:params) {
      {
        :servers => ['giraffe-1', 'giraffe-2', 'giraffe-3'],
      }
    }

    it 'should create nginx config for loadbalancing' do
      should contain_nginx__config__site('giraffe.test.gov.uk')
        .with_content(/server giraffe-1:443.*server giraffe-2:443.*server giraffe-3:443/m)
        .with_content(/listen\s+443 ssl/)
      should_not contain_nginx__config__site('giraffe.test.gov.uk')
        .with_content(/deny all/)
        .with_content(/listen\s+80/)
    end
  end

  context 'single load balancer' do
    let(:title) { 'giraffe' }
    let(:params) {
      {
        :servers => 'giraffe-1',
      }
    }

    it 'should create nginx config for loadbalancing' do
      should contain_nginx__config__site('giraffe.test.gov.uk')
        .with_content(/server giraffe-1:443/)
    end
  end

  context 'internal load balancer' do
    let(:title) { 'giraffe' }
    let(:params) {
      {
        :internal_only => true,
        :servers => ['giraffe-1', 'giraffe-2', 'giraffe-3'],
      }
    }

    it 'should create nginx config for loadbalancing' do
      should contain_nginx__config__site('giraffe.test.gov.uk')
        .with_content(/server giraffe-1:443.*server giraffe-2:443.*server giraffe-3:443/m)
        .with_content(/listen\s+443 ssl/)
        .with_content(/deny all/)<commit_msg>[#51136581] Split negative loadbalancer tests<commit_after>require_relative '../../../../spec_helper'

describe 'loadbalancer::balance', :type => :define do
  context 'external load balancer' do
    let(:title) { 'giraffe' }
    let(:params) {
      {
        :servers => ['giraffe-1', 'giraffe-2', 'giraffe-3'],
      }
    }

    it 'should create nginx config for loadbalancing' do
      should contain_nginx__config__site('giraffe.test.gov.uk')
        .with_content(/server giraffe-1:443.*server giraffe-2:443.*server giraffe-3:443/m)
        .with_content(/listen\s+443 ssl/)
      should_not contain_nginx__config__site('giraffe.test.gov.uk').with_content(/deny all/)
      should_not contain_nginx__config__site('giraffe.test.gov.uk').with_content(/listen\s+80/)
    end
  end

  context 'single load balancer' do
    let(:title) { 'giraffe' }
    let(:params) {
      {
        :servers => 'giraffe-1',
      }
    }

    it 'should create nginx config for loadbalancing' do
      should contain_nginx__config__site('giraffe.test.gov.uk')
        .with_content(/server giraffe-1:443/)
    end
  end

  context 'internal load balancer' do
    let(:title) { 'giraffe' }
    let(:params) {
      {
        :internal_only => true,
        :servers => ['giraffe-1', 'giraffe-2', 'giraffe-3'],
      }
    }

    it 'should create nginx config for loadbalancing' do
      should contain_nginx__config__site('giraffe.test.gov.uk')
        .with_content(/server giraffe-1:443.*server giraffe-2:443.*server giraffe-3:443/m)
        .with_content(/listen\s+443 ssl/)
        .with_content(/deny all/)
{'fraction_non_alphanumeric': 0.14505776636713735, 'fraction_numerical': 0.030166880616174584, 'mean_word_length': 2.746394230769231, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '2760901', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1068, 'n_words': 199}