Sha256: e9c310688ac733c74f3e51087dd58c61e342efd007e49e1b8feea1c217557b66

Contents?: true

Size: 957 Bytes

Versions: 16

Compression:

Stored size: 957 Bytes

Contents

module Windows::Group
  include Beaker::CommandFactory

  def group_list
    execute('cmd /c echo "" | wmic group where localaccount="true" get name /format:value') do |result|
      groups = []
      result.stdout.each_line do |line|
        groups << (line.match(/^Name=(.+)$/) or next)[1]
      end

      yield result if block_given?

      groups
    end
  end

  def group_get(name)
    execute("net localgroup \"#{name}\"") do |result|
      fail_test "failed to get group #{name}" if result.exit_code != 0

      yield result if block_given?
      result
    end
  end

  def group_gid(_name)
    raise NotImplementedError, "Can't retrieve group gid on a Windows host"
  end

  def group_present(name, &block)
    execute("net localgroup /add \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &block)
  end

  def group_absent(name, &block)
    execute("net localgroup /delete \"#{name}\"", { :acceptable_exit_codes => [0, 2] }, &block)
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
beaker-6.4.1 lib/beaker/host/windows/group.rb
beaker-6.4.0 lib/beaker/host/windows/group.rb
beaker-6.3.0 lib/beaker/host/windows/group.rb
beaker-6.2.0 lib/beaker/host/windows/group.rb
beaker-6.1.0 lib/beaker/host/windows/group.rb
beaker-5.8.1 lib/beaker/host/windows/group.rb
beaker-5.8.0 lib/beaker/host/windows/group.rb
beaker-5.7.0 lib/beaker/host/windows/group.rb
beaker-5.6.0 lib/beaker/host/windows/group.rb
beaker-5.5.0 lib/beaker/host/windows/group.rb
beaker-5.4.0 lib/beaker/host/windows/group.rb
beaker-5.3.1 lib/beaker/host/windows/group.rb
beaker-5.3.0 lib/beaker/host/windows/group.rb
beaker-5.2.0 lib/beaker/host/windows/group.rb
beaker-5.1.0 lib/beaker/host/windows/group.rb
beaker-5.0.0 lib/beaker/host/windows/group.rb