start encoding candidate emails - completes #57

This commit is contained in:
Mark Moser
2016-08-26 16:03:55 -05:00
parent 8269bb9e5c
commit 229ebf1380
7 changed files with 123 additions and 9 deletions

View File

@ -2,7 +2,7 @@
roy: # Roy should have started, and is ready for a reminder
name: Roy Cruz
email: roy.cruz@mailinator.com
email: <%= CryptSerializer.dump 'roy.cruz@mailinator.com' %>
experience: 0-3
recruiter: recruiter
quiz: fed
@ -12,7 +12,7 @@ roy: # Roy should have started, and is ready for a reminder
gillian: # Gillian has not begun the test
name: Gillian Anderson
email: gillian.anderson@mailinator.com
email: <%= CryptSerializer.dump 'gillian.anderson@mailinator.com' %>
experience: 4-6
recruiter: recruiter
quiz: fed
@ -22,7 +22,7 @@ gillian: # Gillian has not begun the test
martha: # Martha has not begun the test
name: Martha Watts
email: martha.watts@mailinator.com
email: <%= CryptSerializer.dump 'martha.watts@mailinator.com' %>
experience: 4-6
recruiter: recruiter
quiz: fed
@ -32,7 +32,7 @@ martha: # Martha has not begun the test
dawn: # Dawn has completed, and been reminded, but not submitted the test
name: Dawn Hopkins
email: dawn.hopkins@mailinator.com
email: <%= CryptSerializer.dump 'dawn.hopkins@mailinator.com' %>
experience: 0-2
recruiter: recruiter
quiz: fed
@ -42,7 +42,7 @@ dawn: # Dawn has completed, and been reminded, but not submitted the test
peggy: # Peggy has completed, and been reminded, but not submitted the test
name: Peggy Blisters
email: peggy.blisters@mailinator.com
email: <%= CryptSerializer.dump 'peggy.blisters@mailinator.com' %>
experience: 0-2
recruiter: recruiter
quiz: fed
@ -52,7 +52,7 @@ peggy: # Peggy has completed, and been reminded, but not submitted the test
richard: # Richard has completed AND submitted the test
name: Richard Burns
email: richard.burns@mailinator.com
email: <%= CryptSerializer.dump 'richard.burns@mailinator.com' %>
experience: 15+
recruiter: recruiter
quiz: fed
@ -62,10 +62,10 @@ richard: # Richard has completed AND submitted the test
juan: # Juan has chosen "finish later" for live coders
name: Juan Campbell
email: juan.campbell@mailinator.com
email: <%= CryptSerializer.dump 'juan.campbell@mailinator.com' %>
experience: 15+
recruiter: recruiter
quiz: fed
completed: false
reminded: true
test_hash: qKQo0l4dyol
test_hash: <%= CryptSerializer.dump 'qKQo0l4dyol

View File

@ -9,4 +9,18 @@ class CandidateTest < ActiveSupport::TestCase
assert candidate.test_hash.present?
end
test "should encrypt emails" do
email = 'test@mailinator.com'
candidate = Candidate.create(name: 'new name',
email: email,
experience: '0-3',
recruiter_id: users(:recruiter).id,
quiz_id: quizzes(:fed).id)
sql = "select email from candidates where id = #{candidate.id};"
enc_email = ActiveRecord::Base.connection.execute(sql).first.first
refute_equal email, enc_email
end
end

View File

@ -0,0 +1,26 @@
require 'test_helper'
class CryptSerializerTest < ActiveSupport::TestCase
test "should generate marshaled array" do
string = "some string to encrypt"
encrypted = CryptSerializer.dump string
ar = Marshal.load(Base64.urlsafe_decode64(encrypted))
assert_instance_of Array, ar
assert_equal 3, ar.count
end
test "should encrypt and dencrypt" do
string = "test@string.email"
encrypted = CryptSerializer.dump string
decrypted = CryptSerializer.load encrypted
assert_equal string, decrypted
end
test "must raise RuntimeError" do
assert_raises RuntimeError do
CryptSerializer.dump nil
end
end
end