win32-security 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,14 +9,26 @@ gem 'test-unit'
9
9
 
10
10
  require 'test/unit'
11
11
  require 'win32/security'
12
+ require 'windows/system_info'
12
13
 
13
14
  class TC_Win32_Security < Test::Unit::TestCase
15
+ extend Windows::SystemInfo
16
+
17
+ def self.startup
18
+ @@version = windows_version
19
+ end
20
+
14
21
  def test_version
15
- assert_equal('0.1.2', Win32::Security::VERSION)
22
+ assert_equal('0.1.3', Win32::Security::VERSION)
16
23
  end
17
24
 
18
25
  def test_elevated_security
26
+ omit_if(@@version < 6.0, 'Skipped on Windows 2000 and Windows XP')
19
27
  assert_respond_to(Win32::Security, :elevated_security?)
20
28
  assert_boolean(Win32::Security.elevated_security?)
21
29
  end
30
+
31
+ def self.shutdown
32
+ @@version= nil
33
+ end
22
34
  end
data/test/test_sid.rb CHANGED
@@ -4,126 +4,134 @@
4
4
  # Test suite for the Win32::Security::SID class. You should run these
5
5
  # tests via the 'rake test' task.
6
6
  ########################################################################
7
- require 'rubygems'
8
- gem 'test-unit'
9
-
10
- require 'test/unit'
7
+ require 'test-unit'
11
8
  require 'win32/security'
12
9
  require 'sys/admin'
13
10
  include Win32
14
11
 
15
12
  class TC_Win32_Security_Sid < Test::Unit::TestCase
