diff options
Diffstat (limited to 'spec/lib/gitlab/doorkeeper_secret_storing/token/pbkdf2_sha512_spec.rb')
-rw-r--r-- | spec/lib/gitlab/doorkeeper_secret_storing/token/pbkdf2_sha512_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/lib/gitlab/doorkeeper_secret_storing/token/pbkdf2_sha512_spec.rb b/spec/lib/gitlab/doorkeeper_secret_storing/token/pbkdf2_sha512_spec.rb new file mode 100644 index 00000000000..c73744cd481 --- /dev/null +++ b/spec/lib/gitlab/doorkeeper_secret_storing/token/pbkdf2_sha512_spec.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::DoorkeeperSecretStoring::Token::Pbkdf2Sha512 do + describe '.transform_secret' do + let(:plaintext_token) { 'CzOBzBfU9F-HvsqfTaTXF4ivuuxYZuv3BoAK4pnvmyw' } + + it 'generates a PBKDF2+SHA512 hashed value in the correct format' do + expect(described_class.transform_secret(plaintext_token)) + .to eq("$pbkdf2-sha512$20000$$.c0G5XJVEew1TyeJk5TrkvB0VyOaTmDzPrsdNRED9vVeZlSyuG3G90F0ow23zUCiWKAVwmNnR/ceh.nJG3MdpQ") # rubocop:disable Layout/LineLength + end + + context 'when hash_oauth_tokens is disabled' do + before do + stub_feature_flags(hash_oauth_tokens: false) + end + + it 'returns a plaintext token' do + expect(described_class.transform_secret(plaintext_token)).to eq(plaintext_token) + end + end + end + + describe 'STRETCHES' do + it 'is 20_000' do + expect(described_class::STRETCHES).to eq(20_000) + end + end + + describe 'SALT' do + it 'is empty' do + expect(described_class::SALT).to be_empty + end + end +end |