Skip to content

Commit aee0e01

Browse files
committed
Type mysql_grant was limited to work only with resource names foo@localhost/*.* or foo@localhost/bar.* but NOT with root@localhost/@ which is the parsed value of "GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION" grant line.
New spec test was created for the type mysql_grant.rb
1 parent fbfc5d8 commit aee0e01

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

lib/puppet/type/mysql_grant.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def initialize(*args)
4949
value.delete("`")
5050
end
5151

52-
newvalues(/.*\..*/)
52+
newvalues(/.*\..*/,/@/)
5353
end
5454

5555
newproperty(:user) do
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
require 'puppet'
2+
require 'puppet/type/mysql_grant'
3+
describe Puppet::Type.type(:mysql_grant) do
4+
5+
before :each do
6+
@user = Puppet::Type.type(:mysql_grant).new(:name => 'foo@localhost/*.*', :privileges => ['ALL', 'PROXY'], :table => ['*.*','@'], :user => 'foo@localhost')
7+
end
8+
9+
it 'should accept a grant name' do
10+
@user[:name].should == 'foo@localhost/*.*'
11+
end
12+
13+
it 'should accept ALL privileges' do
14+
@user[:privileges] = 'ALL'
15+
@user[:privileges].should == ['ALL']
16+
end
17+
18+
it 'should accept PROXY privilege' do
19+
@user[:privileges] = 'PROXY'
20+
@user[:privileges].should == ['PROXY']
21+
end
22+
23+
it 'should accept a table' do
24+
@user[:table] = '*.*'
25+
@user[:table].should == '*.*'
26+
end
27+
28+
it 'should accept @ for table' do
29+
@user[:table] = '@'
30+
@user[:table].should == '@'
31+
end
32+
33+
it 'should accept a user' do
34+
@user[:user] = 'foo@localhost'
35+
@user[:user].should == 'foo@localhost'
36+
end
37+
38+
it 'should require a name' do
39+
expect {
40+
Puppet::Type.type(:mysql_grant).new({})
41+
}.to raise_error(Puppet::Error, 'Title or name must be provided')
42+
end
43+
44+
end

0 commit comments

Comments
 (0)