kl-ruby-saml 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/Gemfile +3 -0
 - data/README.md +24 -24
 - data/Rakefile +1 -1
 - data/changelog.md +3 -3
 - data/kl-ruby-saml.gemspec +4 -4
 - data/lib/kl-ruby-saml.rb +1 -0
 - data/lib/onelogin/kl-ruby-saml.rb +17 -0
 - data/lib/onelogin/{ruby-saml → kl-ruby-saml}/attribute_service.rb +1 -1
 - data/lib/onelogin/{ruby-saml → kl-ruby-saml}/attributes.rb +1 -1
 - data/lib/onelogin/{ruby-saml → kl-ruby-saml}/authrequest.rb +7 -7
 - data/lib/onelogin/{ruby-saml → kl-ruby-saml}/http_error.rb +1 -1
 - data/lib/onelogin/{ruby-saml → kl-ruby-saml}/idp_metadata_parser.rb +3 -3
 - data/lib/onelogin/{ruby-saml → kl-ruby-saml}/logging.rb +3 -3
 - data/lib/onelogin/{ruby-saml → kl-ruby-saml}/logoutrequest.rb +7 -7
 - data/lib/onelogin/{ruby-saml → kl-ruby-saml}/logoutresponse.rb +7 -7
 - data/lib/onelogin/{ruby-saml → kl-ruby-saml}/metadata.rb +3 -3
 - data/lib/onelogin/{ruby-saml → kl-ruby-saml}/response.rb +9 -9
 - data/lib/onelogin/{ruby-saml → kl-ruby-saml}/saml_message.rb +2 -2
 - data/lib/onelogin/{ruby-saml → kl-ruby-saml}/settings.rb +6 -6
 - data/lib/onelogin/{ruby-saml → kl-ruby-saml}/slo_logoutrequest.rb +6 -6
 - data/lib/onelogin/{ruby-saml → kl-ruby-saml}/slo_logoutresponse.rb +7 -7
 - data/lib/onelogin/{ruby-saml → kl-ruby-saml}/utils.rb +1 -1
 - data/lib/onelogin/{ruby-saml → kl-ruby-saml}/validation_error.rb +1 -1
 - data/lib/onelogin/kl-ruby-saml/version.rb +5 -0
 - data/lib/xml_security.rb +5 -5
 - data/test/idp_metadata_parser_test.rb +7 -7
 - data/test/logging_test.rb +11 -11
 - data/test/logout_responses/logoutresponse_fixtures.rb +1 -1
 - data/test/logoutrequest_test.rb +17 -17
 - data/test/logoutresponse_test.rb +39 -39
 - data/test/metadata_test.rb +5 -5
 - data/test/request_test.rb +26 -26
 - data/test/response_test.rb +116 -116
 - data/test/saml_message_test.rb +4 -4
 - data/test/settings_test.rb +19 -19
 - data/test/slo_logoutrequest_test.rb +26 -26
 - data/test/slo_logoutresponse_test.rb +16 -16
 - data/test/test_helper.rb +3 -3
 - data/test/utils_test.rb +23 -23
 - data/test/xml_security_test.rb +17 -17
 - metadata +23 -23
 - data/lib/onelogin/ruby-saml.rb +0 -17
 - data/lib/onelogin/ruby-saml/version.rb +0 -5
 - data/lib/ruby-saml.rb +0 -1
 
    
        data/test/test_helper.rb
    CHANGED
    
    | 
         @@ -2,7 +2,7 @@ require 'simplecov' 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            SimpleCov.start do
         
     | 
| 
       4 
4 
     | 
    
         
             
              add_filter "test/"
         
     | 
| 
       5 
     | 
    
         
            -
              add_filter "lib/onelogin/ruby-saml/logging.rb"
         
     | 
| 
      
 5 
     | 
    
         
            +
              add_filter "lib/onelogin/kl-ruby-saml/logging.rb"
         
     | 
| 
       6 
6 
     | 
    
         
             
            end
         
     | 
| 
       7 
7 
     | 
    
         | 
| 
       8 
8 
     | 
    
         
             
            require 'stringio'
         
     | 
| 
         @@ -16,10 +16,10 @@ Bundler.require :default, :test 
     | 
|
| 
       16 
16 
     | 
    
         
             
            $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
         
     | 
| 
       17 
17 
     | 
    
         
             
            $LOAD_PATH.unshift(File.dirname(__FILE__))
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
            require 'onelogin/ruby-saml/logging'
         
     | 
| 
      
 19 
     | 
    
         
            +
            require 'onelogin/kl-ruby-saml/logging'
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
            TEST_LOGGER = Logger.new(StringIO.new)
         
     | 
| 
       22 
     | 
    
         
            -
            OneLogin:: 
     | 
| 
      
 22 
     | 
    
         
            +
            OneLogin::KlRubySaml::Logging.logger = TEST_LOGGER
         
     | 
| 
       23 
23 
     | 
    
         | 
| 
       24 
24 
     | 
    
         
             
            class Minitest::Test
         
     | 
| 
       25 
25 
     | 
    
         
             
              def fixture(document, base64 = true)
         
     | 
    
        data/test/utils_test.rb
    CHANGED
    
    | 
         @@ -8,31 +8,31 @@ class UtilsTest < Minitest::Test 
     | 
|
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
                it "returns empty string when the cert is an empty string" do
         
     | 
| 
       10 
10 
     | 
    
         
             
                  cert = ""
         
     | 
| 
       11 
     | 
    
         
            -
                  assert_equal "", OneLogin:: 
     | 
| 
      
 11 
     | 
    
         
            +
                  assert_equal "", OneLogin::KlRubySaml::Utils.format_cert(cert)
         
     | 
| 
       12 
12 
     | 
    
         
             
                end
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
                it "returns nil when the cert is nil" do
         
     | 
| 
       15 
