Sha256: 0dd7da25e4d302a19c2634be5ebc9e1cd2a79c61746355b11719a268caecbacc

Contents?: true

Size: 1.39 KB

Versions: 5

Compression:

Stored size: 1.39 KB

Contents

require "bundler/setup"
require "bundler/gem_tasks"
require "rake/testtask"

Rake::TestTask.new do |test|
  test.libs << "test"
  test.test_files = FileList["test/**/*_test.rb"]
  test.warning = false
end

task default: :test

desc "Generates an X509 certificate for decoding test ID tokens"
task "test:certificate:generate" do
  require "openssl"
  require "active_support"
  require "active_support/core_ext/integer/time"

  key = OpenSSL::PKey::RSA.new(File.read(File.expand_path("test/key.pem", __dir__)))

  certificate = OpenSSL::X509::Certificate.new
  certificate.subject = certificate.issuer = OpenSSL::X509::Name.parse("/CN=linkedin-sign-in-for-rails.example.com")
  certificate.not_before = Time.now
  certificate.not_after = 5.years.from_now
  certificate.public_key = key.public_key
  certificate.serial = 0
  certificate.version = 1

  extension_factory = OpenSSL::X509::ExtensionFactory.new
  extension_factory.subject_certificate = certificate
  extension_factory.issuer_certificate = certificate
  certificate.extensions = [
    extension_factory.create_extension("basicConstraints", "CA:FALSE", true),
    extension_factory.create_extension("keyUsage", "digitalSignature", true),
    extension_factory.create_extension("extendedKeyUsage", "clientAuth", true)
  ]

  certificate.sign(key, OpenSSL::Digest::SHA1.new)
  File.write(File.expand_path("test/certificate.pem", __dir__), certificate.to_pem)
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
linkedin_sign_in-0.6.0 Rakefile
linkedin_sign_in-0.5.0 Rakefile
linkedin_sign_in-0.4.0 Rakefile
linkedin_sign_in-0.3.1 Rakefile
linkedin_sign_in-0.3 Rakefile