gratan 0.1.9 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/gratan/identifier/auto.rb +10 -6
- data/lib/gratan/version.rb +1 -1
- data/spec/create/create_user_2_spec.rb +34 -0
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: e6c3096bfdfeb9445c63ceec07cbdfa922f12bb5
         | 
| 4 | 
            +
              data.tar.gz: abd97c6f20d52b0400e6f9bc5c4c79f4bbe0febe
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: da931e7f22cac224bd4ef1cdeae20b6d57c640713a5c1f0ffff9f01fc21872e1ff6b1464b641d9ea04e80c2d065c75359b9ad9b7cac78c5acf835a3d8db00ec4
         | 
| 7 | 
            +
              data.tar.gz: 42ce86462837e8dfbfcc75b0141bdc3bb68f1cda393798401066f5db57d6894895a01a53f793615c75ca707275a6415ef0a75084a1115a9a7fe4a3691495e217
         | 
| @@ -2,10 +2,12 @@ class Gratan::Identifier::Auto | |
| 2 2 | 
             
              def initialize(output, options = {})
         | 
| 3 3 | 
             
                @options = options
         | 
| 4 4 |  | 
| 5 | 
            -
                 | 
| 6 | 
            -
                   | 
| 7 | 
            -
             | 
| 8 | 
            -
                   | 
| 5 | 
            +
                unless @options[:dry_run]
         | 
| 6 | 
            +
                  if output == '-'
         | 
| 7 | 
            +
                    @output = $stdout
         | 
| 8 | 
            +
                  else
         | 
| 9 | 
            +
                    @output = open(output, 'w')
         | 
| 10 | 
            +
                  end
         | 
| 9 11 | 
             
                end
         | 
| 10 12 | 
             
              end
         | 
| 11 13 |  | 
| @@ -22,7 +24,9 @@ class Gratan::Identifier::Auto | |
| 22 24 | 
             
              end
         | 
| 23 25 |  | 
| 24 26 | 
             
              def puts_password(user, host, password)
         | 
| 25 | 
            -
                @output | 
| 26 | 
            -
             | 
| 27 | 
            +
                if @output
         | 
| 28 | 
            +
                  @output.puts("#{user}@#{host},#{password}")
         | 
| 29 | 
            +
                  @output.flush
         | 
| 30 | 
            +
                end
         | 
| 27 31 | 
             
              end
         | 
| 28 32 | 
             
            end
         | 
    
        data/lib/gratan/version.rb
    CHANGED
    
    
| @@ -36,6 +36,40 @@ end | |
| 36 36 | 
             
                end
         | 
| 37 37 | 
             
              end
         | 
| 38 38 |  | 
| 39 | 
            +
              context 'when create user with auto identify (dry-run)' do
         | 
| 40 | 
            +
                let(:auto_identifier) do
         | 
| 41 | 
            +
                  identifier = Gratan::Identifier::Auto.new('/dev/null')
         | 
| 42 | 
            +
                  allow(identifier).to receive(:mkpasswd) { 'foobarzoo' }
         | 
| 43 | 
            +
                  identifier
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                subject { client(identifier: auto_identifier, dry_run: true) }
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                it do
         | 
| 49 | 
            +
                  apply(subject) {
         | 
| 50 | 
            +
                    <<-RUBY
         | 
| 51 | 
            +
            user 'scott', 'localhost' do
         | 
| 52 | 
            +
              on '*.*' do
         | 
| 53 | 
            +
                grant 'SELECT'
         | 
| 54 | 
            +
                grant 'INSERT'
         | 
| 55 | 
            +
                grant 'UPDATE'
         | 
| 56 | 
            +
                grant 'DELETE'
         | 
| 57 | 
            +
              end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
              on 'test.*' do
         | 
| 60 | 
            +
                grant 'SELECT'
         | 
| 61 | 
            +
                grant 'INSERT'
         | 
| 62 | 
            +
                grant 'UPDATE'
         | 
| 63 | 
            +
                grant 'DELETE'
         | 
| 64 | 
            +
              end
         | 
| 65 | 
            +
            end
         | 
| 66 | 
            +
                    RUBY
         | 
| 67 | 
            +
                  }
         | 
| 68 | 
            +
             | 
| 69 | 
            +
                  expect(show_grants).to match_array []
         | 
| 70 | 
            +
                end
         | 
| 71 | 
            +
              end
         | 
| 72 | 
            +
             | 
| 39 73 | 
             
              context 'when create user with csv identify' do
         | 
| 40 74 | 
             
                let(:csv_identifier) do
         | 
| 41 75 | 
             
                  identifier = nil
         |