15 
     | 
    
         
             
                  cert = nil
         
     | 
| 
       16 
     | 
    
         
            -
                  assert_equal nil, OneLogin:: 
     | 
| 
      
 16 
     | 
    
         
            +
                  assert_equal nil, OneLogin::KlRubySaml::Utils.format_cert(cert)
         
     | 
| 
       17 
17 
     | 
    
         
             
                end
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
                it "returns the certificate when it is valid" do
         
     | 
| 
       20 
     | 
    
         
            -
                  assert_equal formatted_certificate, OneLogin:: 
     | 
| 
      
 20 
     | 
    
         
            +
                  assert_equal formatted_certificate, OneLogin::KlRubySaml::Utils.format_cert(formatted_certificate)
         
     | 
| 
       21 
21 
     | 
    
         
             
                end
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
                it "reformats the certificate when there are spaces and no line breaks" do
         
     | 
| 
       24 
24 
     | 
    
         
             
                  invalid_certificate1 = read_certificate("invalid_certificate1")
         
     | 
| 
       25 
     | 
    
         
            -
                  assert_equal formatted_certificate, OneLogin:: 
     | 
| 
      
 25 
     | 
    
         
            +
                  assert_equal formatted_certificate, OneLogin::KlRubySaml::Utils.format_cert(invalid_certificate1)
         
     | 
| 
       26 
26 
     | 
    
         
             
                end
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
       28 
28 
     | 
    
         
             
                it "reformats the certificate when there are spaces and no headers" do
         
     | 
| 
       29 
29 
     | 
    
         
             
                  invalid_certificate2 = read_certificate("invalid_certificate2")
         
     | 
| 
       30 
     | 
    
         
            -
                  assert_equal formatted_certificate, OneLogin:: 
     | 
| 
      
 30 
     | 
    
         
            +
                  assert_equal formatted_certificate, OneLogin::KlRubySaml::Utils.format_cert(invalid_certificate2)
         
     | 
| 
       31 
31 
     | 
    
         
             
                end
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
                it "reformats the certificate when there line breaks and no headers" do
         
     | 
| 
       34 
34 
     | 
    
         
             
                  invalid_certificate3 = read_certificate("invalid_certificate3")
         
     | 
| 
       35 
     | 
    
         
            -
                  assert_equal formatted_certificate, OneLogin:: 
     | 
| 
      
 35 
     | 
    
         
            +
                  assert_equal formatted_certificate, OneLogin::KlRubySaml::Utils.format_cert(invalid_certificate3)
         
     | 
| 
       36 
36 
     | 
    
         
             
                end
         
     | 
| 
       37 
37 
     | 
    
         
             
              end
         
     | 
| 
       38 
38 
     | 
    
         | 
| 
         @@ -43,31 +43,31 @@ class UtilsTest < Minitest::Test 
     | 
|
| 
       43 
43 
     | 
    
         | 
| 
       44 
44 
     | 
    
         
             
                it "returns empty string when the private key is an empty string" do
         
     | 
| 
       45 
45 
     | 
    
         
             
                  private_key = ""
         
     | 
| 
       46 
     | 
    
         
            -
                  assert_equal "", OneLogin:: 
     | 
| 
      
 46 
     | 
    
         
            +
                  assert_equal "", OneLogin::KlRubySaml::Utils.format_private_key(private_key)
         
     | 
| 
       47 
47 
     | 
    
         
             
                end
         
     | 
| 
       48 
48 
     | 
    
         | 
| 
       49 
49 
     | 
    
         
             
                it "returns nil when the private key is nil" do
         
     | 
| 
       50 
50 
     | 
    
         
             
                  private_key = nil
         
     | 
| 
       51 
     | 
    
         
            -
                  assert_equal nil, OneLogin:: 
     | 
| 
      
 51 
     | 
    
         
            +
                  assert_equal nil, OneLogin::KlRubySaml::Utils.format_private_key(private_key)
         
     | 
| 
       52 
52 
     | 
    
         
             
                end
         
     | 
| 
       53 
53 
     | 
    
         | 
| 
       54 
54 
     | 
    
         
             
                it "returns the private key when it is valid" do
         
     | 
| 
       55 
     | 
    
         
            -
                  assert_equal formatted_private_key, OneLogin:: 
     | 
| 
      
 55 
     | 
    
         
            +
                  assert_equal formatted_private_key, OneLogin::KlRubySaml::Utils.format_private_key(formatted_private_key)
         
     | 
| 
       56 
56 
     | 
    
         
             
                end
         
     | 
| 
       57 
57 
     | 
    
         | 
| 
       58 
58 
     | 
    
         
             
                it "reformats the private key when there are spaces and no line breaks" do
         
     | 
| 
       59 
59 
     | 
    
         
             
                  invalid_private_key1 = read_certificate("invalid_private_key1")
         
     | 
| 
       60 
     | 
    
         
            -
                  assert_equal formatted_private_key, OneLogin:: 
     | 
| 
      
 60 
     | 
    
         
            +
                  assert_equal formatted_private_key, OneLogin::KlRubySaml::Utils.format_private_key(invalid_private_key1)
         
     | 
| 
       61 
61 
     | 
    
         
             
                end
         
     | 
| 
       62 
62 
     | 
    
         | 
| 
       63 
63 
     | 
    
         
             
                it "reformats the private key when there are spaces and no headers" do
         
     | 
| 
       64 
64 
     | 
    
         
             
                  invalid_private_key2 = read_certificate("invalid_private_key2")
         
     | 
| 
       65 
     | 
    
         
            -
                  assert_equal formatted_private_key, OneLogin:: 
     | 
| 
      
 65 
     | 
    
         
            +
                  assert_equal formatted_private_key, OneLogin::KlRubySaml::Utils.format_private_key(invalid_private_key2)
         
     | 
| 
       66 
66 
     | 
    
         
             
                end
         
     | 
