summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-12-03 13:40:45 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2018-12-03 13:40:45 +0100
commitfe4b5c98201a92ab74b1a0648e2d881feb306ee5 (patch)
tree13bab3925e33a50e13708255439d735f4ba9e8e2 /spec/models
parent0f5073d9bb2dc5c7677c31605d66e2cc30f48d1f (diff)
downloadgitlab-ce-fe4b5c98201a92ab74b1a0648e2d881feb306ee5.tar.gz
Fix token encrypted strategy when migrating data
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/concerns/token_authenticatable_strategies/encrypted_spec.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/models/concerns/token_authenticatable_strategies/encrypted_spec.rb b/spec/models/concerns/token_authenticatable_strategies/encrypted_spec.rb
index 7dced6d79eb..556182ee50e 100644
--- a/spec/models/concerns/token_authenticatable_strategies/encrypted_spec.rb
+++ b/spec/models/concerns/token_authenticatable_strategies/encrypted_spec.rb
@@ -66,9 +66,26 @@ describe TokenAuthenticatableStrategies::Encrypted do
.with('some_field' => 'my-value')
.and_return(nil)
+ allow(model).to receive(:find_by)
+ .with('some_field_encrypted' => encrypted)
+ .and_return(nil)
+
expect(subject.find_token_authenticatable('my-value'))
.to be_nil
end
+
+ it 'finds by encrypted value if cleartext is not present' do
+ allow(model).to receive(:find_by)
+ .with('some_field' => 'my-value')
+ .and_return(nil)
+
+ allow(model).to receive(:find_by)
+ .with('some_field_encrypted' => encrypted)
+ .and_return('encrypted resource')
+
+ expect(subject.find_token_authenticatable('my-value'))
+ .to eq 'encrypted resource'
+ end
end
end