Files
mip/tests/login_tests.rb
2008-03-17 14:32:25 +00:00

120 lines
6.0 KiB
Ruby
Raw Blame History

#---
#This unit test checks the bases screen.
#---
class Test_01_login_screen < Test::Unit::TestCase
#
#Test we can logon to the system using the webmip administrator user<65>s login credentials and check that
#all the columns required for the report appears with the button to create a new base record
#
def test_01_login_screen_appears
@@ie.goto(LOGIN)
#we'll need to login
assert(@@ie.text_field(:id,'P101_USERNAME').exists?,'Could not find P101_USERNAME field')
assert(@@ie.text_field(:id,'P101_PASSWORD').exists?,'Could not find P101_PASSWORD file upload field')
assert(@@ie.button(:value,'Login').exists?,'Could not find Login button')
assert(@@ie.button(:value,'New Password').exists?,'Could not find New Password button')
assert(@@ie.button(:value,'Forgotten Password').exists?,'Could not find Forgotten Password button')
end
def test_02_check_login_validation
#Test that T&Cs must be accepted
@@ie.button(:value,'Login').click
@@ie.wait
assert(@@ie.contains_text('Terms and Conditions must be accepted before entering this site'),'T&Cs must be accepted error not displaying.')
#Test that a username must be given
@@ie.radio( :id,'P101_TC_ACCEPTED_0').set #'I accept the Terms and Conditions of using this site'
@@ie.button(:value,'Login').click
@@ie.wait
assert(@@ie.contains_text('Value must be specified.'),'Expected not null error on username.')
# test that a password must be given
@@ie.text_field(:id,'P101_USERNAME').set 'login_test'
@@ie.radio( :id,'P101_TC_ACCEPTED_0').set #'I accept the Terms and Conditions of using this site'
@@ie.button(:value,'Login').click
@@ie.wait
assert(@@ie.contains_text('Invalid username/password specified.'),'Expected password error.')
# test that a valid user must be given
@@ie.text_field(:id,'P101_USERNAME').set 'not_a_user'
@@ie.text_field(:id,'P101_PASSWORD').set 'password'
@@ie.radio( :id,'P101_TC_ACCEPTED_0').set #'I accept the Terms and Conditions of using this site'
@@ie.button(:value,'Login').click
@@ie.wait
assert(@@ie.contains_text('Invalid username/password specified.'),'User specified does not exist in the system.')
# test that a valid password must be given
@@ie.text_field(:id,'P101_USERNAME').set 'login_test'
@@ie.text_field(:id,'P101_PASSWORD').set 'incorrect'
@@ie.radio( :id,'P101_TC_ACCEPTED_0').set #'I accept the Terms and Conditions of using this site'
@@ie.button(:value,'Login').click
@@ie.wait
assert(@@ie.contains_text('Invalid username/password specified.'),'Valid password error message incorrect.')
#@@ie.close
end
def test_03_open_user
#tests that a correct username and password for an "OPEN" user is accepted and the user is redirected correctly
@@ie.goto(LOGIN)
@@ie.text_field(:id,'P101_USERNAME').set 'login_test'
@@ie.text_field(:id,'P101_PASSWORD').set 'password'
@@ie.radio( :id,'P101_TC_ACCEPTED_0').set #'I accept the Terms and Conditions of using this site'
@@ie.button(:value,'Login').click
@@ie.wait
assert(@@ie.contains_text('Search Enquiries'),'User specified does not exist in the system.')
#@@ie.close
end
def test_04_expired_password
#tests that a correct username and password for an "EXPIRED" user is accepted and the user is redirected correctly
@@ie.goto(LOGIN)
@@ie.text_field(:id,'P101_USERNAME').set 'expired_user'
@@ie.text_field(:id,'P101_PASSWORD').set 'password'
@@ie.radio( :id,'P101_TC_ACCEPTED_0').set #'I accept the Terms and Conditions of using this site'
@@ie.button(:value,'Login').click
@@ie.wait
assert(@@ie.contains_text('Change Password'),'Expired user account not redirected correctly during logon.')
#@@ie.close
end
def test_05_locked_account
#tests that a correct username and password for an "LOCKED" user is accepted and the user is redirected correctly
@@ie.goto(LOGIN)
@@ie.text_field(:id,'P101_USERNAME').set 'locked_user'
@@ie.text_field(:id,'P101_PASSWORD').set 'password'
@@ie.radio( :id,'P101_TC_ACCEPTED_0').set #'I accept the Terms and Conditions of using this site'
@@ie.button(:value,'Login').click
@@ie.wait
assert(@@ie.contains_text('The user account specified is locked. Please contact the system administrator.'),'Locked user account not redirected correctly during logon.')
#ie.close
end
def test_06_expired_account_password_change
#tests that a correct username and password for an "EXPIRED" user is accepted and the user is redirected correctly
@@ie.goto(LOGIN)
@@ie.text_field(:id,'P101_USERNAME').set 'expired_user'
@@ie.text_field(:id,'P101_PASSWORD').set 'password'
@@ie.radio( :id,'P101_TC_ACCEPTED_0').set #'I accept the Terms and Conditions of using this site'
@@ie.button(:value,'Login').click
@@ie.wait
#confirm we're at the right page
assert(@@ie.contains_text('Change Password'),'Expired user account not redirected correctly during logon.')
#fill in some new password details - make sure that we follow security protocol for passwords...
@@ie.text_field(:id,'P102_NEW_PASSWORD').set 'P4ssw0rd.'
@@ie.text_field(:id,'P102_REPEAT_PASSWORD').set 'P4ssw0rd.'
@@ie.button(:value,'Change Password').click
@@ie.wait
#confirm the password was updated correctly
assert(@@ie.contains_text('Password updated.'),'Password not updated.')
#now log back in with the new password
@@ie.button(:value,'Login').click
@@ie.wait
assert(@@ie.button(:value,'Login').exists?,'Not navigated back to login page.')
@@ie.text_field(:id,'P101_USERNAME').set 'expired_user'
@@ie.text_field(:id,'P101_PASSWORD').set 'P4ssw0rd.'
@@ie.radio( :id,'P101_TC_ACCEPTED_0').set #'I accept the Terms and Conditions of using this site'
@@ie.button(:value,'Login').click
@@ie.wait
#confirm we're at the right page
assert(@@ie.contains_text('Search Enquiries'),'Unsuccessful attempt at login.')
end
##close IE if still open
#@@ie.close
end