16
- def self.startup
17
- @@host = Socket.gethostname
18
- @@name = Sys::Admin.users[0].name
19
- end
20
-
21
- def setup
22
- @sid = Security::SID.new(@@name)
23
- end
24
-
25
- def test_version
26
- assert_equal('0.1.2', Security::SID::VERSION)
27
- end
28
-
29
- def test_sid
30
- assert_respond_to(@sid, :sid)
31
- assert_kind_of(String, @sid.sid)
32
- end
33
-
34
- def test_account
35
- assert_respond_to(@sid, :account)
36
- assert_kind_of(String, @sid.account)
37
- end
38
-
39
- def test_account_type
40
- assert_respond_to(@sid, :account_type)
41
- assert_kind_of(String, @sid.account_type)
42
- end
43
-
44
- def test_domain
45
- assert_respond_to(@sid, :domain)
46
- assert_kind_of(String, @sid.domain)
47
- end
48
-
49
- def test_host
50
- assert_respond_to(@sid, :host)
51
- assert_kind_of(String, @sid.host)
52
- end
53
-
54
- def test_sid_to_string
55
- assert_respond_to(Security::SID, :sid_to_string)
56
- assert_kind_of(String, Security::SID.sid_to_string(@sid.sid))
57
- assert_not_nil(Security::SID.sid_to_string(@sid.sid) =~ /\w+\-\w+/)
58
- end
59
-
60
- def test_string_to_sid
61
- assert_respond_to(Security::SID, :string_to_sid)
62
- assert_kind_of(String, Security::SID.string_to_sid(@sid.to_s))
63
- end
64
-
65
- def test_to_s
66
- assert_respond_to(@sid, :to_s)
67
- assert_kind_of(String, @sid.to_s)
68
- assert_equal(true, @sid.to_s.include?('-'))
69
- end
70
-
71
- def test_to_str_alias
72
- assert_respond_to(@sid, :to_str)
73
- assert_equal(true, @sid.method(:to_s) == @sid.method(:to_str))
74
- end
75
-
76
- def test_equal
77
- assert_respond_to(@sid, :==)
78
- assert_equal(true, @sid == @sid)
79
- end
80
-
81
- def test_valid
82
- assert_respond_to(@sid, :valid?)
83
- assert_equal(true, @sid.valid?)
84
- end
85
-
86
- def test_length
87
- assert_respond_to(@sid, :length)
88
- assert_equal(true, @sid.length > 0)
89
- end
90
-
91
- def test_create
92
- assert_respond_to(Security::SID, :create)
93
- assert_nothing_raised{
94
- Security::SID.create(
95
- Security::SID::SECURITY_WORLD_SID_AUTHORITY,
96
- Security::SID::SECURITY_WORLD_RID
97
- )
98
- }
99
- end
100
-
101
- def test_new_with_host
102
- assert_nothing_raised{ Security::SID.new(@@name, @@host) }
103
- end
104
-
105
- def test_new_expected_errors
106
- assert_raise(ArgumentError){ Security::SID.new }
107
- assert_raise(ArgumentError){ Security::SID.new(@@name, @@host, @@host) }
108
- assert_raise(Security::SID::Error){ Security::SID.new('bogus') }
109
- end
110
-
111
- def test_well_known_sid_constants
112
- assert_equal('S-1-0', Security::SID::Null)
113
- assert_equal('S-1-0-0', Security::SID::Nobody)
114
- assert_equal('S-1-1', Security::SID::World)
115
- assert_equal('S-1-1-0', Security::SID::Everyone)
116
- assert_equal('S-1-5-32-544', Security::SID::BuiltinAdministrators)
117
- assert_equal('S-1-5-32-545', Security::SID::BuiltinUsers)
118
- assert_equal('S-1-5-32-546', Security::SID::Guests)
119
- end
120
-
121
- def teardown
122
- @sid = nil
123
- end
124
-
125
- def self.shutdown
126
- @@host = nil
127
- @@name = nil
128
- end
13
+ def self.startup
14
+ @@host = Socket.gethostname
15
+ @@name = Sys::Admin.users[0].name
16
+ end
17
+
18
+ def setup
19
+ @sid = Security::SID.new(@@name)
20
+ end
21
+
22
+ test "version is set to expected value" do
23
+ assert_equal('0.1.3', Security::SID::VERSION)
24
+ end
25
+
26
+ test "sid method basic functionality" do
27
+ assert_respond_to(@sid, :sid)
28
+ assert_kind_of(String, @sid.sid)
29
+ end
30
+
31
+ test "account method basic functionality" do
32
+ assert_respond_to(@sid, :account)
33
+ assert_kind_of(String, @sid.account)
34
+ end
35
+
36
+ test "account_type method basic functionality" do
37
+ assert_respond_to(@sid, :account_type)
38
+ assert_kind_of(String, @sid.account_type)
39
+ end
40
+
41
+ test "domain method basic functionality" do
42
+ assert_respond_to(@sid, :domain)
43
+ assert_kind_of(String, @sid.domain)
44
+ end
45
+
46
+ test "host method basic functionality" do
47
+ assert_respond_to(@sid, :host)
48
+ assert_kind_of(String, @sid.host)
49
+ end
50
+
51
+ test "sid_to_string works as expected" do
52
+ assert_respond_to(Security::SID, :sid_to_string)
53
+ assert_kind_of(String, Security::SID.sid_to_string(@sid.sid))
54
+ assert_not_nil(Security::SID.sid_to_string(@sid.sid) =~ /\w+\-\w+/)
55
+ end
56
+
57
+ test "string_to_sid works as expected" do
58
+ assert_respond_to(Security::SID, :string_to_sid)
59
+ assert_kind_of(String, Security::SID.string_to_sid(@sid.to_s))
60
+ end
61
+
62
+ test "to_s works as expected" do
63
+ assert_respond_to(@sid, :to_s)
64
+ assert_kind_of(String, @sid.to_s)
65
+ assert_true(@sid.to_s.include?('-'))
66
+ end
67
+
68
+ test "to_str is an alias for to_s" do
69
+ assert_respond_to(@sid, :to_str)
70
+ assert_alias_method(@sid, :to_str, :to_s)
71
+ end
72
+
73
+ test "equality works as expected" do
74
+ assert_respond_to(@sid, :==)
75
+ assert_true(@sid == @sid)
76
+ end
77
+
78
+ test "valid? method works as expected" do
79
+ assert_respond_to(@sid, :valid?)
80
+ assert_true(@sid.valid?)
81
+ end
82
+
83
+ test "length method works as expected" do
84
+ assert_respond_to(@sid, :length)
85
+ assert_true(@sid.length > 0)
86
+ end
87
+
88
+ test "create method works as expected" do
89
+ assert_respond_to(Security::SID, :create)
90
+ assert_nothing_raised{
91
+ Security::SID.create(
92
+ Security::SID::SECURITY_WORLD_SID_AUTHORITY,
93
+ Security::SID::SECURITY_WORLD_RID
94
+ )
95
+ }
96
+ end
97
+
98
+ test "constructor defaults to current account" do
99
+ assert_nothing_raised{ @sid = Security::SID.new }
100
+ assert_equal(Sys::Admin.get_login, @sid.account)
101
+ end
102
+
103
+ test "constructor accepts an account argument" do
104
+ assert_nothing_raised{ Security::SID.new(@@name) }
105
+ end
106
+
107
+ test "constructor accepts a host argument" do
108
+ assert_nothing_raised{ Security::SID.new(@@name, @@host) }
109
+ end
110
+
111
+ test "constructor accepts a maximum of two arguments" do
112
+ assert_raise(ArgumentError){ Security::SID.new(@@name, @@host, @@host) }
113
+ end
114
+
115
+ test "constructor raises an error if an invalid account is passed" do
116
+ assert_raise(Security::SID::Error){ Security::SID.new('bogus') }
117
+ end
118
+
119
+ test "well known sid constants are defined" do
120
+ assert_equal('S-1-0', Security::SID::Null)
121
+ assert_equal('S-1-0-0', Security::SID::Nobody)
122
+ assert_equal('S-1-1', Security::SID::World)
123
+ assert_equal('S-1-1-0', Security::SID::Everyone)
124
+ assert_equal('S-1-5-32-544', Security::SID::BuiltinAdministrators)
125
+ assert_equal('S-1-5-32-545', Security::SID::BuiltinUsers)
126
+ assert_equal('S-1-5-32-546', Security::SID::Guests)
127
+ end
128
+
129
+ def teardown
130
+ @sid = nil
131
+ end
132
+
133
+ def self.shutdown
134
+ @@host = nil
135
+ @@name = nil
136
+ end
129
137
  end