| 
       67 
67 
     | 
    
         | 
| 
       68 
68 
     | 
    
         
             
                it "reformats the private key when there line breaks and no headers" do
         
     | 
| 
       69 
69 
     | 
    
         
             
                  invalid_private_key3 = read_certificate("invalid_private_key3")
         
     | 
| 
       70 
     | 
    
         
            -
                  assert_equal formatted_private_key, OneLogin:: 
     | 
| 
      
 70 
     | 
    
         
            +
                  assert_equal formatted_private_key, OneLogin::KlRubySaml::Utils.format_private_key(invalid_private_key3)
         
     | 
| 
       71 
71 
     | 
    
         
             
                end
         
     | 
| 
       72 
72 
     | 
    
         | 
| 
       73 
73 
     | 
    
         
             
                describe "an RSA public key" do
         
     | 
| 
         @@ -76,22 +76,22 @@ class UtilsTest < Minitest::Test 
     | 
|
| 
       76 
76 
     | 
    
         
             
                  end
         
     | 
| 
       77 
77 
     | 
    
         | 
| 
       78 
78 
     | 
    
         
             
                  it "returns the private key when it is valid" do
         
     | 
| 
       79 
     | 
    
         
            -
                    assert_equal formatted_rsa_private_key, OneLogin:: 
     | 
| 
      
 79 
     | 
    
         
            +
                    assert_equal formatted_rsa_private_key, OneLogin::KlRubySaml::Utils.format_private_key(formatted_rsa_private_key)
         
     | 
| 
       80 
80 
     | 
    
         
             
                  end
         
     | 
| 
       81 
81 
     | 
    
         | 
| 
       82 
82 
     | 
    
         
             
                  it "reformats the private key when there are spaces and no line breaks" do
         
     | 
| 
       83 
83 
     | 
    
         
             
                    invalid_rsa_private_key1 = read_certificate("invalid_rsa_private_key1")
         
     | 
| 
       84 
     | 
    
         
            -
                    assert_equal formatted_rsa_private_key, OneLogin:: 
     | 
| 
      
 84 
     | 
    
         
            +
                    assert_equal formatted_rsa_private_key, OneLogin::KlRubySaml::Utils.format_private_key(invalid_rsa_private_key1)
         
     | 
| 
       85 
85 
     | 
    
         
             
                  end
         
     | 
| 
       86 
86 
     | 
    
         | 
| 
       87 
87 
     | 
    
         
             
                  it "reformats the private key when there are spaces and no headers" do
         
     | 
| 
       88 
88 
     | 
    
         
             
                    invalid_rsa_private_key2 = read_certificate("invalid_rsa_private_key2")
         
     | 
| 
       89 
     | 
    
         
            -
                    assert_equal formatted_private_key, OneLogin:: 
     | 
| 
      
 89 
     | 
    
         
            +
                    assert_equal formatted_private_key, OneLogin::KlRubySaml::Utils.format_private_key(invalid_rsa_private_key2)
         
     | 
| 
       90 
90 
     | 
    
         
             
                  end
         
     | 
| 
       91 
91 
     | 
    
         | 
| 
       92 
92 
     | 
    
         
             
                  it "reformats the private key when there line breaks and no headers" do
         
     | 
| 
       93 
93 
     | 
    
         
             
                    invalid_rsa_private_key3 = read_certificate("invalid_rsa_private_key3")
         
     | 
| 
       94 
     | 
    
         
            -
                    assert_equal formatted_private_key, OneLogin:: 
     | 
| 
      
 94 
     | 
    
         
            +
                    assert_equal formatted_private_key, OneLogin::KlRubySaml::Utils.format_private_key(invalid_rsa_private_key3)
         
     | 
| 
       95 
95 
     | 
    
         
             
                  end
         
     | 
| 
       96 
96 
     | 
    
         
             
                end
         
     | 
| 
       97 
97 
     | 
    
         
             
              end
         
     | 
| 
         @@ -103,7 +103,7 @@ class UtilsTest < Minitest::Test 
     | 
|
| 
       103 
103 
     | 
    
         
             
                  params[:data] = "PHNhbWxwOkF1dGhuUmVxdWVzdCBEZXN0aW5hdGlvbj0naHR0cDovL2V4YW1wbGUuY29tP2ZpZWxkPXZhbHVlJyBJRD0nXzk4NmUxZDEwLWVhY2ItMDEzMi01MGRkLTAwOTBmNWRlZGQ3NycgSXNzdWVJbnN0YW50PScyMDE1LTA2LTAxVDIwOjM0OjU5WicgVmVyc2lvbj0nMi4wJyB4bWxuczpzYW1sPSd1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6YXNzZXJ0aW9uJyB4bWxuczpzYW1scD0ndXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOnByb3RvY29sJy8+"
         
     | 
| 
       104 
104 
     | 
    
         
             
                  params[:relay_state] = "http://example.com"
         
     | 
| 
       105 
105 
     | 
    
         
             
                  params[:sig_alg] = "http://www.w3.org/2000/09/xmldsig#rsa-sha1"
         
     | 
| 
       106 
     | 
    
         
            -
                  query_string = OneLogin:: 
     | 
| 
      
 106 
     | 
    
         
            +
                  query_string = OneLogin::KlRubySaml::Utils.build_query(params)
         
     | 
| 
       107 
