summaryrefslogtreecommitdiff
path: root/spec/lib/gitlab/auth/atlassian/auth_hash_spec.rb
blob: c57b15361c4f8c94321cd821213441ca17f05fff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Gitlab::Auth::Atlassian::AuthHash do
  let(:auth_hash) do
    described_class.new(
      OmniAuth::AuthHash.new(uid: 'john', credentials: credentials)
    )
  end

  let(:credentials) do
    {
      token: 'super_secret_token',
      refresh_token: 'super_secret_refresh_token',
      expires_at: 2.weeks.from_now.to_i,
      expires: true
    }
  end

  describe '#uid' do
    it 'returns the correct uid' do
      expect(auth_hash.uid).to eq('john')
    end
  end

  describe '#token' do
    it 'returns the correct token' do
      expect(auth_hash.token).to eq(credentials[:token])
    end
  end

  describe '#refresh_token' do
    it 'returns the correct refresh token' do
      expect(auth_hash.refresh_token).to eq(credentials[:refresh_token])
    end
  end

  describe '#token' do
    it 'returns the correct expires boolean' do
      expect(auth_hash.expires?).to eq(credentials[:expires])
    end
  end

  describe '#token' do
    it 'returns the correct expiration' do
      expect(auth_hash.expires_at).to eq(credentials[:expires_at])
    end
  end
end