Sha256: fee39365658e77c08483da5e7d957e20f6421d2b74781573e727b5109b20223e

Contents?: true

Size: 631 Bytes

Versions: 30

Compression:

Stored size: 631 Bytes

Contents

# frozen_string_literal: true

require 'active_support'
require 'active_support/core_ext/numeric/time'

class AdminAccessTokenSeed
  TOKEN_VALUE = 'ypCa3Dzb23o5nvsixwPA'
  SCOPES = Gitlab::Auth.all_available_scopes

  def self.seed!
    admin_user = User.find_by(username: 'root')

    token_params = {
      scopes: SCOPES.map(&:to_s),
      name: 'admin-api-token',
      expires_at: 3.days.from_now
    }

    admin_user.personal_access_tokens.build(token_params).tap do |pat|
      pat.set_token(TOKEN_VALUE)
      pat.save!
    end

    puts 'Personal access token seeded for root user.'
  end
end

AdminAccessTokenSeed.seed!

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
gitlab-qa-14.13.0 support/data/admin_access_token_seed.rb
gitlab-qa-14.12.0 support/data/admin_access_token_seed.rb
gitlab-qa-14.11.0 support/data/admin_access_token_seed.rb
gitlab-qa-14.9.0 support/data/admin_access_token_seed.rb
gitlab-qa-14.8.1 support/data/admin_access_token_seed.rb
gitlab-qa-14.8.0 support/data/admin_access_token_seed.rb
gitlab-qa-14.7.0 support/data/admin_access_token_seed.rb
gitlab-qa-14.6.0 support/data/admin_access_token_seed.rb
gitlab-qa-14.5.0 support/data/admin_access_token_seed.rb
gitlab-qa-14.4.0 support/data/admin_access_token_seed.rb
gitlab-qa-14.3.0 support/data/admin_access_token_seed.rb
gitlab-qa-14.2.1 support/data/admin_access_token_seed.rb
gitlab-qa-14.2.0 support/data/admin_access_token_seed.rb
gitlab-qa-14.1.0 support/data/admin_access_token_seed.rb
gitlab-qa-14.0.2 support/data/admin_access_token_seed.rb
gitlab-qa-14.0.1 support/data/admin_access_token_seed.rb
gitlab-qa-14.0.0 support/data/admin_access_token_seed.rb
gitlab-qa-13.2.1 support/data/admin_access_token_seed.rb
gitlab-qa-13.2.0 support/data/admin_access_token_seed.rb
gitlab-qa-13.1.0 support/data/admin_access_token_seed.rb