This repository has been archived by the owner on May 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from winebarrel/v0.2.7
v0.2.7
- Loading branch information
Showing
10 changed files
with
333 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module Gratan | ||
VERSION = '0.2.6' | ||
VERSION = '0.2.7' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
describe 'Gratan::Client#apply' do | ||
before(:each) do | ||
apply { | ||
<<-RUBY | ||
user 'scott', 'localhost', identified: 'tiger', required: 'SSL' do | ||
on '*.*' do | ||
grant 'SELECT' | ||
grant 'INSERT' | ||
end | ||
on 'test.*' do | ||
grant 'UPDATE' | ||
grant 'DELETE' | ||
end | ||
on 'mysql.user' do | ||
grant 'SELECT (user)' | ||
end | ||
end | ||
user 'bob', 'localhost' do | ||
on '*.*' do | ||
grant 'USAGE' | ||
end | ||
on 'test.*' do | ||
grant 'ALL PRIVILEGES' | ||
end | ||
end | ||
RUBY | ||
} | ||
end | ||
|
||
context 'when grant privs with ignore_object' do | ||
subject { client(ignore_object: /user/) } | ||
|
||
it do | ||
apply(subject) { | ||
<<-RUBY | ||
user 'scott', 'localhost', identified: 'tiger', required: 'SSL' do | ||
on '*.*' do | ||
grant 'SELECT' | ||
grant 'INSERT' | ||
grant 'UPDATE' | ||
grant 'DELETE' | ||
end | ||
on 'test.*' do | ||
grant 'SELECT' | ||
grant 'INSERT' | ||
grant 'UPDATE' | ||
grant 'DELETE' | ||
end | ||
on 'mysql.user' do | ||
grant 'SELECT (user)' | ||
grant 'UPDATE (host)' # ignore | ||
end | ||
end | ||
user 'bob', 'localhost' do | ||
on '*.*' do | ||
grant 'USAGE' | ||
end | ||
on 'test.*' do | ||
grant 'ALL PRIVILEGES' | ||
end | ||
end | ||
RUBY | ||
} | ||
|
||
expect(show_grants).to match_array [ | ||
"GRANT ALL PRIVILEGES ON `test`.* TO 'bob'@'localhost'", | ||
"GRANT SELECT (user) ON `mysql`.`user` TO 'scott'@'localhost'", | ||
"GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO 'scott'@'localhost' IDENTIFIED BY PASSWORD '*F2F68D0BB27A773C1D944270E5FAFED515A3FA40' REQUIRE SSL", | ||
"GRANT SELECT, INSERT, UPDATE, DELETE ON `test`.* TO 'scott'@'localhost'", | ||
"GRANT USAGE ON *.* TO 'bob'@'localhost'", | ||
] | ||
end | ||
end | ||
|
||
context 'when grant privs with ignore_object (2)' do | ||
subject { client(ignore_object: /user2/) } | ||
|
||
it do | ||
apply(subject) { | ||
<<-RUBY | ||
user 'scott', 'localhost', identified: 'tiger', required: 'SSL' do | ||
on '*.*' do | ||
grant 'SELECT' | ||
grant 'INSERT' | ||
grant 'UPDATE' | ||
grant 'DELETE' | ||
end | ||
on 'test.*' do | ||
grant 'SELECT' | ||
grant 'INSERT' | ||
grant 'UPDATE' | ||
grant 'DELETE' | ||
end | ||
on 'mysql.user' do | ||
grant 'SELECT (user)' | ||
grant 'UPDATE (host)' | ||
end | ||
end | ||
user 'bob', 'localhost' do | ||
on '*.*' do | ||
grant 'USAGE' | ||
end | ||
on 'test.*' do | ||
grant 'ALL PRIVILEGES' | ||
end | ||
end | ||
RUBY | ||
} | ||
|
||
expect(show_grants).to match_array [ | ||
"GRANT ALL PRIVILEGES ON `test`.* TO 'bob'@'localhost'", | ||
"GRANT SELECT (user), UPDATE (host) ON `mysql`.`user` TO 'scott'@'localhost'", | ||
"GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO 'scott'@'localhost' IDENTIFIED BY PASSWORD '*F2F68D0BB27A773C1D944270E5FAFED515A3FA40' REQUIRE SSL", | ||
"GRANT SELECT, INSERT, UPDATE, DELETE ON `test`.* TO 'scott'@'localhost'", | ||
"GRANT USAGE ON *.* TO 'bob'@'localhost'", | ||
] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
describe 'Gratan::Client#apply' do | ||
context 'when user does not exist' do | ||
subject { client } | ||
|
||
it do | ||
result = apply(subject) { '' } | ||
expect(result).to be_falsey | ||
expect(show_grants).to match_array [] | ||
end | ||
end | ||
|
||
context 'when create user with ignore_object' do | ||
subject { client(ignore_object: /test/) } | ||
|
||
it do | ||
result = apply(subject) { | ||
<<-RUBY | ||
user 'scott', 'localhost', identified: 'tiger' do | ||
on '*.*' do | ||
grant 'SELECT' | ||
grant 'INSERT' | ||
grant 'UPDATE' | ||
grant 'DELETE' | ||
end | ||
on 'test.*' do | ||
grant 'SELECT' | ||
grant 'INSERT' | ||
grant 'UPDATE' | ||
grant 'DELETE' | ||
end | ||
end | ||
RUBY | ||
} | ||
|
||
expect(result).to be_truthy | ||
|
||
expect(show_grants).to match_array [ | ||
"GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO 'scott'@'localhost' IDENTIFIED BY PASSWORD '*F2F68D0BB27A773C1D944270E5FAFED515A3FA40'", | ||
] | ||
end | ||
end | ||
|
||
context 'when create user with ignore_object (2)' do | ||
subject { client(ignore_object: /test2/) } | ||
|
||
it do | ||
result = apply(subject) { | ||
<<-RUBY | ||
user 'scott', 'localhost', identified: 'tiger' do | ||
on '*.*' do | ||
grant 'SELECT' | ||
grant 'INSERT' | ||
grant 'UPDATE' | ||
grant 'DELETE' | ||
end | ||
on 'test.*' do | ||
grant 'SELECT' | ||
grant 'INSERT' | ||
grant 'UPDATE' | ||
grant 'DELETE' | ||
end | ||
end | ||
RUBY | ||
} | ||
|
||
expect(result).to be_truthy | ||
|
||
expect(show_grants).to match_array [ | ||
"GRANT SELECT, INSERT, UPDATE, DELETE ON *.* TO 'scott'@'localhost' IDENTIFIED BY PASSWORD '*F2F68D0BB27A773C1D944270E5FAFED515A3FA40'", | ||
"GRANT SELECT, INSERT, UPDATE, DELETE ON `test`.* TO 'scott'@'localhost'", | ||
] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.