Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Genki Sugawara
committed
Feb 24, 2016
1 parent
011510d
commit 2c8fb07
Showing
2 changed files
with
233 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
describe 'databases' do | ||
include SpecHelper | ||
|
||
subject { export_databases } | ||
|
||
before do | ||
apply_roles do | ||
<<-RUBY | ||
group "engineer" do | ||
user "bob" | ||
end | ||
group "staff" do | ||
user "alice" | ||
end | ||
RUBY | ||
end | ||
|
||
apply_databases do | ||
<<-RUBY | ||
role "alice" do | ||
database "#{SpecHelper::DBNAME}" do | ||
grant "CONNECT", :grantable => true | ||
grant "CREATE" | ||
end | ||
end | ||
RUBY | ||
end | ||
end | ||
|
||
context 'nothing to do' do | ||
it do | ||
expect( | ||
apply_databases do | ||
<<-RUBY | ||
role "alice" do | ||
database "#{SpecHelper::DBNAME}" do | ||
grant "CONNECT", :grantable => true | ||
grant "CREATE" | ||
end | ||
end | ||
RUBY | ||
end | ||
).to be_falsey | ||
|
||
is_expected.to eq <<-RUBY.unindent.chomp | ||
role "alice" do | ||
database "#{SpecHelper::DBNAME}" do | ||
grant "CONNECT", :grantable => true | ||
grant "CREATE" | ||
end | ||
end | ||
RUBY | ||
end | ||
end | ||
context 'when grant' do | ||
it do | ||
expect( | ||
apply_databases do | ||
<<-RUBY | ||
role "alice" do | ||
database "#{SpecHelper::DBNAME}" do | ||
grant "CONNECT", :grantable => true | ||
grant "CREATE" | ||
grant "TEMPORARY" | ||
end | ||
end | ||
role "bob" do | ||
database "#{SpecHelper::DBNAME}" do | ||
grant "CONNECT" | ||
grant "CREATE" | ||
grant "TEMPORARY" | ||
end | ||
end | ||
RUBY | ||
end | ||
).to be_truthy | ||
|
||
is_expected.to eq <<-RUBY.unindent.chomp | ||
role "alice" do | ||
database "#{SpecHelper::DBNAME}" do | ||
grant "CONNECT", :grantable => true | ||
grant "CREATE" | ||
grant "TEMPORARY" | ||
end | ||
end | ||
role "bob" do | ||
database "#{SpecHelper::DBNAME}" do | ||
grant "CONNECT" | ||
grant "CREATE" | ||
grant "TEMPORARY" | ||
end | ||
end | ||
RUBY | ||
end | ||
end | ||
|
||
context 'when revoke' do | ||
it do | ||
expect( | ||
apply_databases do | ||
<<-RUBY | ||
role "alice" do | ||
database "#{SpecHelper::DBNAME}" do | ||
grant "CONNECT", :grantable => true | ||
end | ||
end | ||
role "bob" do | ||
database "#{SpecHelper::DBNAME}" do | ||
grant "CONNECT" | ||
grant "CREATE" | ||
grant "TEMPORARY" | ||
end | ||
end | ||
RUBY | ||
end | ||
).to be_truthy | ||
|
||
is_expected.to eq <<-RUBY.unindent.chomp | ||
role "alice" do | ||
database "#{SpecHelper::DBNAME}" do | ||
grant "CONNECT", :grantable => true | ||
end | ||
end | ||
role "bob" do | ||
database "#{SpecHelper::DBNAME}" do | ||
grant "CONNECT" | ||
grant "CREATE" | ||
grant "TEMPORARY" | ||
end | ||
end | ||
RUBY | ||
end | ||
end | ||
|
||
context 'when revoke all' do | ||
it do | ||
expect( | ||
apply_databases do | ||
<<-RUBY | ||
role "bob" do | ||
database "#{SpecHelper::DBNAME}" do | ||
grant "CONNECT" | ||
grant "CREATE" | ||
grant "TEMPORARY" | ||
end | ||
end | ||
RUBY | ||
end | ||
).to be_truthy | ||
|
||
is_expected.to eq <<-RUBY.unindent.chomp | ||
role "bob" do | ||
database "#{SpecHelper::DBNAME}" do | ||
grant "CONNECT" | ||
grant "CREATE" | ||
grant "TEMPORARY" | ||
end | ||
end | ||
RUBY | ||
end | ||
end | ||
|
||
context 'when grant grant_option' do | ||
it do | ||
expect( | ||
apply_databases do | ||
<<-RUBY | ||
role "alice" do | ||
database "#{SpecHelper::DBNAME}" do | ||
grant "CONNECT", :grantable => true | ||
grant "CREATE", :grantable => true | ||
end | ||
end | ||
RUBY | ||
end | ||
).to be_truthy | ||
|
||
is_expected.to eq <<-RUBY.unindent.chomp | ||
role "alice" do | ||
database "#{SpecHelper::DBNAME}" do | ||
grant "CONNECT", :grantable => true | ||
grant "CREATE", :grantable => true | ||
end | ||
end | ||
RUBY | ||
end | ||
end | ||
|
||
context 'when revoke grant_option' do | ||
it do | ||
expect( | ||
apply_databases do | ||
<<-RUBY | ||
role "alice" do | ||
database "#{SpecHelper::DBNAME}" do | ||
grant "CONNECT" | ||
grant "CREATE" | ||
end | ||
end | ||
RUBY | ||
end | ||
).to be_truthy | ||
|
||
is_expected.to eq <<-RUBY.unindent.chomp | ||
role "alice" do | ||
database "#{SpecHelper::DBNAME}" do | ||
grant "CONNECT" | ||
grant "CREATE" | ||
end | ||
end | ||
RUBY | ||
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