summaryrefslogtreecommitdiff
path: root/qa/qa/page/profile/ssh_keys.rb
diff options
context:
space:
mode:
Diffstat (limited to 'qa/qa/page/profile/ssh_keys.rb')
-rw-r--r--qa/qa/page/profile/ssh_keys.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/qa/qa/page/profile/ssh_keys.rb b/qa/qa/page/profile/ssh_keys.rb
index 082202f91ca..810877e21ad 100644
--- a/qa/qa/page/profile/ssh_keys.rb
+++ b/qa/qa/page/profile/ssh_keys.rb
@@ -5,6 +5,7 @@ module QA
module Profile
class SSHKeys < Page::Base
view 'app/views/profiles/keys/_form.html.haml' do
+ element :key_expiry_date_field
element :key_title_field
element :key_public_key_field
element :add_key_button
@@ -19,17 +20,26 @@ module QA
end
def add_key(public_key, title)
- fill_element :key_public_key_field, public_key
- fill_element :key_title_field, title
+ fill_element(:key_public_key_field, public_key)
+ fill_element(:key_title_field, title)
+ # Expire in 2 days just in case the key is created just before midnight
+ fill_expiry_date(Date.today + 2)
- click_element :add_key_button
+ click_element(:add_key_button)
+ end
+
+ def fill_expiry_date(date)
+ date = date.strftime('%m/%d/%Y') if date.is_a?(Date)
+ Date.strptime(date, '%m/%d/%Y') rescue ArgumentError raise "Expiry date must be in mm/dd/yyyy format"
+
+ fill_element(:key_expiry_date_field, date)
end
def remove_key(title)
click_link(title)
accept_alert do
- click_element :delete_key_button
+ click_element(:delete_key_button)
end
end