diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-23 12:10:03 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-23 12:10:03 +0300 |
commit | 65f7976d0cd11d91a4c0945b2c63a1aa2f888b07 (patch) | |
tree | 07a0e774b12b29352ca6b3bd87b108879ebb00b9 /spec/lib/gitlab/terraform_registry_token_spec.rb | |
parent | 1165608bfd217a96e133487d6049a989a15789c4 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/terraform_registry_token_spec.rb')
-rw-r--r-- | spec/lib/gitlab/terraform_registry_token_spec.rb | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/lib/gitlab/terraform_registry_token_spec.rb b/spec/lib/gitlab/terraform_registry_token_spec.rb new file mode 100644 index 00000000000..49c1c07e942 --- /dev/null +++ b/spec/lib/gitlab/terraform_registry_token_spec.rb @@ -0,0 +1,41 @@ +# frozen_string_literal: true +require 'spec_helper' + +RSpec.describe Gitlab::TerraformRegistryToken do + let_it_be(:user) { create(:user) } + + describe '.from_token' do + let(:jwt_token) { described_class.from_token(token) } + + subject { described_class.decode(jwt_token.encoded) } + + context 'with a deploy token' do + let(:deploy_token) { create(:deploy_token, username: 'deployer') } + let(:token) { deploy_token } + + it 'returns the correct token' do + expect(subject['token']).to eq jwt_token['token'] + end + end + + context 'with a job' do + let_it_be(:job) { create(:ci_build) } + + let(:token) { job } + + it 'returns the correct token' do + expect(subject['token']).to eq jwt_token['token'] + end + end + + context 'with a personal access token' do + let(:token) { create(:personal_access_token) } + + it 'returns the correct token' do + expect(subject['token']).to eq jwt_token['token'] + end + end + end + + it_behaves_like 'a gitlab jwt token' +end |