summaryrefslogtreecommitdiff
path: root/qa/qa/vendor/saml_idp/page/login.rb
blob: dc6925109f75fbd219d0b104e603c17ed683452a (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 'capybara/dsl'

module QA
  module Vendor
    module SamlIdp
      module Page
        class Login < Page::Base
          def login(username, password)
            QA::Runtime::Logger.debug("Logging into SAMLIdp with username: #{username} and password:#{password}")

            fill_in 'username', with: username
            fill_in 'password', with: password
            click_on 'Login'
          end

          def login_if_required(username, password)
            login(username, password) if login_required?
          end

          def login_required?
            login_required = page.has_text?('Enter your username and password')
            QA::Runtime::Logger.debug("login_required: #{login_required}")
            login_required
          end
        end
      end
    end
  end
end