Sha256: bc5e3e18de6a7c5d4ddb4be41636e02206b972423c9a4701575de8b5bc835df9

Contents?: true

Size: 1.35 KB

Versions: 18

Compression:

Stored size: 1.35 KB

Contents

#!/usr/bin/env rspec

require 'spec_helper'
require 'mcollective/audit/logfile'

module MCollective
  module RPC
    describe Logfile do
      let(:file) do
        mock
      end

      let(:request) do
        req = mock
        req.stubs(:uniqid).returns("1234")
        req.stubs(:time).returns(1389179593)
        req.stubs(:caller).returns("test_user")
        req.stubs(:sender).returns("test_host")
        req.stubs(:agent).returns("rspec_agent")
        req.stubs(:action).returns("testme")
        req.stubs(:data).returns({})
        req
      end

      before :each do
        Time.stubs(:now).returns(Time.at(1389180255))
        file.expects(:puts).with("[2014-01-08 11:24:15 UTC] reqid=1234: reqtime=1389179593 caller=test_user@test_host " +
                                  "agent=rspec_agent action=testme data={}")
      end

      it 'should log to a user defined logfile' do
        Config.any_instance.stubs(:pluginconf).returns("rpcaudit.logfile" => "/nonexisting")
        File.expects(:open).with("/nonexisting", "a").yields(file)
        Logfile.new.audit_request(request, nil)
      end

      it 'should log to a default logfile' do
        Config.any_instance.stubs(:pluginconf).returns({})
        File.expects(:open).with("/var/log/mcollective-audit.log", "a").yields(file)
        Logfile.new.audit_request(request, nil)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
mcollective-client-2.10.6 spec/unit/mcollective/audit/logfile_spec.rb
mcollective-client-2.10.4 spec/unit/mcollective/audit/logfile_spec.rb
mcollective-client-2.10.3 spec/unit/mcollective/audit/logfile_spec.rb
mcollective-client-2.10.2 spec/unit/mcollective/audit/logfile_spec.rb
mcollective-client-2.10.1 spec/unit/mcollective/audit/logfile_spec.rb
mcollective-client-2.10.0 spec/unit/mcollective/audit/logfile_spec.rb
mcollective-client-2.8.7 spec/unit/mcollective/audit/logfile_spec.rb
mcollective-client-2.8.5 spec/unit/mcollective/audit/logfile_spec.rb
mcollective-client-2.8.8 spec/unit/mcollective/audit/logfile_spec.rb
mcollective-client-2.8.6 spec/unit/mcollective/audit/logfile_spec.rb
mcollective-client-2.9.1 spec/unit/mcollective/audit/logfile_spec.rb
mcollective-client-2.9.0 spec/unit/mcollective/audit/logfile_spec.rb
mcollective-client-2.8.9 spec/unit/mcollective/audit/logfile_spec.rb
mcollective-client-2.8.4 spec/unit/mcollective/audit/logfile_spec.rb
mcollective-client-2.8.3 spec/unit/mcollective/audit/logfile_spec.rb
mcollective-client-2.8.2 spec/unit/mcollective/audit/logfile_spec.rb
mcollective-client-2.8.1 spec/unit/mcollective/audit/logfile_spec.rb
mcollective-client-2.8.0 spec/unit/mcollective/audit/logfile_spec.rb