Use RSpec::Matchers in TC_Login

This commit is contained in:
Brendan Coles
2015-06-27 18:10:56 +00:00
parent c9c9bfa6ee
commit 1f40987355

View File

@@ -6,28 +6,30 @@
require 'test/unit'
require '../common/test_constants'
require '../common/beef_test'
require 'rspec/expectations'
class TC_Login < Test::Unit::TestCase
include RSpec::Matchers
def test_log_in
session = Capybara::Session.new(:selenium)
session.visit(ATTACK_URL)
sleep 2.0
BeefTest.save_screenshot(session)
session.has_content?('BeEF Authentication')
session.should have_title('BeEF Authentication')
session.fill_in 'user', :with => 'beef'
session.fill_in 'pass', :with => 'beef'
BeefTest.save_screenshot(session)
session.click_button('Login')
sleep 20.0
session.has_content?('logout')
sleep 10.0
session.should have_content('Logout')
BeefTest.save_screenshot(session)
session.driver.browser.close
end
def test_beef_test_login_function
session = BeefTest.login
session.has_content?('logout')
session.should have_content('Logout')
BeefTest.save_screenshot(session)
session.driver.browser.close
end
@@ -35,7 +37,8 @@ class TC_Login < Test::Unit::TestCase
def test_log_out
session = BeefTest.login
session.click_link('Logout')
session.has_content?('BeEF Authentication')
sleep 2.0
session.should have_title('BeEF Authentication')
BeefTest.save_screenshot(session)
session.driver.browser.close
end
@@ -43,7 +46,8 @@ class TC_Login < Test::Unit::TestCase
def test_beef_test_logout_function
session = BeefTest.login
session = BeefTest.logout(session)
session.has_content?('BeEF Authentication')
sleep 2.0
session.should have_title('BeEF Authentication')
BeefTest.save_screenshot(session)
session.driver.browser.close
end
@@ -51,13 +55,13 @@ class TC_Login < Test::Unit::TestCase
def test_logs_tab
session = BeefTest.login
session.click_on('Logs')
session.has_content?('logout')
session.has_content?('Hooked Browsers')
session.has_content?('Type')
session.has_content?('Event')
session.has_content?('Date')
session.has_content?('No logs to display')
session.has_content?('Page')
session.should have_content('Logout')
session.should have_content('Hooked Browsers')
session.should have_content('Type')
session.should have_content('Event')
session.should have_content('Date')
session.should have_content('Page')
session.should have_content('User with ip 127.0.0.1 has successfuly authenticated in the application')
BeefTest.save_screenshot(session)
BeefTest.logout(session)
@@ -70,15 +74,15 @@ class TC_Login < Test::Unit::TestCase
sleep 5.0
attacker.has_content?(VICTIM_DOMAIN)
attacker.has_content?('127.0.0.1')
attacker.should have_content(VICTIM_DOMAIN)
attacker.should have_content('127.0.0.1')
attacker.click_on('127.0.0.1')
sleep 1.0
attacker.has_content?('Details')
attacker.has_content?('Commands')
attacker.has_content?('Rider')
attacker.should have_content('Details')
attacker.should have_content('Commands')
attacker.should have_content('Rider')
BeefTest.save_screenshot(attacker)
BeefTest.save_screenshot(victim)