Sha256: c53beff48e7264a7d57dc5c96a8198cd0e07b8b3093d0b3c2c6cd0abc2dbfa70

Contents?: true

Size: 1.49 KB

Versions: 21

Compression:

Stored size: 1.49 KB

Contents

describe 'Gratan::Client#apply' do
  context 'when create user with target' do
    subject { client(target_user: /scott/) }

    it do
      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

user 'bob', '%', required: 'SSL' do
  on '*.*' do
    grant 'ALL PRIVILEGES'
  end

  on 'test.*' do
    grant 'SELECT'
  end
end
        RUBY
      }

      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

  context 'when create user with target (no change)' do
    subject { client(target_user: /mary/) }

    it do
      dsl = <<-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

user 'bob', '%', required: 'SSL' do
  on '*.*' do
    grant 'ALL PRIVILEGES'
  end

  on 'test.*' do
    grant 'SELECT'
  end
end
      RUBY

      result = apply(subject) { dsl }
      expect(result).to be_falsey

      expect(show_grants).to match_array []
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
gratan-0.3.1.beta2 spec/create/create_user_target_spec.rb
gratan-0.3.1.beta spec/create/create_user_target_spec.rb
gratan-0.3.0 spec/create/create_user_target_spec.rb
gratan-0.3.0.beta spec/create/create_user_target_spec.rb
gratan-0.2.9 spec/create/create_user_target_spec.rb
gratan-0.2.9.beta3 spec/create/create_user_target_spec.rb
gratan-0.2.9.beta2 spec/create/create_user_target_spec.rb
gratan-0.2.9.beta spec/create/create_user_target_spec.rb
gratan-0.2.8 spec/create/create_user_target_spec.rb
gratan-0.2.8.beta3 spec/create/create_user_target_spec.rb
gratan-0.2.8.beta2 spec/create/create_user_target_spec.rb
gratan-0.2.8.beta spec/create/create_user_target_spec.rb
gratan-0.2.7 spec/create/create_user_target_spec.rb
gratan-0.2.6 spec/create/create_user_target_spec.rb
gratan-0.2.5 spec/create/create_user_target_spec.rb
gratan-0.2.4 spec/create/create_user_target_spec.rb
gratan-0.2.3 spec/create/create_user_target_spec.rb
gratan-0.2.2 spec/create/create_user_target_spec.rb
gratan-0.2.1 spec/create/create_user_target_spec.rb
gratan-0.2.0 spec/create/create_user_target_spec.rb