Class: CASServer::Authenticators::Test

Inherits:
Base
  • Object
show all
Defined in:
lib/casserver/authenticators/test.rb

Overview

Dummy authenticator used for testing. Accepts any username as valid as long as the password is “testpassword”; otherwise authentication fails. Raises an AuthenticationError when username is “do_error” (this is useful to test the Exception handling functionality).

Instance Attribute Summary

Attributes inherited from Base

#options, #username

Instance Method Summary collapse

Methods inherited from Base

#configure, #extra_attributes, setup

Instance Method Details

#validate(credentials) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/casserver/authenticators/test.rb', line 9

def validate(credentials)
  read_standard_credentials(credentials)

  raise CASServer::AuthenticatorError, "Username is 'do_error'!" if @username == 'do_error'

  @extra_attributes[:test_utf_string] = "Ютф"
  @extra_attributes[:test_numeric] = 123.45
  @extra_attributes[:test_serialized] = {:foo => 'bar', :alpha => [1,2,3]}

  valid_password = options[:password] || "testpassword"

  return @password == valid_password
end