107 
     | 
    
         
             
                  assert_equal "SAMLRequest=PHNhbWxwOkF1dGhuUmVxdWVzdCBEZXN0aW5hdGlvbj0naHR0cDovL2V4YW1wbGUuY29tP2ZpZWxkPXZhbHVlJyBJRD0nXzk4NmUxZDEwLWVhY2ItMDEzMi01MGRkLTAwOTBmNWRlZGQ3NycgSXNzdWVJbnN0YW50PScyMDE1LTA2LTAxVDIwOjM0OjU5WicgVmVyc2lvbj0nMi4wJyB4bWxuczpzYW1sPSd1cm46b2FzaXM6bmFtZXM6dGM6U0FNTDoyLjA6YXNzZXJ0aW9uJyB4bWxuczpzYW1scD0ndXJuOm9hc2lzOm5hbWVzOnRjOlNBTUw6Mi4wOnByb3RvY29sJy8%2B&RelayState=http%3A%2F%2Fexample.com&SigAlg=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23rsa-sha1", query_string
         
     | 
| 
       108 
108 
     | 
    
         
             
                end
         
     | 
| 
       109 
109 
     | 
    
         
             
              end
         
     | 
| 
         @@ -118,12 +118,12 @@ class UtilsTest < Minitest::Test 
     | 
|
| 
       118 
118 
     | 
    
         | 
| 
       119 
119 
     | 
    
         
             
                it "returns true when the signature is valid" do
         
     | 
| 
       120 
120 
     | 
    
         
             
                  @params[:signature] = "uWJm/T4gKLYEsVu1j/ZmjDeHp9zYPXPXWTXHFJZf2KKnWg57fUw3x2l6KTyRQ+Xjigb+sfYdGnnwmIz6KngXYRnh7nO6inspRLWOwkqQFy9iR9LDlMcfpXV/0g3oAxBxO6tX8MUHqR2R62SYZRGd1rxC9apg4vQiP97+atOI8t4="
         
     | 
| 
       121 
     | 
    
         
            -
                  assert OneLogin:: 
     | 
| 
      
 121 
     | 
    
         
            +
                  assert OneLogin::KlRubySaml::Utils.verify_signature(@params)
         
     | 
| 
       122 
122 
     | 
    
         
             
                end
         
     | 
| 
       123 
123 
     | 
    
         | 
| 
       124 
124 
     | 
    
         
             
                it "returns false when the signature is invalid" do
         
     | 
| 
       125 
125 
     | 
    
         
             
                  @params[:signature] = "uWJm/InVaLiDsVu1j/ZmjDeHp9zYPXPXWTXHFJZf2KKnWg57fUw3x2l6KTyRQ+Xjigb+sfYdGnnwmIz6KngXYRnh7nO6inspRLWOwkqQFy9iR9LDlMcfpXV/0g3oAxBxO6tX8MUHqR2R62SYZRGd1rxC9apg4vQiP97+atOI8t4="
         
     | 
| 
       126 
     | 
    
         
            -
                  assert !OneLogin:: 
     | 
| 
      
 126 
     | 
    
         
            +
                  assert !OneLogin::KlRubySaml::Utils.verify_signature(@params)
         
     | 
| 
       127 
127 
     | 
    
         
             
                end
         
     | 
| 
       128 
128 
     | 
    
         
             
              end
         
     | 
| 
       129 
129 
     | 
    
         | 
| 
         @@ -132,14 +132,14 @@ class UtilsTest < Minitest::Test 
     | 
|
| 
       132 
132 
     | 
    
         
             
                  error_msg = "The status code of the Logout Response was not Success"
         
     | 
| 
       133 
133 
     | 
    
         
             
                  status_code = "urn:oasis:names:tc:SAML:2.0:status:Requester"
         
     | 
| 
       134 
134 
     | 
    
         
             
                  status_message = "The request could not be performed due to an error on the part of the requester."
         
     | 
| 
       135 
     | 
    
         
            -
                  status_error_msg = OneLogin:: 
     | 
| 
      
 135 
     | 
    
         
            +
                  status_error_msg = OneLogin::KlRubySaml::Utils.status_error_msg(error_msg, status_code, status_message)
         
     | 
| 
       136 
136 
     | 
    
         
             
                  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
         
     | 
| 
       137 
137 
     | 
    
         | 
| 
       138 
     | 
    
         
            -
                  status_error_msg2 = OneLogin:: 
     | 
| 
      
 138 
     | 
    
         
            +
                  status_error_msg2 = OneLogin::KlRubySaml::Utils.status_error_msg(error_msg, status_code)
         
     | 
| 
       139 
139 
     | 
    
         
             
                  assert_equal = "The status code of the Logout Response was not Success, was Requester", status_error_msg2
         
     | 
| 
       140 
140 
     | 
    
         | 
| 
       141 
     | 
    
         
            -
                  status_error_msg3 =  OneLogin:: 
     | 
| 
      
 141 
     | 
    
         
            +
                  status_error_msg3 =  OneLogin::KlRubySaml::Utils.status_error_msg(error_msg)
         
     | 
| 
       142 
142 
     | 
    
         
             
                  assert_equal = "The status code of the Logout Response was not Success", status_error_msg3
         
     | 
| 
       143 
143 
     | 
    
         
             
                end
         
     | 
| 
       144 
144 
     | 
    
         
             
              end
         
     | 
| 
       145 
     | 
    
         
            -
            end
         
     | 
| 
      
 145 
     | 
    
         
            +
            end
         
     | 
    
        data/test/xml_security_test.rb
    CHANGED
    
    | 
         @@ -9,7 +9,7 @@ class XmlSecurityTest < Minitest::Test 
     | 
|
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
                let(:decoded_response) { Base64.decode64(response_document_without_recipient) }
         
     | 
| 
       11 
11 
     | 
    
         
             
                let(:document) { XMLSecurity::SignedDocument.new(decoded_response) }
         
     | 
