|
26 | 26 | before :each do
|
27 | 27 | # password hash = mypass
|
28 | 28 | @resource = Puppet::Type::Database_user.new(
|
29 |
| - { :password_hash => '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4', :name => 'joe@localhost' } |
| 29 | + { :password_hash => '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4', |
| 30 | + :name => 'joe@localhost', |
| 31 | + :max_user_connections => '10' |
| 32 | + } |
30 | 33 | )
|
31 | 34 | @provider = provider_class.new(@resource)
|
32 | 35 | Facter.stubs(:value).with(:root_home).returns(root_home)
|
|
46 | 49 |
|
47 | 50 | describe 'create' do
|
48 | 51 | it 'makes a user' do
|
49 |
| - subject.expects(:mysql).with([defaults_file, 'mysql', '-e', "create user 'joe'@'localhost' identified by PASSWORD '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4'"]) |
| 52 | + subject.expects(:mysql).with([defaults_file, 'mysql', '-e', "grant usage on *.* to 'joe'@'localhost' identified by PASSWORD |
| 53 | + '*6C8989366EAF75BB670AD8EA7A7FC1176A95CEF4' with max_user_connections 10"]) |
50 | 54 | @provider.expects(:exists?).returns(true)
|
51 | 55 | @provider.create.should be_true
|
52 | 56 | end
|
|
76 | 80 | end
|
77 | 81 | end
|
78 | 82 |
|
| 83 | + describe 'max_user_connections' do |
| 84 | + it 'returns max user connections' do |
| 85 | + subject.expects(:mysql).with([defaults_file, 'mysql', '-NBe', "select max_user_connections from mysql.user where CONCAT(user, '@', host) = 'joe@localhost'"]).returns('10') |
| 86 | + @provider.max_user_connections.should == '10' |
| 87 | + end |
| 88 | + end |
| 89 | + |
| 90 | + describe 'max_user_connections=' do |
| 91 | + it 'changes max user connections' do |
| 92 | + subject.expects(:mysql).with([defaults_file, 'mysql', '-e', "grant usage on *.* to 'joe'@'localhost' with max_user_connections 42"]).returns('0') |
| 93 | + @provider.expects(:max_user_connections).returns('42') |
| 94 | + @provider.max_user_connections=('42') |
| 95 | + end |
| 96 | + end |
| 97 | + |
79 | 98 | describe 'exists?' do
|
80 | 99 | it 'checks if user exists' do
|
81 | 100 | subject.expects(:mysql).with([defaults_file, 'mysql', '-NBe', "select '1' from mysql.user where CONCAT(user, '@', host) = 'joe@localhost'"]).returns('1')
|
|
0 commit comments