BigW Consortium Gitlab

personal_access_tokens.rb 467 Bytes
Newer Older
1
FactoryBot.define do
2 3 4
  factory :personal_access_token do
    user
    token { SecureRandom.hex(50) }
5
    sequence(:name) { |n| "PAT #{n}" }
6 7
    revoked false
    expires_at { 5.days.from_now }
8
    scopes ['api']
9
    impersonation false
10

11 12 13 14 15
    trait :impersonation do
      impersonation true
    end

    trait :revoked do
16 17 18
      revoked true
    end

19
    trait :expired do
20 21
      expires_at { 1.day.ago }
    end
22

23 24
    trait :invalid do
      token nil
25
    end
26 27
  end
end