Skip to content

Commit 2897573

Browse files
authored
Merge pull request #611 from johnnyshields/idp-parser-multi
IdpMetadataParser should always set idp_cert_multi, even when there is only one cert
2 parents 9b6d148 + ff0b803 commit 2897573

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

lib/onelogin/ruby-saml/idp_metadata_parser.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,10 @@ def merge_certificates_into(parsed_metadata)
421421
parsed_metadata[:idp_cert_fingerprint_algorithm]
422422
)
423423
end
424-
else
425-
# symbolize keys of certificates and pass it on
426-
parsed_metadata[:idp_cert_multi] = Hash[certificates.map { |k, v| [k.to_sym, v] }]
427424
end
425+
426+
# symbolize keys of certificates and pass it on
427+
parsed_metadata[:idp_cert_multi] = Hash[certificates.map { |k, v| [k.to_sym, v] }]
428428
end
429429

430430
def certificates_has_one(key)

test/idp_metadata_parser_test.rb

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,8 @@ def initialize; end
532532
@settings = @idp_metadata_parser.parse(@idp_metadata)
533533
end
534534

535-
it "should return idp_cert and idp_cert_fingerprint and no idp_cert_multi" do
536-
assert_equal "MIIEHjCCAwagAwIBAgIBATANBgkqhkiG9w0BAQUFADBnMQswCQYDVQQGEwJVUzET
535+
let(:expected_cert) do
536+
"MIIEHjCCAwagAwIBAgIBATANBgkqhkiG9w0BAQUFADBnMQswCQYDVQQGEwJVUzET
537537
MBEGA1UECAwKQ2FsaWZvcm5pYTEVMBMGA1UEBwwMU2FudGEgTW9uaWNhMREwDwYD
538538
VQQKDAhPbmVMb2dpbjEZMBcGA1UEAwwQYXBwLm9uZWxvZ2luLmNvbTAeFw0xMzA2
539539
MDUxNzE2MjBaFw0xODA2MDUxNzE2MjBaMGcxCzAJBgNVBAYTAlVTMRMwEQYDVQQI
@@ -555,13 +555,17 @@ def initialize; end
555555
sTk/bs9xcru5TPyLIxLLd6ib/pRceKH2mTkzUd0DYk9CQNXXeoGx/du5B9nh3ClP
556556
TbVakRzl3oswgI5MQIphYxkW70SopEh4kOFSRE1ND31NNIq1YrXlgtkguQBFsZWu
557557
QOPR6cEwFZzP0tHTYbI839WgxX6hfhIUTUz6mLqq4+3P4BG3+1OXeVDg63y8Uh78
558-
1sE=", @settings.idp_cert
559-
assert_equal "2D:A9:40:88:28:EE:67:BB:4A:5B:E0:58:A7:CC:71:95:2D:1B:C9:D3", @settings.idp_cert_fingerprint
560-
assert_nil @settings.idp_cert_multi
561-
assert_equal "https://app.onelogin.com/saml/metadata/383123", @settings.idp_entity_id
562-
assert_equal "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", @settings.name_identifier_format
563-
assert_equal "https://app.onelogin.com/trust/saml2/http-post/sso/383123", @settings.idp_sso_service_url
564-
assert_nil @settings.idp_slo_service_url
558+
1sE="
559+
end
560+
561+
it "should return idp_cert and idp_cert_fingerprint and no idp_cert_multi" do
562+
assert_equal(expected_cert, @settings.idp_cert)
563+
assert_equal("2D:A9:40:88:28:EE:67:BB:4A:5B:E0:58:A7:CC:71:95:2D:1B:C9:D3", @settings.idp_cert_fingerprint)
564+
assert_equal({ signing: [expected_cert], encryption: [expected_cert] }, @settings.idp_cert_multi)
565+
assert_equal("https://app.onelogin.com/saml/metadata/383123", @settings.idp_entity_id)
566+
assert_equal("urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress", @settings.name_identifier_format)
567+
assert_equal("https://app.onelogin.com/trust/saml2/http-post/sso/383123", @settings.idp_sso_service_url)
568+
assert_nil(@settings.idp_slo_service_url)
565569
end
566570
end
567571

@@ -638,7 +642,6 @@ def initialize; end
638642

639643
settings = idp_metadata_parser.parse(idp_different_slo_response_location)
640644

641-
642645
assert_equal "https://hello.example.com/access/saml/logout", settings.idp_slo_service_url
643646
assert_equal "https://hello.example.com/access/saml/logout/return", settings.idp_slo_response_service_url
644647
end
@@ -648,7 +651,6 @@ def initialize; end
648651

649652
settings = idp_metadata_parser.parse(idp_without_slo_response_location)
650653

651-
652654
assert_equal "https://hello.example.com/access/saml/logout", settings.idp_slo_service_url
653655
assert_nil settings.idp_slo_response_service_url
654656
end

0 commit comments

Comments
 (0)