Class: Inspec::Resources::IisSite

Inherits:
Object
  • Object
show all
Defined in:
lib/inspec/resources/iis_site.rb

Direct Known Subclasses

IisSiteServerSpec

Instance Method Summary collapse

Constructor Details

#initialize(site_name) ⇒ IisSite

Returns a new instance of IisSite.



34
35
36
37
38
39
40
41
42
# File 'lib/inspec/resources/iis_site.rb', line 34

def initialize(site_name)
  @site_name = site_name
  @cache = nil

  @site_provider = SiteProvider.new(inspec)

  # verify that this resource is only supported on Windows
  return skip_resource "The `iis_site` resource is not supported on your OS." if inspec.os[:family] != "windows"
end

Instance Method Details

#app_poolObject



44
45
46
# File 'lib/inspec/resources/iis_site.rb', line 44

def app_pool
  iis_site.nil? ? nil : iis_site[:app_pool]
end

#bindingsObject



48
49
50
# File 'lib/inspec/resources/iis_site.rb', line 48

def bindings
  iis_site.nil? ? nil : iis_site[:bindings]
end

#exists?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/inspec/resources/iis_site.rb', line 60

def exists?
  !iis_site.nil? && !iis_site[:name].nil?
end

#has_app_pool?(app_pool) ⇒ Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/inspec/resources/iis_site.rb', line 68

def has_app_pool?(app_pool)
  iis_site.nil? ? false : iis_site[:app_pool] == app_pool
end

#has_binding?(binding) ⇒ Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/inspec/resources/iis_site.rb', line 76

def has_binding?(binding)
  iis_site.nil? ? false : (iis_site[:bindings].include? binding)
end

#has_path?(path) ⇒ Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/inspec/resources/iis_site.rb', line 72

def has_path?(path)
  iis_site.nil? ? false : iis_site[:path] == path
end

#iis_siteObject



88
89
90
91
92
# File 'lib/inspec/resources/iis_site.rb', line 88

def iis_site
  return @cache unless @cache.nil?

  @cache = @site_provider.iis_site(@site_name) unless @site_provider.nil?
end

#pathObject



56
57
58
# File 'lib/inspec/resources/iis_site.rb', line 56

def path
  iis_site.nil? ? nil : iis_site[:path]
end

#resource_idObject



80
81
82
# File 'lib/inspec/resources/iis_site.rb', line 80

def resource_id
  @site_name || "IIS Site"
end

#running?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/inspec/resources/iis_site.rb', line 64

def running?
  iis_site.nil? ? false : (iis_site[:state] == "Started")
end

#stateObject



52
53
54
# File 'lib/inspec/resources/iis_site.rb', line 52

def state
  iis_site.nil? ? nil : iis_site[:state]
end

#to_sObject



84
85
86
# File 'lib/inspec/resources/iis_site.rb', line 84

def to_s
  "iis_site '#{@site_name}'"
end