Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 91F87104AF for ; Sun, 2 Mar 2014 21:25:55 +0000 (UTC) Received: (qmail 39873 invoked by uid 500); 2 Mar 2014 21:25:53 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 39767 invoked by uid 500); 2 Mar 2014 21:25:52 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 39733 invoked by uid 99); 2 Mar 2014 21:25:51 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Mar 2014 21:25:51 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id E09B7932D5D; Sun, 2 Mar 2014 21:25:50 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sebgoa@apache.org To: commits@cloudstack.apache.org Date: Sun, 02 Mar 2014 21:25:52 -0000 Message-Id: In-Reply-To: <034c91af6a904ab8b5a6d47e9b18ddef@git.apache.org> References: <034c91af6a904ab8b5a6d47e9b18ddef@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/3] git commit: updated refs/heads/master to cefd4ce initial check in Signed-off-by: Sebastien Goasguen Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/3800728d Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/3800728d Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/3800728d Branch: refs/heads/master Commit: 3800728df7becd5720036329f478a8229fd02a55 Parents: 90262a8 Author: yichi.lu Authored: Wed Feb 19 12:00:54 2014 -0600 Committer: Sebastien Goasguen Committed: Sun Mar 2 16:24:43 2014 -0500 ---------------------------------------------------------------------- test/selenium/browser/__init__.py | 0 test/selenium/browser/firefox.py | 39 ++++ test/selenium/common/Global_Locators.py | 230 +++++++++++++++++++ test/selenium/common/__init__.py | 0 test/selenium/common/shared.py | 134 +++++++++++ test/selenium/cspages/__init__.py | 0 test/selenium/cspages/loginpage.py | 63 +++++ test/selenium/cstests/__init__.py | 0 test/selenium/cstests/smoketests/__init__.py | 0 .../cstests/smoketests/login_logout_test.py | 93 ++++++++ test/selenium/cstests/smoketests/smokecfg.py | 21 ++ 11 files changed, 580 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3800728d/test/selenium/browser/__init__.py ---------------------------------------------------------------------- diff --git a/test/selenium/browser/__init__.py b/test/selenium/browser/__init__.py new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3800728d/test/selenium/browser/firefox.py ---------------------------------------------------------------------- diff --git a/test/selenium/browser/firefox.py b/test/selenium/browser/firefox.py new file mode 100644 index 0000000..e89619f --- /dev/null +++ b/test/selenium/browser/firefox.py @@ -0,0 +1,39 @@ +from selenium import webdriver +import time +from selenium.common.exceptions import WebDriverException +from selenium.common.exceptions import NoSuchElementException + +class Firefox(object): + def __init__(self, x_pos = 0, y_pos = 0, x_size = 1024, y_size = 768, timeout = 30): + self.browser = None + self.browser = webdriver.Firefox() + self.browser.set_page_load_timeout(timeout) + self.browser.set_window_position(x_pos, y_pos) + self.browser.set_window_size(x_size, y_size) + + def get_browser(self): + return self.browser + + def set_url(self, url): + if url == None or url == "": + print "A valid url is required" + return + self.url = url + self.browser.get(url) + + def quit_browser(self): + try: + self.browser.quit() + except NoSuchElementException as err: + print "Element error({0})".format(err.msg) + except WebDriverException as err: + print "WebDriver error({0})".format(err.msg) + + +if __name__ == "__main__": + # Create a new instance of the Firefox driver + browser = Firefox("Firefox") + browser.set_url("http://10.88.90.84:8080/client/") + time.sleep(3) + browser.quit_browser() + http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3800728d/test/selenium/common/Global_Locators.py ---------------------------------------------------------------------- diff --git a/test/selenium/common/Global_Locators.py b/test/selenium/common/Global_Locators.py new file mode 100644 index 0000000..1b03d7f --- /dev/null +++ b/test/selenium/common/Global_Locators.py @@ -0,0 +1,230 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +''' +Variable Names are as follows +Logical Page Descriptor_____What Element Represents and/or where it is_____LocatorType + + +For Example :: + +instances_xpath = "//div[@id='navigation']/ul/li[2]/span[2]" + +Means this is:: xpath link for Instances which is present on Dashboard. +Any test cases that requires to go into Instances from Dashboard can use this variable now. + +This may not be intuitive as you go deep into the tree. + + + +for example + +stopinstanceforce_id + +The best way to know what this represents is to track by variable name +Under Instances / any instance is click on any instance (applies to any instance) / stop instance has a force stop check box when you click. +This link represents that. + + +Steps below do not have global locators. + +PF rule steps including and after filling port numbers. (Refer to vmLifeAndNetwork.py / def test_PF) +FW rule steps including and after filling port numbers. (Refer to vmLifeAndNetwork.py / def test_PF) +ADD Disk Offering page has Names, description, storage type etc etc +ADD Compute Offering page has Names, description, CPU Cores, CPU clocks type etc etc + +Create Acc, Delete Acc, Login and Logout are for test flow and are not test cases. They do not have global Locators. + +Such and many more data entry points that appear only once and hence we do not need glonal names for them. They are hard coded as and when needed in the scripts. + + +''' + +################################################################################################################################################################################################ + +## Links on the Main UI page (Dash board). Listed in the order they appear on screen +dashboard_xpath = "//div[@id='navigation']/ul/li" +instances_xpath = "//div[@id='navigation']/ul/li[2]/span[2]" # Link for Instance and following as self explanatory +storage_xpath = "//div[@id='navigation']/ul/li[3]/span[2]" +network_xpath = "//div[@id='navigation']/ul/li[4]/span[2]" +templates_xpath = "//div[@id='navigation']/ul/li[5]/span[2]" +events_xpath = "//div[@id='navigation']/ul/li[6]/span[2]" +projects_xpath = "//div[@id='navigation']/ul/li[7]/span[2]" +accounts_xpath = "//div[@id='navigation']/ul/li[8]/span[2]" +domains_xpath = "//div[@id='navigation']/ul/li[9]/span[2]" +infrastructure_xpath = "//div[@id='navigation']/ul/li[10]/span[2]" +globalSettings_xpath = "//div[@id='navigation']/ul/li[11]/span[2]" +serviceOfferings_xpath = "//div[@id='navigation']/ul/li[12]/span[2]" + +################################################################################################################################################################################################ + +## Instances Page +## Instances Main page + + +# Add Instance Button on top right corner of Instances page +add_instance_xpath = "//div[2]/div/div[2]/div/div[2]/span" + +# Add Instance Wizard next button +add_instance_next_xpath = "//div[4]/div[2]/div[3]/div[3]/span" + +# Table that lists all VM's under Instances page; General usage is to traverse through this table and search for the VM we are interested in. +instances_table_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div/div[2]/div[2]/table/tbody/tr/td/span" + + +# Click any instance and following are available + +# Click ok on confirmation pop-up box for most actions listed below +actionconfirm_xpath = ("//button[@type='button']") + +# status of VM running. Click on VM > 3rd row in table +state_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div[2]/div[2]/div/div/div[2]/div/table/tbody/tr[3]/td[2]/span" + +# Stop instance icon +stopinstance_css = "a[alt=\"Stop Instance\"] > span.icon" + +# stop instance forcefully check box available after stop instance is executed in separate pop up +stopinstanceforce_id = ("force_stop") + +# start instance icon +startinstance_css = "a[alt=\"Start Instance\"] > span.icon" + +yesconfirmation_xapth = "(//button[@type='button'])[2]" + + +# Destroy instance icon +destroyinstance_css = "a[alt=\"Destroy Instance\"] > span.icon" + +#Restore Instance icon +restoreinstance_css = "a[alt=\"Restore Instance\"] > span.icon" + +# Reboot instance +rebootinstance_css = "a[alt=\"Reboot Instance\"] > span.icon" + +################################################################################################################################################################################################ + + +## Network Page + +# Table that lists all Networks under Network page; General usage is to traverse through this table and search for the network we are interested in. +network_networktable_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div[3]/div[2]/div/div[2]/table/tbody/tr/td/span" + +# View IP addresses button on each network page +viewIp_css="div.view-all > a > span" + +# Acquire a new ip +acquireIP_xpath="//div[2]/div/div/div[2]/span" +# List of IP's within a netork table +network_iptables_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div[3]/div[2]/div/div[2]/table/tbody/tr/td/span" +# Configuration tab for each IP +ipConfiguration_text="Configuration" +# PF under configuration for each IP +ip_PF = "li.portForwarding > div.view-details" + + +################################################################################################################################################################################################ + + +## Servivce Offering Page + +# Selects Compute offering from drop down menu +Offering_compute_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div/div[2]/div/div/div/select/option[1]" + +# Selects System offering from drop down menu +Offering_system_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div/div[2]/div/div/div/select/option[2]" + +# Selects Disk offering from drop down menu +Offering_disk_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div/div[2]/div/div/div/select/option[3]" + +# Selects Network offering from drop down menu +Offering_network_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div/div[2]/div/div/div/select/option[4]" + +# Add Offering +Offering_add_xpath ="//div[3]/span" + +# Points to tbale that lists Offerings +Offering_table_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div/div[2]/div[2]/table/tbody/tr/td/span" + +# Edit Button +Offering_edit_css = "a[alt=\"Edit\"] > span.icon" + +# Edit name box +Offering_editname_name = "name" + +# Edit description box +Offering_editdescription_name = "displaytext" + +# Edit finished click ok +Offering_editdone_css="div.button.done" + +# delete offering button for Disk only +Offering_delete_css = "a[alt=\"Delete Disk Offering\"] > span.icon" + +# delete offering button for Compute only +Offering_deletecompute_css = "a[alt=\"Delete Service Offering\"] > span.icon" + + + + +################################################################################################################################################################################################ + + +#### Templates Page + +# Selects Templates from drop down +template_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div/div[2]/div/div/div/select/option[1]" + +# Selects ISO from drop down +iso_xpath = "/html/body/div/div/div[2]/div[2]/div[2]/div/div[2]/div/div/div/select/option[2]" + +# Add Template +AddTemplate_xpath = "//div[3]/span" + +# Points to table where all templates are +template_table_xpath ="/html/body/div/div/div[2]/div[2]/div[2]/div/div[2]/div[2]/table/tbody/tr/td/span" + +# Edit Template Button +template_edit_css = "a[alt=\"Edit\"] > span.icon" + +# Edit finished click OK +template_editdone_css = "div.button.done" + +# Delete Template button +template_delete_css = "a[alt=\"Delete Template\"] > span.icon" + + +################################################################################################################################################################################################ + + +## Login Page + +# Username box +login_username_css = "body.login > div.login > form > div.fields > div.field.username > input[name=\"username\"]" # Login>Username TextBox + +# Password Box +login_password_css = "body.login > div.login > form > div.fields > div.field.password > input[name=\"password\"]" # LoginPassword TextBox + +# Click ok to login +login_submit_css = "body.login > div.login > form > div.fields > input[type=\"submit\"]" # Login>Login Button (Submit button) + + +################################################################################################################################################################################################ + + +## Logout +logout_css = "div.cloudstack3-container > div.container > div.header > div.controls div.user > div.user-options > a[text=\"Logout\"]" # Logout +# logout_css = "div#header > div#user-options > a[href='#']" http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3800728d/test/selenium/common/__init__.py ---------------------------------------------------------------------- diff --git a/test/selenium/common/__init__.py b/test/selenium/common/__init__.py new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3800728d/test/selenium/common/shared.py ---------------------------------------------------------------------- diff --git a/test/selenium/common/shared.py b/test/selenium/common/shared.py new file mode 100644 index 0000000..39f2d33 --- /dev/null +++ b/test/selenium/common/shared.py @@ -0,0 +1,134 @@ +#!/usr/bin/python +# coding: latin-1 + +from selenium.selenium import selenium +from selenium.common.exceptions import NoSuchElementException +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.common.exceptions import WebDriverException +from selenium.common.exceptions import TimeoutException +from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0 +from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0 +import re, sys, time, traceback + +def try_except_decor(func): + def try_except(*args, **kwargs): + try: + return func(*args, **kwargs) + except WebDriverException as err: + exc_type, exc_value, exc_traceback = sys.exc_info() + print "WebDriver error. Function: {0}, error: {1}".format(func.func_code, err) + print repr(traceback.format_exception(exc_type, exc_value,exc_traceback)) + except NoSuchElementException as err: + exc_type, exc_value, exc_traceback = sys.exc_info() + print "Element error. Function: {0}, error: {1}".format(func.func_code, err) + print repr(traceback.format_exception(exc_type, exc_value,exc_traceback)) + except TimeoutException as err: + exc_type, exc_value, exc_traceback = sys.exc_info() + print "Element error. Function: {0}, error: {1}".format(func.func_code, err) + print repr(traceback.format_exception(exc_type, exc_value,exc_traceback)) + + return try_except + +class Shared(object): + + @staticmethod + @try_except_decor + def option_selection(browser, element_type, element_name, option_text, wait_element_type = '', wait_element_name = ''): + + import pdb + pdb.set_trace() + ret = False + Shared.wait_for_element(browser, element_type, element_name) + if element_type == 'id': + ele = browser.find_element_by_id(element_name) + elif element_type == 'class_name': + ele = browser.find_element_by_class_name(element_name) + options = ele.find_elements_by_tag_name('option') + option_names = [option.text for option in options] + if option_text not in option_names: + return ret + + for option in options: + if option.text.find(option_text) > -1: + option.click() + ret = True + time.sleep(1) + break + + if len(wait_element_type) > 0 and len(wait_element_name) > 0: + Shared.wait_for_element(browser, wait_element_type, wait_element_name) + return ret + + @staticmethod + @try_except_decor + def flash_message(browser): + try: + ele1 = browser.find_element_by_id('flashMessageArea') + except NoSuchElementException: + ele1 = None + if ele1 != None: + ele2 = ele1.find_element_by_class_name('flash_message') + if ele2 != None and ele2.text != None and len(ele2.text) > 0: + return ele2.text + else: + return '' + else: + return '' + + @staticmethod + @try_except_decor + def string_selection(browser, key, value, index = 0): + element = browser.find_elements_by_id(key)[index] + element.clear() + element.send_keys(value) + + @staticmethod + def wait_until_title_text(browser, text, waittime = 30): + wait = WebDriverWait(browser, waittime) + wait.until(lambda browser: browser.title.lower().find(text.lower()) > -1) + + @staticmethod + def wait_until_find_id(browser, element_id, waittime = 10): + wait = WebDriverWait(browser, waittime) + wait.until(lambda browser: browser.find_element_by_id(element_id)) + + @staticmethod + # the name should exist in the newer page, but not in older one + def wait_for_element(browser, element_type, name, waittime = 30): + wait = WebDriverWait(browser, waittime) + if element_type.lower() == 'id': + wait.until(EC.presence_of_element_located((By.ID, name))) + elif element_type.lower() == 'tag_name': + wait.until(EC.presence_of_element_located((By.TAG_NAME, name))) + elif element_type.lower() == 'class_name': + wait.until(EC.presence_of_element_located((By.CLASS_NAME, name))) + elif element_type.lower() == 'xpath': + wait.until(EC.presence_of_element_located((By.XPATH, name))) + elif element_type.lower() == 'link_text': + wait.until(EC.presence_of_element_located((By.LINK_TEXT, name))) + + #feed the string through directly + else: + wait.until(EC.presence_of_element_located(element_type, name)) + + time.sleep(1) + + def playing_around(self): + from threading import Timer + t = Timer(20,self.wait_for_invisible) + t.start() + + @staticmethod + #wait until something disappears + def wait_for_invisible(browser, element_type, name, waittime=30): + wait = WebDriverWait(browser, waittime) + + # the code base uses underscores, but the real string doesn't have em. + final_type = re.sub('_',' ',element_type) + + wait.until(EC.invisibility_of_element_located((final_type, name))) + + #this method isn't as slick as I hoped :( + time.sleep(1) + http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3800728d/test/selenium/cspages/__init__.py ---------------------------------------------------------------------- diff --git a/test/selenium/cspages/__init__.py b/test/selenium/cspages/__init__.py new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3800728d/test/selenium/cspages/loginpage.py ---------------------------------------------------------------------- diff --git a/test/selenium/cspages/loginpage.py b/test/selenium/cspages/loginpage.py new file mode 100644 index 0000000..c6e736c --- /dev/null +++ b/test/selenium/cspages/loginpage.py @@ -0,0 +1,63 @@ +from selenium import webdriver +from selenium.common.exceptions import * +from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0 +from selenium.webdriver.common.action_chains import ActionChains as action +from common import Global_Locators + +from common.shared import * + +class LoginPage(object): + def __init__(self, browser): + self.browser = browser + self.username = "" + self.password = "" + self.language = "" + + @try_except_decor + def set_username(self, username): + self.username = username + usernameElement = self.browser.find_element_by_css_selector(Global_Locators.login_username_css) + usernameElement.send_keys(self.username) + + @try_except_decor + def set_password(self, password): + self.password = password + passwordElement = self.browser.find_element_by_css_selector(Global_Locators.login_password_css) + passwordElement.send_keys(self.password) + self.pwelement = passwordElement + + @try_except_decor + def set_language(self, language): + self.language = language + ele = self.browser.find_element_by_class_name('select-language') + option = ele.find_element_by_xpath("//option[@value='en']") + option.click() + + time.sleep(1) + + @try_except_decor + def login(self, expect_fail = False): + if self.username == "" or self.password == "": + print "Must set email and password before logging in" + return + loginElement = self.browser.find_element_by_css_selector(Global_Locators.login_submit_css) + loginElement.click() + + @try_except_decor + def logout(self): + # must click this icon options first + ele1 = self.browser.find_element_by_xpath("//div[@id='user' and @class='button']/div[@class='icon options']").click() + ele2 = self.browser.find_element_by_xpath("//div[@id='header']/div[@id='user-options']") + ele3 = ele2.find_element_by_link_text('Logout') + ele3.click() + + Shared.wait_for_element(self.browser, 'class_name', 'login') + + @try_except_decor + def get_error_msg(self, loginpage_url): + if loginpage_url is not None and len(loginpage_url) > 0 and \ + (self.browser.current_url.find(loginpage_url) > -1 or loginpage_url.find(self.browser.current_url) > -1): + ele = self.browser.find_element_by_id('std-err') + return ele.text + else: + return "" http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3800728d/test/selenium/cstests/__init__.py ---------------------------------------------------------------------- diff --git a/test/selenium/cstests/__init__.py b/test/selenium/cstests/__init__.py new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3800728d/test/selenium/cstests/smoketests/__init__.py ---------------------------------------------------------------------- diff --git a/test/selenium/cstests/smoketests/__init__.py b/test/selenium/cstests/smoketests/__init__.py new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3800728d/test/selenium/cstests/smoketests/login_logout_test.py ---------------------------------------------------------------------- diff --git a/test/selenium/cstests/smoketests/login_logout_test.py b/test/selenium/cstests/smoketests/login_logout_test.py new file mode 100644 index 0000000..49c545a --- /dev/null +++ b/test/selenium/cstests/smoketests/login_logout_test.py @@ -0,0 +1,93 @@ +import unittest +import sys, os, time +import json + +sys.path.append('./') + +import browser.firefox as firefox +import cspages.loginpage as loginpage +import common.shared as shared +from cstests.smoketests.smokecfg import smokecfg + +# from cstests.smoketests import smokecfg as smokecfg + +class TestCSLoginLogout(unittest.TestCase): + def setUp(self): + # Create a new instance of the Firefox browser + self.browser = firefox.Firefox('firefox') + + def tearDown(self): + self.browser.quit_browser() + + def test_success(self): + self.browser.set_url(smokecfg['cssite']) + self.loginpage = loginpage.LoginPage(self.browser.get_browser()) + self.loginpage.set_username(smokecfg['username']) + self.loginpage.set_password(smokecfg['password']) +# self.loginpage.set_language(smokecfg['language']) + self.loginpage.login() + shared.Shared.wait_for_element(self.browser.browser, 'id', 'navigation') + + time.sleep(5) + + self.loginpage.logout() + shared.Shared.wait_for_element(self.browser.browser, 'class_name', 'login') + + def test_failure_1(self): + self.browser.set_url(smokecfg['cssite']) + self.loginpage = loginpage.LoginPage(self.browser.get_browser()) + self.loginpage.set_username(smokecfg['badusername']) + self.loginpage.set_password(smokecfg['password']) + self.loginpage.login(expect_fail = True) + + def test_failure_2(self): + self.browser.set_url(smokecfg['cssite']) + self.loginpage = loginpage.LoginPage(self.browser.get_browser()) + self.loginpage.set_username(smokecfg['username']) + self.loginpage.set_password(smokecfg['badpassword']) + self.loginpage.login(expect_fail = True) + + def test_failure_3(self): + self.browser.set_url(smokecfg['cssite']) + self.loginpage = loginpage.LoginPage(self.browser.get_browser()) + self.loginpage.set_username(smokecfg['badusername']) + self.loginpage.set_password(smokecfg['badpassword']) + self.loginpage.login(expect_fail = True) + + def test_failure_4(self): + self.browser.set_url(smokecfg['cssite']) + self.loginpage = loginpage.LoginPage(self.browser.get_browser()) + self.loginpage.set_username(smokecfg['sqlinjection_1']) + self.loginpage.set_password(smokecfg['password']) + self.loginpage.login(expect_fail = True) + + def test_failure_5(self): + self.browser.set_url(smokecfg['cssite']) + self.loginpage = loginpage.LoginPage(self.browser.get_browser()) + self.loginpage.set_username(smokecfg['sqlinjection_2']) + self.loginpage.set_password(smokecfg['password']) + self.loginpage.login(expect_fail = True) + + def test_failure_6(self): + self.browser.set_url(smokecfg['cssite']) + self.loginpage = loginpage.LoginPage(self.browser.get_browser()) + self.loginpage.set_username(smokecfg['sqlinjection_3']) + self.loginpage.set_password(smokecfg['password']) + self.loginpage.login(expect_fail = True) + + def test_failure_7(self): + self.browser.set_url(smokecfg['cssite']) + self.loginpage = loginpage.LoginPage(self.browser.get_browser()) + self.loginpage.set_username(smokecfg['sqlinjection_4']) + self.loginpage.set_password(smokecfg['password']) + self.loginpage.login(expect_fail = True) + + def test_failure_8(self): + self.browser.set_url(smokecfg['cssite']) + self.loginpage = loginpage.LoginPage(self.browser.get_browser()) + self.loginpage.set_username(smokecfg['sqlinjection_5']) + self.loginpage.set_password(smokecfg['password']) + self.loginpage.login(expect_fail = True) + +if __name__ == '__main__': + unittest.main() http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3800728d/test/selenium/cstests/smoketests/smokecfg.py ---------------------------------------------------------------------- diff --git a/test/selenium/cstests/smoketests/smokecfg.py b/test/selenium/cstests/smoketests/smokecfg.py new file mode 100644 index 0000000..37d55b3 --- /dev/null +++ b/test/selenium/cstests/smoketests/smokecfg.py @@ -0,0 +1,21 @@ +#!/usr/bin/python +# coding: latin-1 + +smokecfg = { + 'browser': 'Firefox', + 'window position': '10, 10', # upper left coordinates + 'window size': '1200, 1000', + 'cssite': 'http://10.88.91.68:8080/client/', + 'username': 'admin', + 'password': 'password', + 'badusername': 'badname', + 'badpassword': 'badpassword', + 'sqlinjection_1': '\' or 1=1 --\'', + 'sqlinjection_2': '\' union select 1, badusername, badpassword, 1--\'', + 'sqlinjection_3': '\' union select @@version,1,1,1--\'', + 'sqlinjection_4': '\'; drop table user--\'', + 'sqlinjection_5': '\'OR\' \'=\'', + 'language': 'English', + } + +