ref: master
plugins/stoa/test/unit/usp_user_test.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
require 'test_helper' class StoaPlugin::UspUserTest < ActiveSupport::TestCase SALT=YAML::load(File.open(StoaPlugin.root_path + 'config.yml'))['salt'] def setup StoaPlugin::UspUser.create({:codpes => 123456, :cpf => Digest::MD5.hexdigest(SALT+'12345678'), :birth_date => '1970-01-30'}, :without_protection => true) end should 'check existence of usp_id' do assert StoaPlugin::UspUser.exists?(123456) refute StoaPlugin::UspUser.exists?(654321) end should 'check if usp_id matches with a cpf' do assert StoaPlugin::UspUser.matches?(123456, :cpf, 12345678) refute StoaPlugin::UspUser.matches?(123456, :cpf, 87654321) refute StoaPlugin::UspUser.matches?(654321, :cpf, 12345678) end should 'check if usp_id matches with a birth_date' do assert StoaPlugin::UspUser.matches?(123456, :birth_date, '1970-01-30') refute StoaPlugin::UspUser.matches?(123456, :birth_date, '1999-01-30') refute StoaPlugin::UspUser.matches?(654321, :birth_date, '1970-01-30') end should 'filter leading zeroes of id codes on exists and matches' do assert StoaPlugin::UspUser.exists?('0000123456') assert StoaPlugin::UspUser.matches?(123456, :cpf, '00012345678') end should 'return false if field is nil' do assert !StoaPlugin::UspUser.matches?(123456, nil, '00012345678') end end |