Sha256: 8531da69d7712ee2ee6451efa191d60b44749e7684f28ca004cf08f27b05c84e

Contents?: true

Size: 1.01 KB

Versions: 10

Compression:

Stored size: 1.01 KB

Contents

require 'shellwords'

module Serverspec
  module Commands
    class Darwin < Base
      def check_file_md5checksum(file, expected)
        "openssl md5 #{escape(file)} | cut -d'=' -f2 | cut -c 2- | grep -E ^#{escape(expected)}$"
      end

      def check_file_sha256checksum(file, expected)
        "openssl sha256 #{escape(file)} | cut -d'=' -f2 | cut -c 2- | grep -E ^#{escape(expected)}$"
      end

      def check_mode(file, mode)
        regexp = "^#{mode}$"
        "stat -f%Lp #{escape(file)} | grep -- #{escape(regexp)}"
      end

      def check_owner(file, owner)
        regexp = "^#{owner}$"
        "stat -f %Su #{escape(file)} | grep -- #{escape(regexp)}"
      end

      def check_grouped(file, group)
        regexp = "^#{group}$"
        "stat -f %Sg #{escape(file)} | grep -- #{escape(regexp)}"
      end

      def get_mode(file)
        "stat -f%Lp #{escape(file)}"
      end

      def check_access_by_user(file, user, access)
        "sudo -u #{user} -s /bin/test -#{access} #{file}"
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
serverspec-0.7.12 lib/serverspec/commands/darwin.rb
serverspec-0.7.11 lib/serverspec/commands/darwin.rb
serverspec-0.7.10 lib/serverspec/commands/darwin.rb
serverspec-0.7.9 lib/serverspec/commands/darwin.rb
serverspec-0.7.8 lib/serverspec/commands/darwin.rb
serverspec-0.7.7 lib/serverspec/commands/darwin.rb
serverspec-0.7.6 lib/serverspec/commands/darwin.rb
serverspec-0.7.5 lib/serverspec/commands/darwin.rb
serverspec-0.7.4 lib/serverspec/commands/darwin.rb
serverspec-0.7.3 lib/serverspec/commands/darwin.rb