Class: Cassy::Authenticators::Test

Inherits:
Base
  • Object
show all
Defined in:
lib/cassy/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).

Class Method Summary collapse

Methods inherited from Base

configure, extra_attributes, extra_attributes_to_extract, setup, #validate

Class Method Details

.find_user(*args) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/cassy/authenticators/test.rb', line 19

def self.find_user(*args)
  # To stop NotImplementedError raising
  @user = Object.new
  def @user.full_name
    "Example User"
  end
  @user
end

.full_nameObject



22
23
24
# File 'lib/cassy/authenticators/test.rb', line 22

def @user.full_name
  "Example User"
end

.validate(credentials) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/cassy/authenticators/test.rb', line 9

def self.validate(credentials)
  read_standard_credentials(credentials)

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

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

  return @password == valid_password
end