@@ -1,31 +1,27 @@
1
1
  require 'rubygems'
2
2
 
3
- spec = Gem::Specification.new do |gem|
4
- gem.name = 'win32-security'
5
- gem.version = '0.1.2'
6
- gem.authors = ['Daniel J. Berger', 'Park Heesob']
7
- gem.email = 'djberg96@gmail.com'
8
- gem.homepage = 'http://www.rubyforge.org/projects/win32utils'
9
- gem.platform = Gem::Platform::RUBY
10
- gem.summary = 'A library for dealing with aspects of Windows security.'
11
- gem.test_files = Dir['test/*.rb']
12
- gem.has_rdoc = true
13
- gem.files = Dir['**/*'].reject{ |f| f.include?('CVS') }
14
- gem.license = 'Artistic 2.0'
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'win32-security'
5
+ spec.version = '0.1.3'
6
+ spec.authors = ['Daniel J. Berger', 'Park Heesob']
7
+ spec.license = 'Artistic 2.0'
8
+ spec.email = 'djberg96@gmail.com'
9
+ spec.homepage = 'http://www.rubyforge.org/projects/win32utils'
10
+ spec.summary = 'A library for dealing with aspects of Windows security.'
11
+ spec.test_files = Dir['test/*.rb']
12
+ spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
15
13
 
16
- gem.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
17
- gem.rubyforge_project = 'win32utils'
14
+ spec.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
15
+ spec.rubyforge_project = 'win32utils'
18
16
 
19
- gem.add_dependency('windows-pr', '>= 0.9.8')
17
+ spec.add_dependency('windows-pr', '>= 1.2.2')
20
18
 
