casino_core-authenticator-activerecord 1.0.1 → 1.1.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.
| 
         @@ -4,17 +4,21 @@ require 'bcrypt' 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            class CASinoCore::Authenticator::ActiveRecord
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
      
 7 
     | 
    
         
            +
              class AuthDatabase < ::ActiveRecord::Base
         
     | 
| 
      
 8 
     | 
    
         
            +
                self.abstract_class = true
         
     | 
| 
      
 9 
     | 
    
         
            +
              end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
       7 
11 
     | 
    
         
             
              # @param [Hash] options
         
     | 
| 
       8 
12 
     | 
    
         
             
              def initialize(options)
         
     | 
| 
       9 
13 
     | 
    
         
             
                @options = options
         
     | 
| 
       10 
     | 
    
         
            -
                ::ActiveRecord::Base.establish_connection @options[:connection]
         
     | 
| 
       11 
14 
     | 
    
         | 
| 
       12 
15 
     | 
    
         
             
                eval <<-END
         
     | 
| 
       13 
     | 
    
         
            -
                  class #{self.class.to_s}::#{@options[:table].classify} <  
     | 
| 
      
 16 
     | 
    
         
            +
                  class #{self.class.to_s}::#{@options[:table].classify} < AuthDatabase
         
     | 
| 
       14 
17 
     | 
    
         
             
                  end
         
     | 
| 
       15 
18 
     | 
    
         
             
                END
         
     | 
| 
       16 
19 
     | 
    
         | 
| 
       17 
20 
     | 
    
         
             
                @model = "#{self.class.to_s}::#{@options[:table].classify}".constantize
         
     | 
| 
      
 21 
     | 
    
         
            +
                @model.establish_connection @options[:connection]
         
     | 
| 
       18 
22 
     | 
    
         
             
              end
         
     | 
| 
       19 
23 
     | 
    
         | 
| 
       20 
24 
     | 
    
         
             
              def validate(username, password)
         
     | 
| 
         @@ -7,7 +7,7 @@ describe CASinoCore::Authenticator::ActiveRecord do 
     | 
|
| 
       7 
7 
     | 
    
         
             
                {
         
     | 
| 
       8 
8 
     | 
    
         
             
                  connection: {
         
     | 
| 
       9 
9 
     | 
    
         
             
                    adapter: 'sqlite3',
         
     | 
| 
       10 
     | 
    
         
            -
                    database: ' 
     | 
| 
      
 10 
     | 
    
         
            +
                    database: '/tmp/casino-test-auth.sqlite'
         
     | 
| 
       11 
11 
     | 
    
         
             
                  },
         
     | 
| 
       12 
12 
     | 
    
         
             
                  table: 'users',
         
     | 
| 
       13 
13 
     | 
    
         
             
                  username_column: 'username',
         
     | 
| 
         @@ -19,9 +19,10 @@ describe CASinoCore::Authenticator::ActiveRecord do 
     | 
|
| 
       19 
19 
     | 
    
         
             
              end
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
              before do
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
22 
     | 
    
         
             
                @authenticator = CASinoCore::Authenticator::ActiveRecord.new(options)
         
     | 
| 
       24 
23 
     | 
    
         | 
| 
      
 24 
     | 
    
         
            +
                ::ActiveRecord::Base.establish_connection options[:connection]
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
       25 
26 
     | 
    
         
             
                ActiveRecord::Migration.suppress_messages do
         
     | 
| 
       26 
27 
     | 
    
         
             
                  ActiveRecord::Schema.define do
         
     | 
| 
       27 
28 
     | 
    
         
             
                    create_table :users do |t|
         
     | 
| 
         @@ -38,6 +39,14 @@ describe CASinoCore::Authenticator::ActiveRecord do 
     | 
|
| 
       38 
39 
     | 
    
         
             
                  mail_address: 'mail@example.org')
         
     | 
| 
       39 
40 
     | 
    
         
             
              end
         
     | 
| 
       40 
41 
     | 
    
         | 
| 
      
 42 
     | 
    
         
            +
              after do
         
     | 
| 
      
 43 
     | 
    
         
            +
                ActiveRecord::Migration.suppress_messages do
         
     | 
| 
      
 44 
     | 
    
         
            +
                  ActiveRecord::Schema.define do
         
     | 
| 
      
 45 
     | 
    
         
            +
                    drop_table :users
         
     | 
| 
      
 46 
     | 
    
         
            +
                  end
         
     | 
| 
      
 47 
     | 
    
         
            +
                end
         
     | 
| 
      
 48 
     | 
    
         
            +
              end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
       41 
50 
     | 
    
         
             
              describe '#validate' do
         
     | 
| 
       42 
51 
     | 
    
         | 
| 
       43 
52 
     | 
    
         
             
                context 'valid username' do
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: casino_core-authenticator-activerecord
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.0 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.1.0
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -10,7 +10,7 @@ authors: 
     | 
|
| 
       10 
10 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       11 
11 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       12 
12 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       13 
     | 
    
         
            -
            date: 2013-02- 
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2013-02-22 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies:
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
16 
     | 
    
         
             
              name: rake
         
     |