Welcome to mirror list, hosted at ThFree Co, Russian Federation.

personal_access_token.rb « resource « qa « qa - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 6b2301ba9168f4e3a1e6ca29568a4aff3cf5532b (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
# frozen_string_literal: true

require 'date'

module QA
  module Resource
    ##
    # Create a personal access token that can be used by the api
    #
    class PersonalAccessToken < Base
      attr_accessor :name

      attribute :access_token do
        Page::Profile::PersonalAccessTokens.perform(&:created_access_token)
      end

      def fabricate!
        Page::Main::Menu.perform(&:click_edit_profile_link)
        Page::Profile::Menu.perform(&:click_access_tokens)

        Page::Profile::PersonalAccessTokens.perform do |token_page|
          token_page.fill_token_name(name || 'api-test-token')
          token_page.check_api
          # Expire in 2 days just in case the token is created just before midnight
          token_page.fill_expiry_date(Date.today + 2)
          token_page.click_create_token_button
        end
      end
    end
  end
end