21
- gem.add_development_dependency('test-unit', '>= 2.0.1')
22
- gem.add_development_dependency('sys-admin', '>= 1.4.4')
19
+ spec.add_development_dependency('test-unit', '>= 2.5.0')
20
+ spec.add_development_dependency('sys-admin', '>= 1.5.3')
23
21
 
24
- gem.description = <<-EOF
25
- The win32-security library provides an interface for dealing with
26
- security related aspects of MS Windows. At the moment it provides an
27
- interface for inspecting or creating SID's.
28
- EOF
22
+ spec.description = <<-EOF
23
+ The win32-security library provides an interface for dealing with
24
+ security related aspects of MS Windows. At the moment it provides an
25
+ interface for inspecting or creating SID's.
26
+ EOF
29
27
  end
30
-
31
- Gem::Builder.new(spec).build
metadata CHANGED
@@ -1,59 +1,76 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: win32-security
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.3
5
+ prerelease:
5
6
  platform: ruby
6
- authors:
7
+ authors:
7
8
  - Daniel J. Berger
8
9
  - Park Heesob
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
-
13
- date: 2009-08-02 00:00:00 -06:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
13
+ date: 2012-07-12 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
17
16
  name: windows-pr
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: 1.2.2
18
23
  type: :runtime
19
- version_requirement:
20
- version_requirements: !ruby/object:Gem::Requirement
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
24
- version: 0.9.8
25
- version:
26
- - !ruby/object:Gem::Dependency
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: 1.2.2
31
+ - !ruby/object:Gem::Dependency
27
32
  name: test-unit
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: 2.5.0
28
39
  type: :development
29
- version_requirement:
30
- version_requirements: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: 2.0.1
35
- version:
36
- - !ruby/object:Gem::Dependency
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: 2.5.0
47
+ - !ruby/object:Gem::Dependency
37
48
  name: sys-admin
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.5.3
38
55
  type: :development
39
- version_requirement:
40
- version_requirements: !ruby/object:Gem::Requirement
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- version: 1.4.4
45
- version:
46
- description: " The win32-security library provides an interface for dealing with\n security related aspects of MS Windows. At the moment it provides an\n interface for inspecting or creating SID's.\n"
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: 1.5.3
63
+ description: ! " The win32-security library provides an interface for dealing with\n
64
+ \ security related aspects of MS Windows. At the moment it provides an\n interface
65
+ for inspecting or creating SID's.\n"
47
66
  email: djberg96@gmail.com
48
67
  executables: []
49
-
50
68
  extensions: []
51
-
52
- extra_rdoc_files:
69
+ extra_rdoc_files:
53
70
  - README
54
71
  - CHANGES
55
72
  - MANIFEST
56
- files:
73
+ files:
57
74
  - CHANGES
58
75
  - lib/win32/security/ace.rb
59
76
  - lib/win32/security/acl.rb
@@ -66,35 +83,32 @@ files:
66
83
  - test/test_security.rb
67
84
  - test/test_sid.rb
68
85
  - win32-security.gemspec
69
- has_rdoc: true
70
86
  homepage: http://www.rubyforge.org/projects/win32utils
71
- licenses:
87
+ licenses:
72
88
  - Artistic 2.0
73
89
  post_install_message:
74
90
  rdoc_options: []
75
-
76
- require_paths:
91
+ require_paths:
77
92
  - lib
78
- required_ruby_version: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: "0"
83
- version:
84
- required_rubygems_version: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: "0"
89
- version:
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
90
105
  requirements: []
91
-
92
106
  rubyforge_project: win32utils
93
- rubygems_version: 1.3.5
107
+ rubygems_version: 1.8.24
94
108
  signing_key:
95
109
  specification_version: 3
96
110
  summary: A library for dealing with aspects of Windows security.
97
- test_files:
111
+ test_files:
98
112
  - test/test_acl.rb
99
113
  - test/test_security.rb
100
114
  - test/test_sid.rb