dbi-dbrc 1.1.7-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,162 @@
1
+ ########################################################################
2
+ # test_dbi_dbrc_xml.rb
3
+ #
4
+ # Test suite for the XML specific version of DBI::DBRC. This test case
5
+ # should be run via the 'rake test' task.
6
+ ########################################################################
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'dbi/dbrc'
11
+ require 'test/unit'
12
+ require 'rexml/document'
13
+ include REXML
14
+ include DBI
15
+
16
+ class TC_DBI_DBRC_XML < Test::Unit::TestCase
17
+ def setup
18
+ @dir = File.join(Dir.pwd, 'examples/xml')
19
+ @file = File.join(@dir, '.dbrc')
20
+ @db1 = "foo"
21
+ @db2 = "bar"
22
+ @user1 = "user1"
23
+ @user2 = "user2"
24
+ @db_bad = "blah" # Doesn't exist
25
+ @user_bad = "user8" # Doesn't exist
26
+
27
+ if File::ALT_SEPARATOR && File.respond_to?(:set_attr)
28
+ File.set_attr(@file, File::HIDDEN)
29
+ else
30
+ File.chmod(0600, @file)
31
+ end
32
+
33
+ @dbrc = DBRC::XML.new(@db1, nil, @dir)
34
+ end
35
+
36
+ def test_constructor
37
+ assert_raises(ArgumentError){ DBRC::XML.new }
38
+ assert_nothing_raised{ DBRC::XML.new(@db1, @user1, @dir) }
39
+ assert_nothing_raised{ DBRC::XML.new(@db1, nil, @dir) }
40
+ end
41
+
42
+ def test_bad_database
43
+ assert_raises(DBRC::Error){ DBRC::XML.new(@db_bad, nil, @dir) }
44
+ end
45
+
46
+ def test_bad_user
47
+ assert_raises(DBRC::Error){ DBRC::XML.new(@db1, @user_bad, @dir) }
48
+ end
49
+
50
+ def test_database
51
+ assert_respond_to(@dbrc, :database)
52
+ assert_respond_to(@dbrc, :database=)
53
+ assert_respond_to(@dbrc, :db)
54
+ assert_respond_to(@dbrc, :db=)
55
+ assert_kind_of(String, @dbrc.db)
56
+ end
57
+
58
+ def test_dsn
59
+ assert_respond_to(@dbrc, :dsn)
60
+ assert_respond_to(@dbrc, :dsn=)
61
+ end
62
+
63
+ def test_user
64
+ assert_respond_to(@dbrc, :user)
65
+ assert_respond_to(@dbrc, :user=)
66
+ assert_kind_of(String, @dbrc.user)
67
+ end
68
+
69
+ def test_password
70
+ assert_respond_to(@dbrc, :password)
71
+ assert_respond_to(@dbrc, :password=)
72
+ assert_respond_to(@dbrc, :passwd)
73
+ assert_respond_to(@dbrc, :passwd=)
74
+ assert_kind_of(String, @dbrc.password)
75
+ end
76
+
77
+ def test_driver
78
+ assert_respond_to(@dbrc, :driver)
79
+ assert_respond_to(@dbrc, :driver=)
80
+ assert_kind_of(String, @dbrc.driver)
81
+ end
82
+
83
+ def test_interval
84
+ assert_respond_to(@dbrc, :interval)
85
+ assert_respond_to(@dbrc, :interval=)
86
+ assert_kind_of(Fixnum, @dbrc.interval)
87
+ end
88
+
89
+ def test_timeout
90
+ assert_respond_to(@dbrc, :timeout)
91
+ assert_respond_to(@dbrc, :timeout=)
92
+ assert_respond_to(@dbrc, :time_out)
93
+ assert_respond_to(@dbrc, :time_out=)
94
+ assert_kind_of(Fixnum, @dbrc.timeout)
95
+ end
96
+
97
+ def test_max_reconn
98
+ assert_respond_to(@dbrc, :max_reconn)
99
+ assert_respond_to(@dbrc, :max_reconn=)
100
+ assert_respond_to(@dbrc, :maximum_reconnects)
101
+ assert_respond_to(@dbrc, :maximum_reconnects=)
102
+ assert_kind_of(Fixnum, @dbrc.maximum_reconnects)
103
+ end
104
+
105
+ def test_sample_values
106
+ assert_equal("foo", @dbrc.database)
107
+ assert_equal("user1", @dbrc.user)
108
+ assert_equal("pwd1", @dbrc.passwd)
109
+ assert_equal("Oracle", @dbrc.driver)
110
+ assert_equal(60, @dbrc.interval)
111
+ assert_equal(40, @dbrc.timeout)
112
+ assert_equal(3, @dbrc.max_reconn)
113
+ assert_equal("dbi:Oracle:foo", @dbrc.dsn)
114
+ end
115
+
116
+ # Same database, different user
117
+ def test_duplicate_database
118
+ db = DBRC::XML.new("foo", "user2", @dir)
119
+ assert_equal("user2", db.user)
120
+ assert_equal("pwd2", db.passwd)
121
+ assert_equal("OCI8", db.driver)
122
+ assert_equal(60, db.interval)
123
+ assert_equal(60, db.timeout)
124
+ assert_equal(4, db.max_reconn)
125
+ assert_equal("dbi:OCI8:foo", db.dsn)
126
+ end
127
+
128
+ # Different database, different user
129
+ def test_different_database
130
+ db = DBRC::XML.new("bar", "user1", @dir)
131
+ assert_equal("user1", db.user)
132
+ assert_equal("pwd3", db.passwd)
133
+ assert_equal("Oracle", db.driver)
134
+ assert_equal(30, db.interval)
135
+ assert_equal(30, db.timeout)
136
+ assert_equal(2, db.max_reconn)
137
+ assert_equal("dbi:Oracle:bar", db.dsn)
138
+ end
139
+
140
+ # A database with only a couple fields defined
141
+ def test_nil_values
142
+ db = DBRC::XML.new("baz", "user3", @dir)
143
+ assert_equal("user3", db.user)
144
+ assert_equal("pwd4", db.passwd)
145
+ assert_nil(db.driver)
146
+ assert_nil(db.interval)
147
+ assert_nil(db.timeout)
148
+ assert_nil(db.max_reconn)
149
+ assert_nil(db.dsn)
150
+ end
151
+
152
+ def teardown
153
+ @dir = nil
154
+ @db1 = nil
155
+ @db2 = nil
156
+ @user1 = nil
157
+ @user2 = nil
158
+ @db_bad = nil
159
+ @user_bad = nil
160
+ @dbrc = nil
161
+ end
162
+ end
@@ -0,0 +1,160 @@
1
+ #########################################################################
2
+ # test_dbi_dbrc_yml.rb
3
+ #
4
+ # Test suite for the YAML specific version of DBI::DBRC. You should run
5
+ # this test case via the 'rake test' task.
6
+ #########################################################################
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'dbi/dbrc'
11
+ require 'test/unit'
12
+ include DBI
13
+
14
+ class TC_DBI_DBRC_YML < Test::Unit::TestCase
15
+ def setup
16
+ @dir = File.join(Dir.pwd, 'examples/yml')
17
+ @file = File.join(@dir, '.dbrc')
18
+ @db1 = "foo"
19
+ @db2 = "bar"
20
+ @user1 = "user1"
21
+ @user2 = "user2"
22
+ @db_bad = "blah" # Doesn't exist
23
+ @user_bad = "user8" # Doesn't exist
24
+
25
+ if File::ALT_SEPARATOR && File.respond_to?(:set_attr)
26
+ File.set_attr(@file, File::HIDDEN)
27
+ else
28
+ File.chmod(0600, @file)
29
+ end
30
+
31
+ @dbrc = DBRC::YML.new(@db1, nil, @dir)
32
+ end
33
+
34
+ def test_constructor
35
+ assert_raises(ArgumentError){ DBRC::YML.new }
36
+ assert_nothing_raised{ DBRC::YML.new(@db1, @user1, @dir) }
37
+ assert_nothing_raised{ DBRC::YML.new(@db1, nil, @dir) }
38
+ end
39
+
40
+ def test_bad_database
41
+ assert_raises(DBRC::Error){ DBRC::YML.new(@db_bad, nil, @dir) }
42
+ end
43
+
44
+ def test_bad_user
45
+ assert_raises(DBRC::Error){ DBRC::YML.new(@db1, @user_bad, @dir) }
46
+ end
47
+
48
+ def test_database
49
+ assert_respond_to(@dbrc, :database)
50
+ assert_respond_to(@dbrc, :database=)
51
+ assert_respond_to(@dbrc, :db)
52
+ assert_respond_to(@dbrc, :db=)
53
+ assert_kind_of(String, @dbrc.db)
54
+ end
55
+
56
+ def test_dsn
57
+ assert_respond_to(@dbrc, :dsn)
58
+ assert_respond_to(@dbrc, :dsn=)
59
+ end
60
+
61
+ def test_user
62
+ assert_respond_to(@dbrc, :user)
63
+ assert_respond_to(@dbrc, :user=)
64
+ assert_kind_of(String, @dbrc.user)
65
+ end
66
+
67
+ def test_password
68
+ assert_respond_to(@dbrc, :password)
69
+ assert_respond_to(@dbrc, :password=)
70
+ assert_respond_to(@dbrc, :passwd)
71
+ assert_respond_to(@dbrc, :passwd=)
72
+ assert_kind_of(String, @dbrc.password)
73
+ end
74
+
75
+ def test_driver
76
+ assert_respond_to(@dbrc, :driver)
77
+ assert_respond_to(@dbrc, :driver=)
78
+ assert_kind_of(String, @dbrc.driver)
79
+ end
80
+
81
+ def test_interval
82
+ assert_respond_to(@dbrc, :interval)
83
+ assert_respond_to(@dbrc, :interval=)
84
+ assert_kind_of(Fixnum, @dbrc.interval)
85
+ end
86
+
87
+ def test_timeout
88
+ assert_respond_to(@dbrc, :timeout)
89
+ assert_respond_to(@dbrc, :timeout=)
90
+ assert_respond_to(@dbrc, :time_out)
91
+ assert_respond_to(@dbrc, :time_out=)
92
+ assert_kind_of(Fixnum, @dbrc.timeout)
93
+ end
94
+
95
+ def test_max_reconn
96
+ assert_respond_to(@dbrc, :max_reconn)
97
+ assert_respond_to(@dbrc, :max_reconn=)
98
+ assert_respond_to(@dbrc, :maximum_reconnects)
99
+ assert_respond_to(@dbrc, :maximum_reconnects=)
100
+ assert_kind_of(Fixnum, @dbrc.maximum_reconnects)
101
+ end
102
+
103
+ def test_sample_values
104
+ assert_equal("foo", @dbrc.database)
105
+ assert_equal("user1", @dbrc.user)
106
+ assert_equal("pwd1", @dbrc.passwd)
107
+ assert_equal("Oracle", @dbrc.driver)
108
+ assert_equal(60, @dbrc.interval)
109
+ assert_equal(40, @dbrc.timeout)
110
+ assert_equal(3, @dbrc.max_reconn)
111
+ assert_equal("dbi:Oracle:foo", @dbrc.dsn)
112
+ end
113
+
114
+ # Same database, different user
115
+ def test_duplicate_database
116
+ db = DBRC::YML.new("foo", "user2", @dir)
117
+ assert_equal("user2", db.user)
118
+ assert_equal("pwd2", db.passwd)
119
+ assert_equal("OCI8", db.driver)
120
+ assert_equal(60, db.interval)
121
+ assert_equal(60, db.timeout)
122
+ assert_equal(4, db.max_reconn)
123
+ assert_equal("dbi:OCI8:foo", db.dsn)
124
+ end
125
+
126
+ # Different database, different user
127
+ def test_different_database
128
+ db = DBRC::YML.new("bar", "user1", @dir)
129
+ assert_equal("user1", db.user)
130
+ assert_equal("pwd3", db.passwd)
131
+ assert_equal("Oracle", db.driver)
132
+ assert_equal(30, db.interval)
133
+ assert_equal(30, db.timeout)
134
+ assert_equal(2, db.max_reconn)
135
+ assert_equal("dbi:Oracle:bar", db.dsn)
136
+ end
137
+
138
+ # A database with only a couple fields defined
139
+ def test_nil_values
140
+ db = DBRC::YML.new("baz", "user3", @dir)
141
+ assert_equal("user3", db.user)
142
+ assert_equal("pwd4", db.passwd)
143
+ assert_nil(db.driver)
144
+ assert_nil(db.interval)
145
+ assert_nil(db.timeout)
146
+ assert_nil(db.max_reconn)
147
+ assert_nil(db.dsn)
148
+ end
149
+
150
+ def teardown
151
+ @dir = nil
152
+ @db1 = nil
153
+ @db2 = nil
154
+ @user1 = nil
155
+ @user2 = nil
156
+ @db_bad = nil
157
+ @user_bad = nil
158
+ @dbrc = nil
159
+ end
160
+ end
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dbi-dbrc
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 1
9
+ - 7
10
+ version: 1.1.7
11
+ platform: x86-mingw32
12
+ authors:
13
+ - Daniel Berger
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-07 00:00:00 -06:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: sys-admin
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 7
30
+ segments:
31
+ - 1
32
+ - 5
33
+ - 2
34
+ version: 1.5.2
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: test-unit
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: win32-file
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 11
60
+ segments:
61
+ - 0
62
+ - 6
63
+ - 6
64
+ version: 0.6.6
65
+ type: :runtime
66
+ version_requirements: *id003
67
+ - !ruby/object:Gem::Dependency
68
+ name: win32-dir
69
+ prerelease: false
70
+ requirement: &id004 !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ hash: 29
76
+ segments:
77
+ - 0
78
+ - 3
79
+ - 7
80
+ version: 0.3.7
81
+ type: :runtime
82
+ version_requirements: *id004
83
+ - !ruby/object:Gem::Dependency
84
+ name: win32-process
85
+ prerelease: false
86
+ requirement: &id005 !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ - 6
95
+ - 2
96
+ version: 0.6.2
97
+ type: :runtime
98
+ version_requirements: *id005
99
+ description: " The dbi-dbrc library provides an interface for storing database\n connection information, including passwords, in a locally secure\n file only accessible by you, or root. This allows you to avoid\n hard coding login and password information in your programs\n that require such information.\n\n This library can also be used to store login and password information\n for logins on remote hosts, not just databases.\n"
100
+ email: djberg96@gmail.com
101
+ executables: []
102
+
103
+ extensions: []
104
+
105
+ extra_rdoc_files:
106
+ - README
107
+ - CHANGES
108
+ - MANIFEST
109
+ files:
110
+ - CHANGES
111
+ - dbi-dbrc.gemspec
112
+ - examples/plain/test.rb
113
+ - examples/xml/test_xml.rb
114
+ - examples/yml/test_yml.rb
115
+ - lib/dbi/dbrc.rb
116
+ - MANIFEST
117
+ - Rakefile
118
+ - README
119
+ - test/test_dbi_dbrc.rb
120
+ - test/test_dbi_dbrc_xml.rb
121
+ - test/test_dbi_dbrc_yml.rb
122
+ has_rdoc: true
123
+ homepage: http://www.rubyforge.org/projects/shards
124
+ licenses:
125
+ - Artistic 2.0
126
+ post_install_message:
127
+ rdoc_options: []
128
+
129
+ require_paths:
130
+ - lib
131
+ required_ruby_version: !ruby/object:Gem::Requirement
132
+ none: false
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ hash: 3
137
+ segments:
138
+ - 0
139
+ version: "0"
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ none: false
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ hash: 3
146
+ segments:
147
+ - 0
148
+ version: "0"
149
+ requirements: []
150
+
151
+ rubyforge_project: shards
152
+ rubygems_version: 1.3.7
153
+ signing_key:
154
+ specification_version: 3
155
+ summary: A simple way to avoid hard-coding passwords with DBI
156
+ test_files:
157
+ - test/test_dbi_dbrc.rb
158
+ - test/test_dbi_dbrc_xml.rb
159
+ - test/test_dbi_dbrc_yml.rb