|
41 | 41 | end
|
42 | 42 |
|
43 | 43 | it 'should query set priviliges' do
|
44 |
| - provider_class.expects(:mysql).with(["--defaults-file=#{root_home}/.my.cnf", 'mysql', '-Be', 'select * from mysql.user where user="user" and host="host"']).returns <<-EOT |
| 44 | + provider_class.expects(:mysql).with(["--defaults-file=#{root_home}/.my.cnf", 'mysql', '-Be', "select * from mysql.user where user='user' and host='host'"]).returns <<-EOT |
45 | 45 | Host User Password Select_priv Insert_priv Update_priv
|
46 | 46 | host user Y N Y
|
47 | 47 | EOT
|
48 | 48 | @provider.privileges.should == [ 'Select_priv', 'Update_priv' ]
|
49 | 49 | end
|
50 | 50 |
|
51 | 51 | it 'should recognize when all priviliges are set' do
|
52 |
| - provider_class.expects(:mysql).with(["--defaults-file=#{root_home}/.my.cnf", 'mysql', '-Be', 'select * from mysql.user where user="user" and host="host"']).returns <<-EOT |
| 52 | + provider_class.expects(:mysql).with(["--defaults-file=#{root_home}/.my.cnf", 'mysql', '-Be', "select * from mysql.user where user='user' and host='host'"]).returns <<-EOT |
53 | 53 | Host User Password Select_priv Insert_priv Update_priv
|
54 | 54 | host user Y Y Y
|
55 | 55 | EOT
|
56 | 56 | @provider.all_privs_set?.should == true
|
57 | 57 | end
|
58 | 58 |
|
59 | 59 | it 'should recognize when all privileges are not set' do
|
60 |
| - provider_class.expects(:mysql).with(["--defaults-file=#{root_home}/.my.cnf", 'mysql', '-Be', 'select * from mysql.user where user="user" and host="host"']).returns <<-EOT |
| 60 | + provider_class.expects(:mysql).with(["--defaults-file=#{root_home}/.my.cnf", 'mysql', '-Be', "select * from mysql.user where user='user' and host='host'"]).returns <<-EOT |
61 | 61 | Host User Password Select_priv Insert_priv Update_priv
|
62 | 62 | host user Y N Y
|
63 | 63 | EOT
|
64 | 64 | @provider.all_privs_set?.should == false
|
65 | 65 | end
|
66 | 66 |
|
67 | 67 | it 'should be able to set all privileges' do
|
68 |
| - provider_class.expects(:mysql).with(["--defaults-file=#{root_home}/.my.cnf", 'mysql', '-NBe', 'SELECT "1" FROM user WHERE user="user" AND host="host"']).returns "1\n" |
69 |
| - provider_class.expects(:mysql).with(["--defaults-file=#{root_home}/.my.cnf", 'mysql', '-Be', "update user set Select_priv = 'Y', Insert_priv = 'Y', Update_priv = 'Y' where user=\"user\" and host=\"host\""]) |
| 68 | + provider_class.expects(:mysql).with(["--defaults-file=#{root_home}/.my.cnf", 'mysql', '-NBe', "SELECT '1' FROM user WHERE user='user' AND host='host'"]).returns "1\n" |
| 69 | + provider_class.expects(:mysql).with(["--defaults-file=#{root_home}/.my.cnf", 'mysql', '-Be', "update user set Select_priv = 'Y', Insert_priv = 'Y', Update_priv = 'Y' where user='user' and host='host'"]) |
70 | 70 | provider_class.expects(:mysqladmin).with(["--defaults-file=#{root_home}/.my.cnf", "flush-privileges"])
|
71 | 71 | @provider.privileges=(['all'])
|
72 | 72 | end
|
73 | 73 |
|
74 | 74 | it 'should be able to set partial privileges' do
|
75 |
| - provider_class.expects(:mysql).with(["--defaults-file=#{root_home}/.my.cnf", 'mysql', '-NBe', 'SELECT "1" FROM user WHERE user="user" AND host="host"']).returns "1\n" |
76 |
| - provider_class.expects(:mysql).with(["--defaults-file=#{root_home}/.my.cnf", 'mysql', '-Be', "update user set Select_priv = 'Y', Insert_priv = 'N', Update_priv = 'Y' where user=\"user\" and host=\"host\""]) |
| 75 | + provider_class.expects(:mysql).with(["--defaults-file=#{root_home}/.my.cnf", 'mysql', '-NBe', "SELECT '1' FROM user WHERE user='user' AND host='host'"]).returns "1\n" |
| 76 | + provider_class.expects(:mysql).with(["--defaults-file=#{root_home}/.my.cnf", 'mysql', '-Be', "update user set Select_priv = 'Y', Insert_priv = 'N', Update_priv = 'Y' where user='user' and host='host'"]) |
77 | 77 | provider_class.expects(:mysqladmin).with(["--defaults-file=#{root_home}/.my.cnf", "flush-privileges"])
|
78 | 78 | @provider.privileges=(['Select_priv', 'Update_priv'])
|
79 | 79 | end
|
80 | 80 |
|
81 | 81 | it 'should be case insensitive' do
|
82 |
| - provider_class.expects(:mysql).with(["--defaults-file=#{root_home}/.my.cnf", 'mysql', '-NBe', 'SELECT "1" FROM user WHERE user="user" AND host="host"']).returns "1\n" |
83 |
| - provider_class.expects(:mysql).with(["--defaults-file=#{root_home}/.my.cnf", 'mysql', '-Be', "update user set Select_priv = 'Y', Insert_priv = 'Y', Update_priv = 'Y' where user=\"user\" and host=\"host\""]) |
| 82 | + provider_class.expects(:mysql).with(["--defaults-file=#{root_home}/.my.cnf", 'mysql', '-NBe', "SELECT '1' FROM user WHERE user='user' AND host='host'"]).returns "1\n" |
| 83 | + provider_class.expects(:mysql).with(["--defaults-file=#{root_home}/.my.cnf", 'mysql', '-Be', "update user set Select_priv = 'Y', Insert_priv = 'Y', Update_priv = 'Y' where user='user' and host='host'"]) |
84 | 84 | provider_class.expects(:mysqladmin).with(["--defaults-file=#{root_home}/.my.cnf", 'flush-privileges'])
|
85 | 85 | @provider.privileges=(['SELECT_PRIV', 'insert_priv', 'UpDaTe_pRiV'])
|
86 | 86 | end
|
87 | 87 |
|
88 | 88 | it 'should not pass --defaults-file if $root_home/.my.cnf is absent' do
|
89 | 89 | File.stubs(:file?).with("#{root_home}/.my.cnf").returns(false)
|
90 |
| - provider_class.expects(:mysql).with(['mysql', '-NBe', 'SELECT "1" FROM user WHERE user="user" AND host="host"']).returns "1\n" |
91 |
| - provider_class.expects(:mysql).with(['mysql', '-Be', "update user set Select_priv = 'Y', Insert_priv = 'N', Update_priv = 'Y' where user=\"user\" and host=\"host\""]) |
| 90 | + provider_class.expects(:mysql).with(['mysql', '-NBe', "SELECT '1' FROM user WHERE user='user' AND host='host'"]).returns "1\n" |
| 91 | + provider_class.expects(:mysql).with(['mysql', '-Be', "update user set Select_priv = 'Y', Insert_priv = 'N', Update_priv = 'Y' where user='user' and host='host'"]) |
92 | 92 | provider_class.expects(:mysqladmin).with(["flush-privileges"])
|
93 | 93 | @provider.privileges=(['Select_priv', 'Update_priv'])
|
94 | 94 | end
|
|
0 commit comments