Skip to content

Commit f888f28

Browse files
committed
extend validation refactoring to SloLogoutrequest and Logoutresponse
1 parent ac66c1b commit f888f28

File tree

2 files changed

+23
-28
lines changed

2 files changed

+23
-28
lines changed

lib/onelogin/ruby-saml/logoutresponse.rb

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,20 @@ def status_message
110110
def validate(collect_errors = false)
111111
reset_errors!
112112

113-
if collect_errors
114-
valid_state?
115-
validate_success_status
116-
validate_structure
117-
valid_in_response_to?
118-
valid_issuer?
119-
validate_signature
113+
validations = [
114+
:valid_state?,
115+
:validate_success_status,
116+
:validate_structure,
117+
:valid_in_response_to?,
118+
:valid_issuer?,
119+
:validate_signature
120+
]
120121

122+
if collect_errors
123+
validations.each { |validation| send(validation) }
121124
@errors.empty?
122125
else
123-
valid_state? &&
124-
validate_success_status &&
125-
validate_structure &&
126-
valid_in_response_to? &&
127-
valid_issuer? &&
128-
validate_signature
126+
validations.all? { |validation| send(validation) }
129127
end
130128
end
131129

lib/onelogin/ruby-saml/slo_logoutrequest.rb

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,24 +126,21 @@ def session_indexes
126126
def validate(collect_errors = false)
127127
reset_errors!
128128

129-
if collect_errors
130-
validate_request_state
131-
validate_id
132-
validate_version
133-
validate_structure
134-
validate_not_on_or_after
135-
validate_issuer
136-
validate_signature
129+
validations = [
130+
:validate_request_state,
131+
:validate_id,
132+
:validate_version,
133+
:validate_structure,
134+
:validate_not_on_or_after,
135+
:validate_issuer,
136+
:validate_signature
137+
]
137138

139+
if collect_errors
140+
validations.each { |validation| send(validation) }
138141
@errors.empty?
139142
else
140-
validate_request_state &&
141-
validate_id &&
142-
validate_version &&
143-
validate_structure &&
144-
validate_not_on_or_after &&
145-
validate_issuer &&
146-
validate_signature
143+
validations.all? { |validation| send(validation) }
147144
end
148145
end
149146

0 commit comments

Comments
 (0)