win32-security 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,67 +1,67 @@
1
- ########################################################################
2
- # test_acl.rb
3
- #
4
- # Test suite for the Win32::Security::ACL class. You should run these
5
- # tests via the 'rake test' task.
6
- ########################################################################
7
- require 'rubygems'
8
- gem 'test-unit'
9
-
10
- require 'win32/security'
11
- require 'test/unit'
12
-
13
- class TC_Win32_Security_Acl < Test::Unit::TestCase
14
- def setup
15
- @acl = Security::ACL.new
16
- end
17
-
18
- def test_version
19
- assert_equal('0.1.0', Security::ACL::VERSION)
20
- end
21
-
22
- def test_ace_count
23
- assert_respond_to(@acl, :ace_count)
24
- assert_kind_of(Fixnum, @acl.ace_count)
25
- assert_equal(0, @acl.ace_count)
26
- end
27
-
28
- def test_acl
29
- assert_respond_to(@acl, :acl)
30
- assert_kind_of(String, @acl.acl)
31
- end
32
-
33
- def test_add_access_allowed_ace
34
- assert_respond_to(@acl, :add_access_allowed_ace)
35
- end
36
-
37
- def test_add_access_denied_ace
38
- assert_respond_to(@acl, :add_access_denied_ace)
39
- end
40
-
41
- def test_add_ace
42
- assert_respond_to(@acl, :add_ace)
43
- end
44
-
45
- def test_delete_ace
46
- assert_respond_to(@acl, :delete_ace)
47
- end
48
-
49
- def test_find_ace
50
- assert_respond_to(@acl, :find_ace)
51
- assert_kind_of(Fixnum, @acl.find_ace)
52
- end
53
-
54
- def test_revision
55
- assert_respond_to(@acl, :revision)
56
- assert_kind_of(Fixnum, @acl.revision)
57
- end
58
-
59
- def test_is_valid
60
- assert_respond_to(@acl, :valid?)
61
- assert_equal(true, @acl.valid?)
62
- end
63
-
64
- def teardown
65
- @acl = nil
66
- end
67
- end
1
+ ########################################################################
2
+ # test_acl.rb
3
+ #
4
+ # Test suite for the Win32::Security::ACL class. You should run these
5
+ # tests via the 'rake test' task.
6
+ ########################################################################
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'win32/security'
11
+ require 'test/unit'
12
+
13
+ class TC_Win32_Security_Acl < Test::Unit::TestCase
14
+ def setup
15
+ @acl = Security::ACL.new
16
+ end
17
+
18
+ def test_version
19
+ assert_equal('0.1.0', Security::ACL::VERSION)
20
+ end
21
+
22
+ def test_ace_count
23
+ assert_respond_to(@acl, :ace_count)
24
+ assert_kind_of(Fixnum, @acl.ace_count)
25
+ assert_equal(0, @acl.ace_count)
26
+ end
27
+
28
+ def test_acl
29
+ assert_respond_to(@acl, :acl)
30
+ assert_kind_of(String, @acl.acl)
31
+ end
32
+
33
+ def test_add_access_allowed_ace
34
+ assert_respond_to(@acl, :add_access_allowed_ace)
35
+ end
36
+
37
+ def test_add_access_denied_ace
38
+ assert_respond_to(@acl, :add_access_denied_ace)
39
+ end
40
+
41
+ def test_add_ace
42
+ assert_respond_to(@acl, :add_ace)
43
+ end
44
+
45
+ def test_delete_ace
46
+ assert_respond_to(@acl, :delete_ace)
47
+ end
48
+
49
+ def test_find_ace
50
+ assert_respond_to(@acl, :find_ace)
51
+ assert_kind_of(Fixnum, @acl.find_ace)
52
+ end
53
+
54
+ def test_revision
55
+ assert_respond_to(@acl, :revision)
56
+ assert_kind_of(Fixnum, @acl.revision)
57
+ end
58
+
59
+ def test_is_valid
60
+ assert_respond_to(@acl, :valid?)
61
+ assert_equal(true, @acl.valid?)
62
+ end
63
+
64
+ def teardown
65
+ @acl = nil
66
+ end
67
+ end
@@ -1,34 +1,34 @@
1
- ########################################################################
2
- # test_security.rb
3
- #
4
- # Test suite for the Win32::Security base class. You should run these
5
- # tests via the 'rake test' task.
6
- ########################################################################
7
- require 'rubygems'
8
- gem 'test-unit'
9
-
10
- require 'test/unit'
11
- require 'win32/security'
12
- require 'windows/system_info'
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
-
21
- def test_version
22
- assert_equal('0.1.3', Win32::Security::VERSION)
23
- end
24
-
25
- def test_elevated_security
26
- omit_if(@@version < 6.0, 'Skipped on Windows 2000 and Windows XP')
27
- assert_respond_to(Win32::Security, :elevated_security?)
28
- assert_boolean(Win32::Security.elevated_security?)
29
- end
30
-
31
- def self.shutdown
32
- @@version= nil
33
- end
34
- end
1
+ ########################################################################
2
+ # test_security.rb
3
+ #
4
+ # Test suite for the Win32::Security base class. You should run these
5
+ # tests via the 'rake test' task.
6
+ ########################################################################
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'test/unit'
11
+ require 'win32/security'
12
+ require 'windows/system_info'
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
+
21
+ def test_version
22
+ assert_equal('0.1.4', Win32::Security::VERSION)
23
+ end
24
+
25
+ def test_elevated_security
26
+ omit_if(@@version < 6.0, 'Skipped on Windows 2000 and Windows XP')
27
+ assert_respond_to(Win32::Security, :elevated_security?)
28
+ assert_boolean(Win32::Security.elevated_security?)
29
+ end
30
+
31
+ def self.shutdown
32
+ @@version= nil
33
+ end
34
+ end
@@ -1,137 +1,141 @@
1
- ########################################################################
2
- # test_sid.rb
3
- #
4
- # Test suite for the Win32::Security::SID class. You should run these
5
- # tests via the 'rake test' task.
6
- ########################################################################
7
- require 'test-unit'
8
- require 'win32/security'
9
- require 'sys/admin'
10
- include Win32
11
-
12
- class TC_Win32_Security_Sid < Test::Unit::TestCase
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
137
- end
1
+ ########################################################################
2
+ # test_sid.rb
3
+ #
4
+ # Test suite for the Win32::Security::SID class. You should run these
5
+ # tests via the 'rake test' task.
6
+ ########################################################################
7
+ require 'test-unit'
8
+ require 'win32/security'
9
+ require 'sys/admin'
10
+ include Win32
11
+
12
+ class TC_Win32_Security_Sid < Test::Unit::TestCase
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.4', 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 "string/sid roundtrip works as expected" do
63
+ assert_true(Security::SID.new(Security::SID.string_to_sid('S-1-5-18')).to_s == 'S-1-5-18')
64
+ end
65
+
66
+ test "to_s works as expected" do
67
+ assert_respond_to(@sid, :to_s)
68
+ assert_kind_of(String, @sid.to_s)
69
+ assert_true(@sid.to_s.include?('-'))
70
+ end
71
+
72
+ test "to_str is an alias for to_s" do
73
+ assert_respond_to(@sid, :to_str)
74
+ assert_alias_method(@sid, :to_str, :to_s)
75
+ end
76
+
77
+ test "equality works as expected" do
78
+ assert_respond_to(@sid, :==)
79
+ assert_true(@sid == @sid)
80
+ end
81
+
82
+ test "valid? method works as expected" do
83
+ assert_respond_to(@sid, :valid?)
84
+ assert_true(@sid.valid?)
85
+ end
86
+
87
+ test "length method works as expected" do
88
+ assert_respond_to(@sid, :length)
89
+ assert_true(@sid.length > 0)
90
+ end
91
+
92
+ test "create method works as expected" do
93
+ assert_respond_to(Security::SID, :create)
94
+ assert_nothing_raised{
95
+ Security::SID.create(
96
+ Security::SID::SECURITY_WORLD_SID_AUTHORITY,
97
+ Security::SID::SECURITY_WORLD_RID
98
+ )
99
+ }
100
+ end
101
+
102
+ test "constructor defaults to current account" do
103
+ assert_nothing_raised{ @sid = Security::SID.new }
104
+ assert_equal(Sys::Admin.get_login, @sid.account)
105
+ end
106
+
107
+ test "constructor accepts an account argument" do
108
+ assert_nothing_raised{ Security::SID.new(@@name) }
109
+ end
110
+
111
+ test "constructor accepts a host argument" do
112
+ assert_nothing_raised{ Security::SID.new(@@name, @@host) }
113
+ end
114
+
115
+ test "constructor accepts a maximum of two arguments" do
116
+ assert_raise(ArgumentError){ Security::SID.new(@@name, @@host, @@host) }
117
+ end
118
+
119
+ test "constructor raises an error if an invalid account is passed" do
120
+ assert_raise(Security::SID::Error){ Security::SID.new('bogus') }
121
+ end
122
+
123
+ test "well known sid constants are defined" do
124
+ assert_equal('S-1-0', Security::SID::Null)
125
+ assert_equal('S-1-0-0', Security::SID::Nobody)
126
+ assert_equal('S-1-1', Security::SID::World)
127
+ assert_equal('S-1-1-0', Security::SID::Everyone)
128
+ assert_equal('S-1-5-32-544', Security::SID::BuiltinAdministrators)
129
+ assert_equal('S-1-5-32-545', Security::SID::BuiltinUsers)
130
+ assert_equal('S-1-5-32-546', Security::SID::Guests)
131
+ end
132
+
133
+ def teardown
134
+ @sid = nil
135
+ end
136
+
137
+ def self.shutdown
138
+ @@host = nil
139
+ @@name = nil
140
+ end
141
+ end