|
28 | 28 | client.use(key_vault_db)[key_vault_coll].drop |
29 | 29 | end |
30 | 30 |
|
31 | | - shared_examples 'an explicit encrypter' do |
| 31 | + shared_examples 'an explicit encrypter' do |decrypted_value| |
32 | 32 | it 'encrypts and decrypts the value using key_id' do |
33 | 33 | data_key_id = client_encryption.create_data_key( |
34 | 34 | kms_provider_name, |
|
44 | 44 | ) |
45 | 45 |
|
46 | 46 | decrypted = client_encryption.decrypt(encrypted) |
47 | | - expect(decrypted).to eq(value) |
48 | | - expect(decrypted).to be_a_kind_of(value.class) |
| 47 | + if decrypted_value.nil? |
| 48 | + expect(decrypted).to eq(value) |
| 49 | + expect(decrypted).to be_a_kind_of(value.class) |
| 50 | + else |
| 51 | + expect(decrypted).to eq(decrypted_value) |
| 52 | + expect(decrypted).to be_a_kind_of(decrypted_value.class) |
| 53 | + end |
49 | 54 | end |
50 | 55 |
|
51 | 56 | it 'encrypts and decrypts the value using key_alt_name' do |
|
63 | 68 | ) |
64 | 69 |
|
65 | 70 | decrypted = client_encryption.decrypt(encrypted) |
66 | | - expect(decrypted).to eq(value) |
67 | | - expect(decrypted).to be_a_kind_of(value.class) |
| 71 | + if decrypted_value.nil? |
| 72 | + expect(decrypted).to eq(value) |
| 73 | + expect(decrypted).to be_a_kind_of(value.class) |
| 74 | + else |
| 75 | + expect(decrypted).to eq(decrypted_value) |
| 76 | + expect(decrypted).to be_a_kind_of(decrypted_value.class) |
| 77 | + end |
68 | 78 | end |
69 | 79 | end |
70 | 80 |
|
|
140 | 150 | end |
141 | 151 | end |
142 | 152 |
|
| 153 | + context 'values is a large integer that requires BSON::Int64' do |
| 154 | + let(:value) { 2**40 } |
| 155 | + |
| 156 | + context 'when csfle_convert_to_ruby_types is true' do |
| 157 | + config_override :csfle_convert_to_ruby_types, true |
| 158 | + |
| 159 | + context 'with local KMS provider' do |
| 160 | + include_context 'with local kms_providers' |
| 161 | + |
| 162 | + it_behaves_like 'an explicit encrypter' |
| 163 | + end |
| 164 | + end |
| 165 | + |
| 166 | + context 'when csfle_convert_to_ruby_types is false' do |
| 167 | + config_override :csfle_convert_to_ruby_types, false |
| 168 | + |
| 169 | + context 'with local KMS provider' do |
| 170 | + include_context 'with local kms_providers' |
| 171 | + |
| 172 | + it_behaves_like 'an explicit encrypter', BSON::Int64.new(2**40) |
| 173 | + end |
| 174 | + end |
| 175 | + end |
| 176 | + |
143 | 177 | context 'value is an symbol' do |
144 | 178 | let(:value) { BSON::Symbol::Raw.new(:hello_world) } |
145 | 179 |
|
|
0 commit comments