| 
       12 
     | 
    
         
            -
                let(:settings) { OneLogin:: 
     | 
| 
      
 12 
     | 
    
         
            +
                let(:settings) { OneLogin::KlRubySaml::Settings.new() }
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
                before do
         
     | 
| 
       15 
15 
     | 
    
         
             
                  @base64cert = document.elements["//ds:X509Certificate"].text
         
     | 
| 
         @@ -20,7 +20,7 @@ class XmlSecurityTest < Minitest::Test 
     | 
|
| 
       20 
20 
     | 
    
         
             
                end
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
                it "should run validate with throwing NS related exceptions" do
         
     | 
| 
       23 
     | 
    
         
            -
                  assert_raises(OneLogin:: 
     | 
| 
      
 23 
     | 
    
         
            +
                  assert_raises(OneLogin::KlRubySaml::ValidationError) do
         
     | 
| 
       24 
24 
     | 
    
         
             
                    document.validate_signature(@base64cert, false)
         
     | 
| 
       25 
25 
     | 
    
         
             
                  end
         
     | 
| 
       26 
26 
     | 
    
         
             
                end
         
     | 
| 
         @@ -36,7 +36,7 @@ class XmlSecurityTest < Minitest::Test 
     | 
|
| 
       36 
36 
     | 
    
         
             
                end
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
38 
     | 
    
         
             
                it "should raise Fingerprint mismatch" do
         
     | 
| 
       39 
     | 
    
         
            -
                  exception = assert_raises(OneLogin:: 
     | 
| 
      
 39 
     | 
    
         
            +
                  exception = assert_raises(OneLogin::KlRubySaml::ValidationError) do
         
     | 
| 
       40 
40 
     | 
    
         
             
                    document.validate_document("no:fi:ng:er:pr:in:t", false)
         
     | 
| 
       41 
41 
     | 
    
         
             
                  end
         
     | 
| 
       42 
42 
     | 
    
         
             
                  assert_equal("Fingerprint mismatch", exception.message)
         
     | 
| 
         @@ -44,7 +44,7 @@ class XmlSecurityTest < Minitest::Test 
     | 
|
| 
       44 
44 
     | 
    
         
             
                end
         
     | 
| 
       45 
45 
     | 
    
         | 
| 
       46 
46 
     | 
    
         
             
                it "should raise Digest mismatch" do
         
     | 
| 
       47 
     | 
    
         
            -
                  exception = assert_raises(OneLogin:: 
     | 
| 
      
 47 
     | 
    
         
            +
                  exception = assert_raises(OneLogin::KlRubySaml::ValidationError) do
         
     | 
| 
       48 
48 
     | 
    
         
             
                    document.validate_signature(@base64cert, false)
         
     | 
| 
       49 
49 
     | 
    
         
             
                  end
         
     | 
| 
       50 
50 
     | 
    
         
             
                  assert_equal("Digest mismatch", exception.message)
         
     | 
| 
         @@ -56,7 +56,7 @@ class XmlSecurityTest < Minitest::Test 
     | 
|
| 
       56 
56 
     | 
    
         
             
                                "<ds:DigestValue>b9xsAXLsynugg3Wc1CI3kpWku+0=</ds:DigestValue>")
         
     | 
| 
       57 
57 
     | 
    
         
             
                  mod_document = XMLSecurity::SignedDocument.new(decoded_response)
         
     | 
| 
       58 
58 
     | 
    
         
             
                  base64cert = mod_document.elements["//ds:X509Certificate"].text
         
     | 
| 
       59 
     | 
    
         
            -
                  exception = assert_raises(OneLogin:: 
     | 
| 
      
 59 
     | 
    
         
            +
                  exception = assert_raises(OneLogin::KlRubySaml::ValidationError) do
         
     | 
| 
       60 
60 
     | 
    
         
             
                    mod_document.validate_signature(base64cert, false)
         
     | 
| 
       61 
61 
     | 
    
         
             
                  end
         
     | 
| 
       62 
62 
     | 
    
         
             
                  assert_equal("Key validation error", exception.message)
         
     | 
| 
         @@ -72,7 +72,7 @@ class XmlSecurityTest < Minitest::Test 
     | 
|
| 
       72 
72 
     | 
    
         
             
                it "raise validation error when the X509Certificate is missing" do
         
     | 
| 
       73 
73 
     | 
    
         
             
                  decoded_response.sub!(/<ds:X509Certificate>.*<\/ds:X509Certificate>/, "")
         
     | 
| 
       74 
74 
     | 
    
         
             
                  mod_document = XMLSecurity::SignedDocument.new(decoded_response)
         
     | 
| 
       75 
     | 
    
         
            -
                  exception = assert_raises(OneLogin:: 
     | 
| 
      
 75 
     | 
    
         
            +
                  exception = assert_raises(OneLogin::KlRubySaml::ValidationError) do
         
     | 
| 
       76 
76 
     | 
    
         
             
                    mod_document.validate_document("a fingerprint", false) # The fingerprint isn't relevant to this test
         
     | 
| 
       77 
77 
     | 
    
         
             
                  end
         
     | 
| 
       78 
78 
     | 
    
         
             
                  assert_equal("Certificate element missing in response (ds:X509Certificate)", exception.message)
         
     | 
| 
         @@ -126,7 +126,7 @@ class XmlSecurityTest < Minitest::Test 
     | 
|
| 
       126 
126 
     | 
    
         
             
              end
         
     | 
| 
       127 
127 
     | 
    
         | 
| 
       128 
128 
     | 
    
         
             
              describe "Fingerprint Algorithms" do
         
     | 
| 
       129 
     | 
    
         
            -
                let(:response_fingerprint_test) { OneLogin:: 
     | 
| 
      
 129 
     | 
    
         
            +
                let(:response_fingerprint_test) { OneLogin::KlRubySaml::Response.new(fixture(:adfs_response_sha1, false)) }
         
     | 
| 
       130 
130 
     | 
    
         | 
| 
       131 
131 
     | 
    
         
             
                it "validate using SHA1" do
         
     | 
| 
       132 
132 
     | 
    
         
             
                  sha1_fingerprint = "F1:3C:6B:80:90:5A:03:0E:6C:91:3E:5D:15:FA:DD:B0:16:45:48:72"
         
     | 
| 
         @@ -205,7 +205,7 @@ class XmlSecurityTest < Minitest::Test 
     | 
|
| 
       205 
205 
     | 
    
         | 
| 
       206 
206 
     | 
    
         
             
                  it 'support inclusive canonicalization' do
         
     | 
| 
       207 
207 
     | 
    
         
             
                    skip('test not yet implemented')
         
     | 
| 
       208 
     | 
    
         
            -
                    response = OneLogin:: 
     | 
| 
      
 208 
     | 
    
         
            +
                    response = OneLogin::KlRubySaml::Response.new(fixture("tdnf_response.xml"))
         
     | 
| 
       209 
209 
     | 
    
         
             
                    response.stubs(:conditions).returns(nil)
         
     | 
| 
       210 
210 
     | 
    
         
             
                    assert !response.is_valid?
         
     | 
| 
       211 
211 
     | 
    
         
             
                    assert !response.is_valid?
         
     | 
| 
         @@ -238,13 +238,13 @@ class XmlSecurityTest < Minitest::Test 
     | 
|
| 
       238 
238 
     | 
    
         | 
| 
       239 
239 
     | 
    
         | 
| 
       240 
240 
     | 
    
         
             
                  it "sign an AuthNRequest" do
         
     | 
| 
       241 
     | 
    
         
            -
                    request = OneLogin:: 
     | 
| 
      
 241 
     | 
    
         
            +
                    request = OneLogin::KlRubySaml::Authrequest.new.create_authentication_xml_doc(settings)
         
     | 
| 
       242 
242 
     | 
    
         
             
                    request.sign_document(ruby_saml_key, ruby_saml_cert)
         
     | 
| 
       243 
243 
     | 
    
         
             
                    # verify our signature
         
     | 
| 
       244 
244 
     | 
    
         
             
                    signed_doc = XMLSecurity::SignedDocument.new(request.to_s)
         
     | 
| 
       245 
245 
     | 
    
         
             
                    assert signed_doc.validate_document(ruby_saml_cert_fingerprint, false)
         
     | 
| 
       246 
246 
     | 
    
         | 
| 
       247 
     | 
    
         
            -
                    request2 = OneLogin:: 
     | 
| 
      
 247 
     | 
    
         
            +
                    request2 = OneLogin::KlRubySaml::Authrequest.new.create_authentication_xml_doc(settings)
         
     | 
| 
       248 
248 
     | 
    
         
             
                    request2.sign_document(ruby_saml_key, ruby_saml_cert_text)
         
     | 
| 
       249 
249 
     | 
    
         
             
                    # verify our signature
         
     | 
| 
       250 
250 
     | 
    
         
             
                    signed_doc2 = XMLSecurity::SignedDocument.new(request2.to_s)
         
     | 
| 
         @@ -252,7 +252,7 @@ class XmlSecurityTest < Minitest::Test 
     | 
|
| 
       252 
252 
     | 
    
         
             
                  end
         
     | 
| 
       253 
253 
     | 
    
         | 
| 
       254 
254 
     | 
    
         
             
                  it "sign an AuthNRequest with certificate as text" do
         
     | 
| 
       255 
     | 
    
         
            -
                    request = OneLogin:: 
     | 
| 
      
 255 
     | 
    
         
            +
                    request = OneLogin::KlRubySaml::Authrequest.new.create_authentication_xml_doc(settings)
         
     | 
| 
       256 
256 
     | 
    
         
             
                    request.sign_document(ruby_saml_key, ruby_saml_cert_text)
         
     | 
| 
       257 
257 
     | 
    
         | 
| 
       258 
258 
     | 
    
         
             
                    # verify our signature
         
     | 
| 
         @@ -261,13 +261,13 @@ class XmlSecurityTest < Minitest::Test 
     | 
|
| 
       261 
261 
     | 
    
         
             
                  end
         
     | 
| 
       262 
262 
     | 
    
         | 
| 
       263 
263 
     | 
    
         
             
                  it "sign a LogoutRequest" do
         
     | 
| 
       264 
     | 
    
         
            -
                    logout_request = OneLogin:: 
     | 
| 
      
 264 
     | 
    
         
            +
                    logout_request = OneLogin::KlRubySaml::Logoutrequest.new.create_logout_request_xml_doc(settings)
         
     | 
| 
       265 
265 
     | 
    
         
             
                    logout_request.sign_document(ruby_saml_key, ruby_saml_cert)
         
     | 
| 
       266 
266 
     | 
    
         
             
                    # verify our signature
         
     | 
| 
       267 
267 
     | 
    
         
             
                    signed_doc = XMLSecurity::SignedDocument.new(logout_request.to_s)
         
     | 
| 
       268 
268 
     | 
    
         
             
                    assert signed_doc.validate_document(ruby_saml_cert_fingerprint, false)
         
     | 
| 
       269 
269 
     | 
    
         | 
| 
       270 
     | 
    
         
            -
                    logout_request2 = OneLogin:: 
     | 
| 
      
 270 
     | 
    
         
            +
                    logout_request2 = OneLogin::KlRubySaml::Logoutrequest.new.create_logout_request_xml_doc(settings)
         
     | 
| 
       271 
271 
     | 
    
         
             
                    logout_request2.sign_document(ruby_saml_key, ruby_saml_cert_text)
         
     | 
| 
       272 
272 
     | 
    
         
             
                    # verify our signature
         
     | 
| 
       273 
273 
     | 
    
         
             
                    signed_doc2 = XMLSecurity::SignedDocument.new(logout_request2.to_s)
         
     | 
| 
         @@ -276,13 +276,13 @@ class XmlSecurityTest < Minitest::Test 
     | 
|
| 
       276 
276 
     | 
    
         
             
                  end
         
     | 
| 
       277 
277 
     | 
    
         | 
| 
       278 
278 
     | 
    
         
             
                  it "sign a LogoutResponse" do
         
     | 
| 
       279 
     | 
    
         
            -
                    logout_response = OneLogin:: 
     | 
| 
      
 279 
     | 
    
         
            +
                    logout_response = OneLogin::KlRubySaml::SloLogoutresponse.new.create_logout_response_xml_doc(settings, 'request_id_example', "Custom Logout Message")
         
     | 
| 
       280 
280 
     | 
    
         
             
                    logout_response.sign_document(ruby_saml_key, ruby_saml_cert)
         
     | 
| 
       281 
281 
     | 
    
         
             
                    # verify our signature
         
     | 
| 
       282 
282 
     | 
    
         
             
                    signed_doc = XMLSecurity::SignedDocument.new(logout_response.to_s)
         
     | 
| 
       283 
283 
     | 
    
         
             
                    assert signed_doc.validate_document(ruby_saml_cert_fingerprint, false)
         
     | 
| 
       284 
284 
     | 
    
         | 
| 
       285 
     | 
    
         
            -
                    logout_response2 = OneLogin:: 
     | 
| 
      
 285 
     | 
    
         
            +
                    logout_response2 = OneLogin::KlRubySaml::SloLogoutresponse.new.create_logout_response_xml_doc(settings, 'request_id_example', "Custom Logout Message")
         
     | 
| 
       286 
286 
     | 
    
         
             
                    logout_response2.sign_document(ruby_saml_key, ruby_saml_cert_text)
         
     | 
| 
       287 
287 
     | 
    
         
             
                    # verify our signature
         
     | 
| 
       288 
288 
     | 
    
         
             
                    signed_doc2 = XMLSecurity::SignedDocument.new(logout_response2.to_s)
         
     | 
| 
         @@ -292,10 +292,10 @@ class XmlSecurityTest < Minitest::Test 
     | 
|
| 
       292 
292 
     | 
    
         
             
                end
         
     | 
| 
       293 
293 
     | 
    
         | 
| 
       294 
294 
     | 
    
         
             
                describe "StarfieldTMS" do
         
     | 
| 
       295 
     | 
    
         
            -
                  let (:response) { OneLogin:: 
     | 
| 
      
 295 
     | 
    
         
            +
                  let (:response) { OneLogin::KlRubySaml::Response.new(fixture(:starfield_response)) }
         
     | 
| 
       296 
296 
     | 
    
         | 
| 
       297 
297 
     | 
    
         
             
                  before do
         
     | 
| 
       298 
     | 
    
         
            -
                    response.settings = OneLogin:: 
     | 
| 
      
 298 
     | 
    
         
            +
                    response.settings = OneLogin::KlRubySaml::Settings.new( :idp_cert_fingerprint => "8D:BA:53:8E:A3:B6:F9:F1:69:6C:BB:D9:D8:BD:41:B3:AC:4F:9D:4D")
         
     | 
| 
       299 
299 
     | 
    
         
             
                  end
         
     | 
| 
       300 
300 
     | 
    
         | 
| 
       301 
301 
     | 
    
         
             
                  it "be able to validate a good response" do
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,15 +1,15 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: kl-ruby-saml
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.4
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - OneLogin LLC
         
     | 
| 
       8 
     | 
    
         
            -
            - Knightlabs 
     | 
| 
      
 8 
     | 
    
         
            +
            - Knightlabs LLC
         
     | 
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2015-07- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2015-07-16 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: uuid
         
     | 
| 
         @@ -169,25 +169,25 @@ files: 
     | 
|
| 
       169 
169 
     | 
    
         
             
            - changelog.md
         
     | 
| 
       170 
170 
     | 
    
         
             
            - gemfiles/nokogiri-1.5.gemfile
         
     | 
| 
       171 
171 
     | 
    
         
             
            - kl-ruby-saml.gemspec
         
     | 
| 
       172 
     | 
    
         
            -
            - lib/ 
     | 
| 
       173 
     | 
    
         
            -
            - lib/onelogin/ruby-saml 
     | 
| 
       174 
     | 
    
         
            -
            - lib/onelogin/ruby-saml/ 
     | 
| 
       175 
     | 
    
         
            -
            - lib/onelogin/ruby-saml/ 
     | 
| 
       176 
     | 
    
         
            -
            - lib/onelogin/ruby-saml/ 
     | 
| 
       177 
     | 
    
         
            -
            - lib/onelogin/ruby-saml/ 
     | 
| 
       178 
     | 
    
         
            -
            - lib/onelogin/ruby-saml/ 
     | 
| 
       179 
     | 
    
         
            -
            - lib/onelogin/ruby-saml/ 
     | 
| 
       180 
     | 
    
         
            -
            - lib/onelogin/ruby-saml/ 
     | 
| 
       181 
     | 
    
         
            -
            - lib/onelogin/ruby-saml/ 
     | 
| 
       182 
     | 
    
         
            -
            - lib/onelogin/ruby-saml/ 
     | 
| 
       183 
     | 
    
         
            -
            - lib/onelogin/ruby-saml/ 
     | 
| 
       184 
     | 
    
         
            -
            - lib/onelogin/ruby-saml/ 
     | 
| 
       185 
     | 
    
         
            -
            - lib/onelogin/ruby-saml/ 
     | 
| 
       186 
     | 
    
         
            -
            - lib/onelogin/ruby-saml/ 
     | 
| 
       187 
     | 
    
         
            -
            - lib/onelogin/ruby-saml/ 
     | 
| 
       188 
     | 
    
         
            -
            - lib/onelogin/ruby-saml/ 
     | 
| 
       189 
     | 
    
         
            -
            - lib/onelogin/ruby-saml/ 
     | 
| 
       190 
     | 
    
         
            -
            - lib/ruby-saml.rb
         
     | 
| 
      
 172 
     | 
    
         
            +
            - lib/kl-ruby-saml.rb
         
     | 
| 
      
 173 
     | 
    
         
            +
            - lib/onelogin/kl-ruby-saml.rb
         
     | 
| 
      
 174 
     | 
    
         
            +
            - lib/onelogin/kl-ruby-saml/attribute_service.rb
         
     | 
| 
      
 175 
     | 
    
         
            +
            - lib/onelogin/kl-ruby-saml/attributes.rb
         
     | 
| 
      
 176 
     | 
    
         
            +
            - lib/onelogin/kl-ruby-saml/authrequest.rb
         
     | 
| 
      
 177 
     | 
    
         
            +
            - lib/onelogin/kl-ruby-saml/http_error.rb
         
     | 
| 
      
 178 
     | 
    
         
            +
            - lib/onelogin/kl-ruby-saml/idp_metadata_parser.rb
         
     | 
| 
      
 179 
     | 
    
         
            +
            - lib/onelogin/kl-ruby-saml/logging.rb
         
     | 
| 
      
 180 
     | 
    
         
            +
            - lib/onelogin/kl-ruby-saml/logoutrequest.rb
         
     | 
| 
      
 181 
     | 
    
         
            +
            - lib/onelogin/kl-ruby-saml/logoutresponse.rb
         
     | 
| 
      
 182 
     | 
    
         
            +
            - lib/onelogin/kl-ruby-saml/metadata.rb
         
     | 
| 
      
 183 
     | 
    
         
            +
            - lib/onelogin/kl-ruby-saml/response.rb
         
     | 
| 
      
 184 
     | 
    
         
            +
            - lib/onelogin/kl-ruby-saml/saml_message.rb
         
     | 
| 
      
 185 
     | 
    
         
            +
            - lib/onelogin/kl-ruby-saml/settings.rb
         
     | 
| 
      
 186 
     | 
    
         
            +
            - lib/onelogin/kl-ruby-saml/slo_logoutrequest.rb
         
     | 
| 
      
 187 
     | 
    
         
            +
            - lib/onelogin/kl-ruby-saml/slo_logoutresponse.rb
         
     | 
| 
      
 188 
     | 
    
         
            +
            - lib/onelogin/kl-ruby-saml/utils.rb
         
     | 
| 
      
 189 
     | 
    
         
            +
            - lib/onelogin/kl-ruby-saml/validation_error.rb
         
     | 
| 
      
 190 
     | 
    
         
            +
            - lib/onelogin/kl-ruby-saml/version.rb
         
     | 
| 
       191 
191 
     | 
    
         
             
            - lib/schemas/saml-schema-assertion-2.0.xsd
         
     | 
| 
       192 
192 
     | 
    
         
             
            - lib/schemas/saml-schema-authn-context-2.0.xsd
         
     | 
| 
       193 
193 
     | 
    
         
             
            - lib/schemas/saml-schema-authn-context-types-2.0.xsd
         
     | 
| 
         @@ -319,7 +319,7 @@ rubyforge_project: http://www.rubygems.org/gems/kl-ruby-saml 
     | 
|
| 
       319 
319 
     | 
    
         
             
            rubygems_version: 2.2.2
         
     | 
| 
       320 
320 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       321 
321 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       322 
     | 
    
         
            -
            summary:  
     | 
| 
      
 322 
     | 
    
         
            +
            summary: SAML Ruby Tookit
         
     | 
| 
       323 
323 
     | 
    
         
             
            test_files:
         
     | 
| 
       324 
324 
     | 
    
         
             
            - test/certificates/certificate1
         
     | 
| 
       325 
325 
     | 
    
         
             
            - test/certificates/certificate_without_head_foot
         
     | 
    
        data/lib/onelogin/ruby-saml.rb
    DELETED
    
    | 
         @@ -1,17 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'onelogin/ruby-saml/logging'
         
     | 
| 
       2 
     | 
    
         
            -
            require 'onelogin/ruby-saml/saml_message'
         
     | 
| 
       3 
     | 
    
         
            -
            require 'onelogin/ruby-saml/authrequest'
         
     | 
| 
       4 
     | 
    
         
            -
            require 'onelogin/ruby-saml/logoutrequest'
         
     | 
| 
       5 
     | 
    
         
            -
            require 'onelogin/ruby-saml/logoutresponse'
         
     | 
| 
       6 
     | 
    
         
            -
            require 'onelogin/ruby-saml/attributes'
         
     | 
| 
       7 
     | 
    
         
            -
            require 'onelogin/ruby-saml/slo_logoutrequest'
         
     | 
| 
       8 
     | 
    
         
            -
            require 'onelogin/ruby-saml/slo_logoutresponse'
         
     | 
| 
       9 
     | 
    
         
            -
            require 'onelogin/ruby-saml/response'
         
     | 
| 
       10 
     | 
    
         
            -
            require 'onelogin/ruby-saml/settings'
         
     | 
| 
       11 
     | 
    
         
            -
            require 'onelogin/ruby-saml/attribute_service'
         
     | 
| 
       12 
     | 
    
         
            -
            require 'onelogin/ruby-saml/http_error'
         
     | 
| 
       13 
     | 
    
         
            -
            require 'onelogin/ruby-saml/validation_error'
         
     | 
| 
       14 
     | 
    
         
            -
            require 'onelogin/ruby-saml/metadata'
         
     | 
| 
       15 
     | 
    
         
            -
            require 'onelogin/ruby-saml/idp_metadata_parser'
         
     | 
| 
       16 
     | 
    
         
            -
            require 'onelogin/ruby-saml/utils'
         
     | 
| 
       17 
     | 
    
         
            -
            require 'onelogin/ruby-saml/version'
         
     | 
    
        data/lib/ruby-saml.rb
    DELETED
    
    | 
         @@ -1 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'onelogin/ruby-saml'
         
     |