Skip to content

Commit

Permalink
Reuse the new configuration error in other places
Browse files Browse the repository at this point in the history
  • Loading branch information
janko committed Dec 12, 2024
1 parent d2dd801 commit 7ec0a54
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/rodauth/features/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ def hmac_secret_rotation?
end

def compute_raw_hmac(data)
raise ArgumentError, "hmac_secret not set" unless hmac_secret
raise ConfigurationError, "hmac_secret not set" unless hmac_secret
compute_raw_hmac_with_secret(data, hmac_secret)
end

Expand Down Expand Up @@ -885,7 +885,7 @@ def use_scope_clear_session?

def require_response(meth)
send(meth)
raise RuntimeError, "#{meth.to_s.sub(/\A_/, '')} overridden without returning a response (should use redirect or request.halt). This is a bug in your Rodauth configuration, not a bug in Rodauth itself."
raise ConfigurationError, "#{meth.to_s.sub(/\A_/, '')} overridden without returning a response (should use redirect or request.halt)."
end

def set_session_value(key, value)
Expand Down
2 changes: 1 addition & 1 deletion lib/rodauth/features/jwt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def clear_session
end

def jwt_secret
raise ArgumentError, "jwt_secret not set"
raise ConfigurationError, "jwt_secret not set"
end

def jwt_session_hash
Expand Down
2 changes: 1 addition & 1 deletion lib/rodauth/features/sms_codes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ def sms_new_confirm_code
end

def sms_send(phone, message)
raise NotImplementedError, "sms_send needs to be defined in the Rodauth configuration for SMS sending to work"
raise ConfigurationError, "sms_send needs to be defined in the Rodauth configuration for SMS sending to work"
end

def update_sms(values)
Expand Down
2 changes: 1 addition & 1 deletion spec/change_login_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,6 @@
visit '/change-login'
fill_in 'Login', :with=>'[email protected]'
fill_in 'Confirm Login', :with=>'[email protected]'
proc{click_button 'Change Login'}.must_raise RuntimeError
proc{click_button 'Change Login'}.must_raise Rodauth::ConfigurationError
end
end
2 changes: 1 addition & 1 deletion spec/login_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@
rodauth do
enable :login, :logout
json_response_custom_error_status? false
jwt_secret{proc{super()}.must_raise ArgumentError; "1"}
jwt_secret{proc{super()}.must_raise Rodauth::ConfigurationError; "1"}
end
roda(:jwt) do |r|
r.rodauth
Expand Down
2 changes: 1 addition & 1 deletion spec/rodauth_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ def foo
rodauth.compute_hmac("secret")
end

error = proc{visit "/"}.must_raise(ArgumentError)
error = proc{visit "/"}.must_raise(Rodauth::ConfigurationError)
error.message.must_equal "hmac_secret not set"
end

Expand Down
2 changes: 1 addition & 1 deletion spec/two_factor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def reset_otp_last_use
end

sms_send do |phone, msg|
proc{super(phone, msg)}.must_raise NotImplementedError
proc{super(phone, msg)}.must_raise Rodauth::ConfigurationError
sms_phone = phone
sms_message = msg
end
Expand Down

0 comments on commit 7ec0a54

Please sign in to comment.