diff options
author | Azul <azul@leap.se> | 2013-02-06 14:29:44 +0100 |
---|---|---|
committer | Azul <azul@leap.se> | 2013-02-06 14:29:44 +0100 |
commit | 0362663decaa1c861b183ec3773f69952398a976 (patch) | |
tree | f5cecb371612a4ba579578d9f95b8b961fe47e12 | |
parent | 37d3a5b4fd06ff75d21740cf0f70d0eb0c43e586 (diff) | |
parent | 8fbee620476db018ca096f1a448dbfde9f9eb95a (diff) |
Merge remote-tracking branch 'leap/master'
-rw-r--r-- | README.md | 10 | ||||
-rw-r--r-- | certs/app/models/client_certificate.rb | 16 | ||||
-rw-r--r-- | certs/test/files/ca.crt | 25 | ||||
-rw-r--r-- | certs/test/files/ca.key | 30 | ||||
-rw-r--r-- | certs/test/unit/client_certificate_test.rb | 5 | ||||
-rw-r--r-- | help/app/controllers/tickets_controller.rb | 2 | ||||
-rw-r--r-- | help/test/functional/tickets_controller_test.rb | 2 |
7 files changed, 52 insertions, 38 deletions
@@ -66,3 +66,13 @@ Then open http://localhost:3000 in your web browser. To peruse the database, visit http://localhost:5984/_utils/ +Testing +-------------------------------- + +To run all tests + + rake test + +To run an individual test: + + rake test TEST=certs/test/unit/client_certificate_test.rb
\ No newline at end of file diff --git a/certs/app/models/client_certificate.rb b/certs/app/models/client_certificate.rb index 9cde820..be0ac63 100644 --- a/certs/app/models/client_certificate.rb +++ b/certs/app/models/client_certificate.rb @@ -73,13 +73,13 @@ class ClientCertificate { "digest" => APP_CONFIG[:client_cert_hash], "extensions" => { - "keyUsage" => { - "usage" => ["digitalSignature"] - }, - "extendedKeyUsage" => { - "usage" => ["clientAuth"] - } - } + "keyUsage" => { + "usage" => ["digitalSignature"] + }, + "extendedKeyUsage" => { + "usage" => ["clientAuth"] + } + } } end @@ -91,7 +91,7 @@ class ClientCertificate ## def yesterday - t = Time.now - 24*24*60 + t = Time.now - 24*60*60 Time.utc t.year, t.month, t.day end diff --git a/certs/test/files/ca.crt b/certs/test/files/ca.crt index cade598..8393eee 100644 --- a/certs/test/files/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CXRlc3QgbmFtZTCBqDAN +BgkqhkiG9w0BAQEFAAOBlgAwgZICgYoAx076Dz8zswvCLuz0HP3Y3PWOgFDo9+8o +H4uXRcTpd+yw+5B79xjtQ7ojQy2465Jq00nkzHI6V1otM2uvVVIOcNk0t1HEjmK0 +T/r96dDHc59YvVQ+XPrzuQ4t3iREy8IAPNbc3r29PVZkMdGpeSYxyY1mUKza4DcY +My4SVko9pcP8zJBD4bHgEa0CAwEAAaNgMF4wHQYDVR0OBBYEFOQ+d2EUwBpi93TJ +9AX4Okew5/UIMA4GA1UdDwEB/wQEAwICBDAMBgNVHRMEBTADAQH/MB8GA1UdIwQY +MBaAFOQ+d2EUwBpi93TJ9AX4Okew5/UIMA0GCSqGSIb3DQEBDQUAA4GKAJW9/39P +VbVjH9C7F0XMOpd9nWBe9NUoiw36ZFZw95dqfUm6j5f3nejWG4lEtyMFu5i5rAw6 +GdDSXmq4sUqWTaJmQmZyY+WggQR4UGWJ0I18HRDiPxuA++OfkGzA20Gmvk+CIw/J +QLHlVjLyyUwaA+EO88rEcdc9VnGL/Xgjh8C/PYH2DpWw/kJa -----END CERTIFICATE----- diff --git a/certs/test/files/ca.key b/certs/test/files/ca.key index d266ef7..125997f 100644 --- a/certs/test/files/ca.key +++ b/certs/test/files/ca.key @@ -1,18 +1,16 @@ -----BEGIN RSA PRIVATE KEY----- -MIIC2gIBAAKBnQCl6oIZA6aIfEIXGx9QqYFXqu45hqsSx6kUDJxOaZqRcGM2PgH0 -93eATcJznqu+SrS7GW5G+qynOkQ5CkKDwzl+R+39/FJpzD5pySPfKzuvQyteAvrp -B4uc0Z7z5GME7xQdvc4/HnjuGpQdWD7cepIJ2f1wZBf3/8QmudImwu5nD2S2Q3hi -3J3V15mjoCSIh4LLPQfEpAEiF0kA9GUCAwEAAQKBnAKz9FSgqO42Sq6tBBtAolkh -nBSXK2L4mmTiOQr/UMOnzLtN0qMBWRK1Bu2dRcz+0zztEs0t45wsfdS0DxYDGy+s -elBrSOhs/w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F8jLw9IDMkr9kkfT+n03p8sOd4g7iSw0sknlzaZZpIDvibkyN +SDKM7VX4VQa7u58+sCF4ylwi0UQu7/VT7Smp4QJFDJSoEOKplBvaT9fTfdVKjE4P +QyCAWEsb6Up8KKswhtDqiWeFtktIvx1Mkxn25erLms3cUEBde//rwNB+6ItBR/N8 +4RlNAkUPLsc3Gn+7gmFQ7r3U3zViboON0B/wiWcUjJsQzR6zdoBCvg0+VwsOIniG +ubjbI1uZUGHHg/SYn4KQOm4DwlgF7aDkxQECRQjVZMEedlXxzLOdZvoHBuZHdT38 +F0Jn0rxXOaDQuy0eimBamS+r4vOWngr4Az3jRH15KMYMu9dyllX3z/R2uyrLVBc2 +TQJFBEHIjoMVgP2h+N6VUDgPOhnxnnLvowOtX23J1y2foKwfZrHH38LNcWmuaGUi +fz6EYeUO20D174GfhqB0j6yR50ejPjYD -----END RSA PRIVATE KEY----- diff --git a/certs/test/unit/client_certificate_test.rb b/certs/test/unit/client_certificate_test.rb index 492a44a..71a1d90 100644 --- a/certs/test/unit/client_certificate_test.rb +++ b/certs/test/unit/client_certificate_test.rb @@ -11,4 +11,9 @@ class ClientCertificateTest < ActiveSupport::TestCase assert @sample.cert end + test "cert issuer matches ca subject" do + cert = OpenSSL::X509::Certificate.new(@sample.cert) + assert_equal ClientCertificate.root_ca.openssl_body.subject, cert.issuer + end + end diff --git a/help/app/controllers/tickets_controller.rb b/help/app/controllers/tickets_controller.rb index d5a3da7..6562048 100644 --- a/help/app/controllers/tickets_controller.rb +++ b/help/app/controllers/tickets_controller.rb @@ -18,7 +18,7 @@ class TicketsController < ApplicationController @ticket.comments.last.posted_by = (logged_in? ? current_user.id : nil) #protecting posted_by isn't working, so this should protect it. @ticket.created_by = current_user.id if logged_in? - @ticket.email = current_user.email if logged_in? and current_user.email + @ticket.email = current_user.email_address if logged_in? and current_user.email_address flash[:notice] = 'Ticket was successfully created.' if @ticket.save diff --git a/help/test/functional/tickets_controller_test.rb b/help/test/functional/tickets_controller_test.rb index 0c462a9..f8627d8 100644 --- a/help/test/functional/tickets_controller_test.rb +++ b/help/test/functional/tickets_controller_test.rb @@ -89,7 +89,7 @@ class TicketsControllerTest < ActionController::TestCase assert_not_nil assigns(:ticket).created_by assert_equal assigns(:ticket).created_by, @current_user.id - assert_equal assigns(:ticket).email, @current_user.email + assert_equal assigns(:ticket).email, @current_user.email_address.email assert_equal 1, assigns(:ticket).comments.count assert_not_nil assigns(:ticket).comments.first.posted_by |