Sha256: 1d9efc6f1bc6431da7edecbb5886f608cfce3d4641ec61dd0d4699d53d17ec2c

Contents?: true

Size: 891 Bytes

Versions: 2

Compression:

Stored size: 891 Bytes

Contents

require 'io/console'

namespace :casino do
  namespace :authentication do
    desc 'Test authentication.'
    task test: :environment do |task, args|
      include CASino::ProcessorConcern::Authentication
      print "Username: "
      username = STDIN.gets.chomp
      print "Password (won't be shown): "
      password = STDIN.noecho(&:gets).chomp
      2.times { puts }
      puts "Testing credentials against #{authenticators.length} authenticators"
      authenticators.each do |authenticator_name, authenticator|
        puts "'#{authenticator_name}' (#{authenticator.class}):"
        print '  '
        begin
          if data = authenticator.validate(username, password)
            p data
          else
            puts "Invalid credentials"
          end
        rescue CASino::Authenticator::AuthenticatorError => e
          puts "#{e}"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
casino-4.0.0.pre.1 lib/casino/tasks/authentication.rake
casino-3.0.4 lib/casino/tasks/authentication.rake