Files
railsgoat/spec/lib/encryption_spec.rb
T
robbiepaul 298610b5f6
CI / test (3.4.1) (push) Has been cancelled
Initial commit (history cleared)
2026-04-29 11:21:39 +01:00

25 lines
638 B
Ruby

# frozen_string_literal: true
require "spec_helper"
require_relative "../../lib/encryption"
describe Encryption do
let(:value) {
allow(Encryption).to receive(:key).and_return(SecureRandom.bytes(32))
allow(Encryption).to receive(:iv).and_return(SecureRandom.bytes(16))
"OMG PII"
}
it "encrypts values" do
encrypted = Encryption.encrypt_sensitive_value(value)
expect(Base64.decode64(encrypted)).not_to eq(value)
end
it "decrypts values" do
encrypted = Encryption.encrypt_sensitive_value(value)
decrypted = Encryption.decrypt_sensitive_value(encrypted)
expect(decrypted).to eq(value)
end
end