Skip to content

Commit 7188030

Browse files
committed
Fix tests
1 parent fd41c69 commit 7188030

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@
1313
* [#709](https://github.com/SAML-Toolkits/ruby-saml/pull/709) Allow passing in `Net::HTTP` `:open_timeout`, `:read_timeout`, and `:max_retries` settings to `IdpMetadataParser#parse_remote`.
1414
* [#715](https://github.com/SAML-Toolkits/ruby-saml/pull/715) Fix typo in error when SPNameQualifier value does not match the SP entityID.
1515
* [#718](https://github.com/SAML-Toolkits/ruby-saml/pull/718) Add support to retrieve from SAMLResponse the AuthnInstant and AuthnContextClassRef values
16-
* [#711](https://github.com/SAML-Toolkits/ruby-saml/pull/711) Standardize how RubySaml reads and formats certificate and private_key PEM values, including the `RubySaml::Util#format_cert` and `#format_private_key` methods.
16+
* [#711](https://github.com/SAML-Toolkits/ruby-saml/pull/711) Standardize how RubySaml reads and formats certificate and private_key PEM values, including the `RubySaml::Utils#format_cert` and `#format_private_key` methods.
1717
* [#733](https://github.com/SAML-Toolkits/ruby-saml/pull/733) Allow `RubySaml::Utils.is_cert_expired` and `is_cert_active` to accept an optional time argument.
1818
* [#731](https://github.com/SAML-Toolkits/ruby-saml/pull/731) Add CI coverage for Ruby 3.4. Remove CI coverage for Ruby 1.x and 2.x.
19+
* [#735](https://github.com/SAML-Toolkits/ruby-saml/pull/735) Add `Settings#sp_uuid_prefix` and deprecate `Utils#set_prefix`.
1920

2021
### 1.18.0 (???)
2122
* [#718](https://github.com/SAML-Toolkits/ruby-saml/pull/718) Add support to retrieve from SAMLResponse the AuthnInstant and AuthnContextClassRef values

lib/ruby_saml/authrequest.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Authrequest < SamlMessage
2424
# @return [String] AuthNRequest string that includes the SAMLRequest
2525
#
2626
def create(settings, params = {})
27-
@uuid = RubySaml::Utils.generate_uuid(settings.sp_uuid_prefix)
27+
assign_uuid(settings)
2828
params = create_params(settings, params)
2929
params_prefix = /\?/.match?(settings.idp_sso_service_url) ? '&' : '?'
3030
saml_request = CGI.escape(params.delete("SAMLRequest"))
@@ -97,6 +97,7 @@ def create_authentication_xml_doc(settings)
9797

9898
def create_xml_document(settings)
9999
time = Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ")
100+
assign_uuid(settings)
100101

101102
request_doc = RubySaml::XML::Document.new
102103
request_doc.uuid = uuid
@@ -180,5 +181,9 @@ def sign_document(document, settings)
180181

181182
document
182183
end
184+
185+
def assign_uuid(settings)
186+
@uuid ||= RubySaml::Utils.generate_uuid(settings.sp_uuid_prefix)
187+
end
183188
end
184189
end

lib/ruby_saml/logoutrequest.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Logoutrequest < SamlMessage
2222
# @return [String] Logout Request string that includes the SAMLRequest
2323
#
2424
def create(settings, params={})
25-
@uuid = RubySaml::Utils.generate_uuid(settings.sp_uuid_prefix)
25+
assign_uuid(settings)
2626
params = create_params(settings, params)
2727
params_prefix = /\?/.match?(settings.idp_slo_service_url) ? '&' : '?'
2828
saml_request = CGI.escape(params.delete("SAMLRequest"))
@@ -95,6 +95,7 @@ def create_logout_request_xml_doc(settings)
9595

9696
def create_xml_document(settings)
9797
time = Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ")
98+
assign_uuid(settings)
9899

99100
request_doc = RubySaml::XML::Document.new
100101
request_doc.uuid = uuid
@@ -139,5 +140,9 @@ def sign_document(document, settings)
139140

140141
document
141142
end
143+
144+
def assign_uuid(settings)
145+
@uuid ||= RubySaml::Utils.generate_uuid(settings.sp_uuid_prefix)
146+
end
142147
end
143148
end

lib/ruby_saml/slo_logoutresponse.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class SloLogoutresponse < SamlMessage
2525
# @return [String] Logout Request string that includes the SAMLRequest
2626
#
2727
def create(settings, request_id = nil, logout_message = nil, params = {}, logout_status_code = nil)
28-
@uuid = RubySaml::Utils.generate_uuid(settings.sp_uuid_prefix)
28+
assign_uuid(settings)
2929
params = create_params(settings, request_id, logout_message, params, logout_status_code)
3030
params_prefix = /\?/.match?(settings.idp_slo_service_url) ? '&' : '?'
3131
url = settings.idp_slo_response_service_url || settings.idp_slo_service_url
@@ -106,6 +106,7 @@ def create_logout_response_xml_doc(settings, request_id = nil, logout_message =
106106

107107
def create_xml_document(settings, request_id = nil, logout_message = nil, status_code = nil)
108108
time = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
109+
assign_uuid(settings)
109110

110111
response_doc = RubySaml::XML::Document.new
111112
response_doc.uuid = uuid
@@ -149,5 +150,9 @@ def sign_document(document, settings)
149150

150151
document
151152
end
153+
154+
def assign_uuid(settings)
155+
@uuid ||= RubySaml::Utils.generate_uuid(settings.sp_uuid_prefix)
156+
end
152157
end
153158
end

lib/ruby_saml/utils.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ module Utils # rubocop:disable Metrics/ModuleLength
3333
UUID_DEFAULT_PREFIX = '_'
3434

3535
# @deprecated Use UUID_DEFAULT_PREFIX instead.
36+
# This constant is intentionally unfrozen for backwards compatibility.
3637
UUID_PREFIX = UUID_DEFAULT_PREFIX.dup
3738

3839
# Checks if the x509 cert provided is expired.

0 commit comments

Comments
 (0)