<commit_before>require 'spec_helper_system'

describe 'single node setup:' do
  proj_root = File.expand_path(File.join(File.dirname(__FILE__), '../..'))
  pp = IO.read(proj_root + '/spec/fixtures/manifests/end_to_end.pp')

  context puppet_apply(pp) do
    its(:exit_code) { should_not eq(1) }
  end

  describe 'root can do what they like' do
    context shell('mco ping') do
      its(:stdout) { should =~ /main.foo.vm/ }
    end

    context shell('mco rpc rpcutil inventory -j </dev/null') do
      its(:stdout) { should =~ /discovery/ }
    end

    context shell('mco rpc nrpe runcommand command=hello_world -j </dev/null') do
      its(:stdout) { should =~ /Hello World!/ }
    end
  end

  describe 'nagios user can do limited things' do
    context shell('sudo -u nagios mco ping') do
      its(:stdout) { should =~ /main.foo.vm/ }
    end

    context shell('sudo -u nagios mco rpc rpcutil inventory -j </dev/null') do
      its(:stdout) { should =~ /You are not authorized to call this agent or action/ }
    end

    context shell('sudo -u nagios mco rpc nrpe runcommand command=hello_world -j </dev/null') do
      its(:stdout) { should =~ /Hello World!/ }
    end
  end
end
<commit_msg>(#58) fix user impersonation in rspec-system tests<commit_after>require 'spec_helper_system'

describe 'single node setup:' do
  proj_root = File.expand_path(File.join(File.dirname(__FILE__), '../..'))
  pp = IO.read(proj_root + '/spec/fixtures/manifests/end_to_end.pp')

  context puppet_apply(pp) do
    its(:exit_code) { should_not eq(1) }
  end

  describe 'root can do what they like' do
    context shell('sudo -i mco ping') do
      its(:stdout) { should =~ /main.foo.vm/ }
    end

    context shell('sudo -i mco rpc rpcutil inventory -j </dev/null') do
      its(:stdout) { should =~ /discovery/ }
    end

    context shell('sudo -i mco rpc nrpe runcommand command=hello_world -j </dev/null') do
      its(:stdout) { should =~ /Hello World!/ }
    end
  end

  describe 'nagios user can do limited things' do
    context shell('sudo -i -u nagios mco ping') do
      its(:stdout) { should =~ /main.foo.vm/ }
    end

    context shell('sudo -i -u nagios mco rpc rpcutil inventory -j </dev/null') do
      its(:stdout) { should =~ /You are not authorized to call this agent or action/ }
    end

    context shell('sudo -i -u nagios mco rpc nrpe runcommand command=hello_world -j </dev/null') do
      its(:stdout) { should =~ /Hello World!/ }
    end
  end
end

{'fraction_non_alphanumeric': 0.13036437246963561, 'fraction_numerical': 0.0016194331983805667, 'mean_word_length': 2.9036334913112163, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, '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': '7295812', 'n_tokens_mistral': 863, 'n_tokens_neox': 824, 'n_words': 263}