Skip to content

Commit

Permalink
speed up VAOS specs 3x by loading rsa key instead of generating new o…
Browse files Browse the repository at this point in the history
…ne (#3602)
  • Loading branch information
saneshark authored Dec 6, 2019
1 parent 29d3e44 commit 90bad1c
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
51 changes: 51 additions & 0 deletions modules/vaos/spec/fixtures/open_ssl_rsa_private.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
-----BEGIN RSA PRIVATE KEY-----
MIIJKwIBAAKCAgEAypeU/1jBflNOJsCJ4byHuQ6i5LTOhSO+CNz96FzkSLJLLf6x
wq5601h14fqCEe5XUhPxmqgfIHDiu7EK+4rp0o0sSezCN+iOeJF7kWW+fTDYGLB3
T1clVGCYnHeM7eUgMdzmMmT7SXbFxT4vl1Nqe2ao6epqEuepH09m4/MWTncoO5fo
D3xIlnIx7QVn1SgbTsLzgYK9nKmCZHHx+sWoeZG3RIQTx87DlFXr1bpRhFQ6xgDy
eDuIxThTupCi8NPvZM0t9XQeY68IPOTWoLI8f5j9+cxmxByZVyKNUqN/2JOU6Wzq
QPfDTE0y+JHuDLAogssi5pAaN3NfH+0DgTRjVtrb4yRWfHrijRMcs8x+uSGp9PT1
cbZawFNYDN9YUKnxNSYPI/giCyO3bIww0YmgfV+UI7NOGpTBfQj73PxrYVK04dvI
/OXhTspmKN3nJ4B6rw4aZjQzARFRIacHbuehY2STRoQPVwIguNNmeC3PF1TKRcaG
O9Ls0WkFG+tUltAY02LXJJ3UqBSmiyI/4bGHPiBzVTrkdKczYWbu2v5QLCLx4jpi
84zYWJUTRePukjZU1u7PSjILw72GYsqh0kP5SwGUDyBc6/EmEuJ8fIgar9gJe5zL
UPu5mqlMi8AepepdZkAWFPayLi4MVRxIAO5Ti29Af1hgXmdc0rYOurmx9M0CAwEA
AQKCAgEAkWT8P825ACpVOiaQTft6BGvmp/DDDnY6Wi4P44VXKH0cy2Owu6Fw8ODZ
qVaZprjA3l0F1hK2VBfwAPfsg96MNNm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vl84KM7AG/hkWdAJBRcSNK
toIioUYcywO9H5JLKwx80krXDriY6Y76jOPkceNh8yD0B53kMK+FzKpmGS+1OUSE
2OCe0TOjumuM/xdpiAXwO0OWYfH+lmwvxIKDMnUsFHegPhRj5SnIKOZS2YFkxnWB
xKtX4KhmMMoIPLM8u5KulOqKlpysNJJNGDi0/4g3F/qMlsxiHUdvouZrBT7vd+I=
-----END RSA PRIVATE KEY-----
3 changes: 2 additions & 1 deletion modules/vaos/spec/services/jwt_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# frozen_string_literal: true

require 'rails_helper'
require_relative '../support/fixture_helper'

describe VAOS::JWT do
subject { VAOS::JWT.new(user) }

let(:user) { build(:user, :vaos) }
let(:rsa_private) { OpenSSL::PKey::RSA.generate(4096) }
let(:rsa_private) { OpenSSL::PKey::RSA.new(read_fixture_file('open_ssl_rsa_private.pem')) }
# JWT REGEX has 3 base64 url encoded parts (header, payload signature) and more importantly is non empty.
let(:jwt_regex) { %r{^[A-Za-z0-9\-_=]+\.[A-Za-z0-9\-_=]+\.?[A-Za-z0-9\-_.+/=]*$} }

Expand Down
3 changes: 2 additions & 1 deletion modules/vaos/spec/services/user_service_spec.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# frozen_string_literal: true

require 'rails_helper'
require_relative '../support/fixture_helper'

describe VAOS::UserService do
let(:user) { build(:user, :mhv) }

describe '#session' do
let(:rsa_private) { OpenSSL::PKey::RSA.generate 4096 }
let(:rsa_private) { OpenSSL::PKey::RSA.new(read_fixture_file('open_ssl_rsa_private.pem')) }
let(:token) { 'abc123' }
let(:response) { double('response', body: token) }

Expand Down
9 changes: 9 additions & 0 deletions modules/vaos/spec/support/fixture_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

def fixture_file_path(filename)
VAOS::Engine.root.join("spec/fixtures/#{filename}").to_s
end

def read_fixture_file(filename)
File.read fixture_file_path(filename)
end

0 comments on commit 90bad1c

Please sign in to comment.