Sha256: e9ef238eb295134253bb8f67081baf834dac9b5b48f3631a317814482a37f20f
Contents?: true
Size: 1.99 KB
Versions: 3
Compression:
Stored size: 1.99 KB
Contents
#!/usr/bin/env ruby require './TestSetup' require 'test/unit' require 'rubygems' require 'rubyfb' include Rubyfb class RoleTest < Test::Unit::TestCase CURDIR = "#{Dir.getwd}" DB_FILE = "#{CURDIR}#{File::SEPARATOR}role_unit_test.fdb" def setup puts "#{self.class.name} started." if TEST_LOGGING # Remove existing database files. @database = Database.new(DB_FILE) if File.exist?(DB_FILE) @database.drop(DB_USER_NAME, DB_PASSWORD) end Database.create(DB_FILE, DB_USER_NAME, DB_PASSWORD) @sm = ServiceManager.new('localhost') @sm.connect(DB_USER_NAME, DB_PASSWORD) au = AddUser.new('user1', 'password', 'first', 'middle', 'last') au.execute(@sm) sleep(3) end def teardown ru = RemoveUser.new('user1') ru.execute(@sm) sleep(3) @sm.disconnect # Remove existing database files. if File.exist?(DB_FILE) @database.drop(DB_USER_NAME, DB_PASSWORD) end puts "#{self.class.name} finished." if TEST_LOGGING end def test01 cxn = @database.connect(DB_USER_NAME, DB_PASSWORD) cxn.execute_immediate('CREATE TABLE TEST (field1 INTEGER)') cxn.execute_immediate('CREATE role myrole') cxn.execute_immediate('GRANT myrole to user1') cxn.execute_immediate('GRANT ALL on TEST to myrole') cxn.close cxn = @database.connect('user1', 'password') assert_raise FireRubyException do t1 = cxn.start_transaction r = ResultSet.new(cxn, t1, "select * from test", 3, nil) r.fetch r.close t1.commit end cxn.close cxn = @database.connect('user1', 'password', {Connection::SQL_ROLE_NAME => "myrole"}) assert_nothing_raised do t1 = cxn.start_transaction r = ResultSet.new(cxn, t1, "select * from test", 3, nil) r.fetch r.close t1.commit end cxn.close end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rubyfb-0.5.7 | test/RoleTest.rb |
rubyfb-0.5.6 | test/RoleTest.rb |
rubyfb-0.5.5 | test/RoleTest.rb |