diff options
author | Patricio Cano <suprnova32@gmail.com> | 2016-08-29 13:05:07 -0500 |
---|---|---|
committer | Patricio Cano <suprnova32@gmail.com> | 2016-09-15 12:21:00 -0500 |
commit | cb85cf1f0a7047c485d7b29b2792b8965e270898 (patch) | |
tree | c681b20e379478042e718afa1473af209af126a0 /spec/lib/gitlab/lfs_token_spec.rb | |
parent | 372be2d2e8fe8d607011aa7e2b2fca99eeea007d (diff) | |
download | gitlab-ce-cb85cf1f0a7047c485d7b29b2792b8965e270898.tar.gz |
Refactor LFS token logic to use a Redis key instead of a DB field, making it a 1 use only token.
Diffstat (limited to 'spec/lib/gitlab/lfs_token_spec.rb')
-rw-r--r-- | spec/lib/gitlab/lfs_token_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/lib/gitlab/lfs_token_spec.rb b/spec/lib/gitlab/lfs_token_spec.rb new file mode 100644 index 00000000000..76b348637c7 --- /dev/null +++ b/spec/lib/gitlab/lfs_token_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +describe Gitlab::LfsToken, lib: true do + describe '#set_token and #get_value' do + shared_examples 'an LFS token generator' do + it 'returns a randomly generated token' do + token = handler.set_token + + expect(token).not_to be_nil + expect(token).to be_a String + expect(token.length).to eq 50 + end + + it 'returns the correct token based on the key' do + token = handler.set_token + + expect(handler.get_value).to eq(token) + end + end + + context 'when the actor is a user' do + let(:actor) { create(:user) } + let(:handler) { described_class.new(actor) } + + it_behaves_like 'an LFS token generator' + end + + context 'when the actor is a deploy key' do + let(:actor) { create(:deploy_key) } + let(:handler) { described_class.new(actor) } + + it_behaves_like 'an LFS token generator' + end + end +end |