Class: MockAuthenticationSource
- Inherits:
-
Object
- Object
- MockAuthenticationSource
show all
- Includes:
- JSONModel
- Defined in:
- backend/spec/model_authentication_manager_spec.rb
Instance Method Summary
(collapse)
Methods included from JSONModel
JSONModel, #JSONModel, add_error_handler, all, allow_unmapped_enum_value, backend_url, client_mode?, custom_validations, destroy_model, enum_default_value, enum_values, handle_error, init, load_schema, #models, models, parse_jsonmodel_ref, parse_reference, repository, repository_for, schema_src, set_repository, strict_mode, strict_mode?, with_repository
Constructor Details
Returns a new instance of MockAuthenticationSource
6
7
8
|
# File 'backend/spec/model_authentication_manager_spec.rb', line 6
def initialize(opts)
@opts = opts
end
|
Instance Method Details
- (Object) authenticate(username, pass)
10
11
12
13
14
15
16
17
18
|
# File 'backend/spec/model_authentication_manager_spec.rb', line 10
def authenticate(username, pass)
raise "Boom" if @opts[:blowup]
user = @opts[:users][username]
if (user && user[:password] == pass)
JSONModel(:user).from_hash(:username => username, :name => "Mark")
end
end
|
- (Object) matching_usernames(query)
21
22
23
|
# File 'backend/spec/model_authentication_manager_spec.rb', line 21
def matching_usernames(query)
@opts[:users].keys.select {|username| username =~ /^#{query}/}
end
|
- (Object) name
26
27
28
|
# File 'backend/spec/model_authentication_manager_spec.rb', line 26
def name
"MockAuthenticationSource"
end
|