Skip to content

Commit

Permalink
Update for frozen string compatibility
Browse files Browse the repository at this point in the history
This marks mutable strings to allow tests to pass with
    RUBYOPT="--enable-frozen-string-literal"
enabled.

This will be the default in future Ruby versions, so being compatible now is ideal.
  • Loading branch information
HParker committed Aug 29, 2024
1 parent 6e33ed3 commit 44b14ce
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/onelogin/ruby-saml/authrequest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def create_params(settings, params={})
request_doc = create_authentication_xml_doc(settings)
request_doc.context[:attribute_quote] = :quote if settings.double_quote_xml_attribute_values

request = ""
request = String.new
request_doc.write(request)

Logging.debug "Created AuthnRequest: #{request}"
Expand Down
2 changes: 1 addition & 1 deletion lib/onelogin/ruby-saml/logoutrequest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def create_params(settings, params={})
request_doc = create_logout_request_xml_doc(settings)
request_doc.context[:attribute_quote] = :quote if settings.double_quote_xml_attribute_values

request = ""
request = String.new
request_doc.write(request)

Logging.debug "Created SLO Logout Request: #{request}"
Expand Down
2 changes: 1 addition & 1 deletion lib/onelogin/ruby-saml/logoutresponse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def validate(collect_errors = false)
def validate_success_status
return true if success?

error_msg = 'The status code of the Logout Response was not Success'
error_msg = String.new('The status code of the Logout Response was not Success')
status_error_msg = OneLogin::RubySaml::Utils.status_error_msg(error_msg, status_code, status_message)
append_error(status_error_msg)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/onelogin/ruby-saml/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def embed_signature(meta_doc, settings)
end

def output_xml(meta_doc, pretty_print)
ret = ''
ret = String.new

# pretty print the XML so IdP administrators can easily see what the SP supports
if pretty_print
Expand Down
2 changes: 1 addition & 1 deletion lib/onelogin/ruby-saml/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def validate(collect_errors = false)
def validate_success_status
return true if success?

error_msg = 'The status code of the Response was not Success'
error_msg = +'The status code of the Response was not Success'
status_error_msg = OneLogin::RubySaml::Utils.status_error_msg(error_msg, status_code, status_message)
append_error(status_error_msg)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/onelogin/ruby-saml/slo_logoutresponse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def create_params(settings, request_id = nil, logout_message = nil, params = {},
response_doc = create_logout_response_xml_doc(settings, request_id, logout_message, logout_status_code)
response_doc.context[:attribute_quote] = :quote if settings.double_quote_xml_attribute_values

response = ""
response = String.new
response_doc.write(response)

Logging.debug "Created SLO Logout Response: #{response}"
Expand Down
2 changes: 1 addition & 1 deletion lib/onelogin/ruby-saml/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Utils
(\d+)W # 8: Weeks
)
$)x.freeze
UUID_PREFIX = '_'
UUID_PREFIX = String.new('_')

# Checks if the x509 cert provided is expired.
#
Expand Down
4 changes: 2 additions & 2 deletions test/utils_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,15 @@ def result(duration, reference = 0)

describe ".status_error_msg" do
it "returns a error msg with status_code and status message" do
error_msg = "The status code of the Logout Response was not Success"
error_msg = String.new("The status code of the Logout Response was not Success")
status_code = "urn:oasis:names:tc:SAML:2.0:status:Requester"
status_message = "The request could not be performed due to an error on the part of the requester."
status_error_msg = OneLogin::RubySaml::Utils.status_error_msg(error_msg, status_code, status_message)
assert_equal "The status code of the Logout Response was not Success, was Requester -> The request could not be performed due to an error on the part of the requester.", status_error_msg
end

it "returns a error msg with status_code" do
error_msg = "The status code of the Logout Response was not Success"
error_msg = String.new("The status code of the Logout Response was not Success")
status_code = "urn:oasis:names:tc:SAML:2.0:status:Requester"
status_error_msg = OneLogin::RubySaml::Utils.status_error_msg(error_msg, status_code)
assert_equal "The status code of the Logout Response was not Success, was Requester", status_error_msg
Expand Down

0 comments on commit 44b14ce

Please sign in to comment.