Esempio n. 1
0
 def __init__(self, *args, **kwargs):
     EdTestBase.__init__(self, *args, **kwargs)
     DatabaseTestHelper.db_url = preferences(Edware.db_main_url)
     DatabaseTestHelper.db_schema_name = preferences(Edware.db_schema_name)
     create_connection(DatabaseTestHelper.db_url,
                       DatabaseTestHelper.db_schema_name,
                       datasource_name=DatabaseTestHelper.datasource_name)
Esempio n. 2
0
 def __init__(self, *args, **kwargs):
     ApiHelper.__init__(self, *args, **kwargs)
     TestServicesTriggerAPI.db_stat_url = preferences(Edware.db_stats_main_url)
     TestServicesTriggerAPI.db_schema_name = preferences(Edware.db_stats_schema)
     create_connection(
         TestServicesTriggerAPI.db_stat_url,
         TestServicesTriggerAPI.db_schema_name,
         datasource_name=TestServicesTriggerAPI.datasource_name
     )
Esempio n. 3
0
 def __init__(self, *args, **kwargs):
     EdTestBase.__init__(self, *args, **kwargs)
     self._response = None
     self._request_header = {}
     self._request_header['headers'] = {}
     self._items_to_check = None
     self._request_header['headers'] = {}
     # Assign static variables
     ApiHelper.db_url = preferences(Edware.db_edauth_main_url)
     ApiHelper.db_schema_name = preferences(Edware.db_edauth_schema_name)
 def __init__(self, *args, **kwargs):
     EdTestBase.__init__(self, *args, **kwargs)
     self._response = None
     self._request_header = {}
     self._request_header['headers'] = {}
     self._items_to_check = None
     self._request_header['headers'] = {}
     # Assign static variables
     ApiHelper.db_url = preferences(Edware.db_edauth_main_url)
     ApiHelper.db_schema_name = preferences(Edware.db_edauth_schema_name)
Esempio n. 5
0
 def __init__(self, *args, **kwargs):
     ApiHelper.__init__(self, *args, **kwargs)
     TestServicesTriggerAPI.db_stat_url = preferences(
         Edware.db_stats_main_url)
     TestServicesTriggerAPI.db_schema_name = preferences(
         Edware.db_stats_schema)
     create_connection(
         TestServicesTriggerAPI.db_stat_url,
         TestServicesTriggerAPI.db_schema_name,
         datasource_name=TestServicesTriggerAPI.datasource_name)
 def call_cleanup_script(self, expiration, config):
     cleanup_script_path = os.path.abspath(
         os.path.dirname(__file__)) + preferences(
             HPZ.cleanup_script_relative_location)
     subprocess.call('python {0} -e {1} -c {2}'.format(
         cleanup_script_path, str(expiration), config),
                     shell=True)
Esempio n. 7
0
 def authenticate_with_oauth(self, user_id):
     """
     Retrieve access token from SSO using oauth and sets the request header to use it in bearer
     """
     password = user_id + '1234'
     oauth_server = preferences(Default.idp_host) + '&username={user_id}&password={password}'.format(user_id=user_id,
                                                                                                     password=password)
     self.send_post(oauth_server)
     access_token = self._response.json()['access_token']
     self.update_request_header('Authorization', 'Bearer {0}'.format(access_token))
Esempio n. 8
0
 def setUp(self):
     self.test_file_name = 'test_file.tar'
     self.test_file = os.path.join(os.path.dirname(__file__), 'resources', self.test_file_name)
     old_downloaded_file = DOWNLOAD_DIRECTORY + self.test_file_name
     if os.path.exists(old_downloaded_file):
         os.remove(old_downloaded_file)
     if not os.path.exists(HPZ_UPLOAD_DIRECTORY):
         os.makedirs(HPZ_UPLOAD_DIRECTORY)
     if not os.path.exists(DOWNLOAD_DIRECTORY):
         os.makedirs(DOWNLOAD_DIRECTORY)
     self.files_to_delete = []
     self.base_url = self.get_hpz_url()
     self.reg_endpoint = preferences(HPZ.registration_endpoint)
     self.files_endpoint = preferences(HPZ.files_endpoint)
     self.reg_url = self.base_url + self.reg_endpoint
     self.upload_url = self.base_url + self.files_endpoint
     self.db = preferences(HPZ.db_main_url)
     self.db_schema = preferences(HPZ.db_schema_name)
     self.reg_table = preferences(HPZ.db_registration_table)
     create_connection(self.db, self.db_schema, 'hpz')
 def setUp(self):
     self.test_file_name = 'test_file.tar'
     self.test_file = os.path.join(os.path.dirname(__file__), 'resources',
                                   self.test_file_name)
     old_downloaded_file = DOWNLOAD_DIRECTORY + self.test_file_name
     if os.path.exists(old_downloaded_file):
         os.remove(old_downloaded_file)
     if not os.path.exists(HPZ_UPLOAD_DIRECTORY):
         os.makedirs(HPZ_UPLOAD_DIRECTORY)
     if not os.path.exists(DOWNLOAD_DIRECTORY):
         os.makedirs(DOWNLOAD_DIRECTORY)
     self.files_to_delete = []
     self.base_url = self.get_hpz_url()
     self.reg_endpoint = preferences(HPZ.registration_endpoint)
     self.files_endpoint = preferences(HPZ.files_endpoint)
     self.reg_url = self.base_url + self.reg_endpoint
     self.upload_url = self.base_url + self.files_endpoint
     self.db = preferences(HPZ.db_main_url)
     self.db_schema = preferences(HPZ.db_schema_name)
     self.reg_table = preferences(HPZ.db_registration_table)
     create_connection(self.db, self.db_schema, 'hpz')
Esempio n. 10
0
 def authenticate_with_oauth(self, user_id):
     """
     Retrieve access token from SSO using oauth and sets the request header to use it in bearer
     """
     password = user_id + '1234'
     oauth_server = preferences(
         Default.idp_host
     ) + '&username={user_id}&password={password}'.format(user_id=user_id,
                                                          password=password)
     self.send_post(oauth_server)
     access_token = self._response.json()['access_token']
     self.update_request_header('Authorization',
                                'Bearer {0}'.format(access_token))
Esempio n. 11
0
    def set_request_cookie(self, user_id):
        """
        POST request for non-json content body
        :param user_id: userid used to send the request
        :type user_id:string
        """
        # Assumes password is always user_id + 1234
        password = user_id + '1234'

        # Make a request to Access the smarter URL for the purpose of being re directed to the OPEN AM page.
        self.send_request("GET", "/data")
        json_response = self._response.json()
        redirect = json_response['redirect']
        self.send_request("GET", redirect, use_base=False)
        # This should redirect us to IDP page. Extract the response message.
        response = self._response.content.decode('utf-8')

        # Search for regular expressions from the response body
        goto = re.search('name=\\"goto\\" value=\\"(.*)\\"', response).group(1)
        sun_query = re.search('name=\\"SunQueryParamsString\\" value=\\"(.*)\\"', response).group(1)
        self.set_request_header('content-type', 'application/x-www-form-urlencoded')
        # Get the LOGIN FORM. Compose a redirect PATH using the parameters extracted from the last GET request made to smarter
        # Submit the request to get the login form from IDP.
        request_data = {'goto': goto, 'SunQueryParamsString': sun_query, 'IDButton': 'Log In', 'gx_charset': 'UTF-8',
                        'encoded': 'true', 'IDToken1': user_id, 'IDToken2': password}

        # Send login request to IDP
        self.send_post(preferences(Default.idp), request_data)
        # Extract the response received from IDP
        response = self._response.content.decode('utf-8')
        # https: Submit the login information in the login form received from the from previous request a
        # and send a post request to smarter to get the cookie information
        parser = html.parser.HTMLParser()
        url = re.search('action=\\"(.*?)\\"', response).group(1)
        samlresponse = re.search('name=\\"SAMLResponse\\" value=\\"(.*?)\\"', response).group(1)
        relaystate = re.search('name=\\"RelayState\\" value=\\"(.*?)\\"', response).group(1)
        data = {'SAMLResponse': samlresponse, 'RelayState': relaystate}

        self.set_request_header('content-type', 'application/x-www-form-urlencoded')
        # unescape the strings
        url = parser.unescape(str(url))
        data['SAMLResponse'] = parser.unescape(str(data['SAMLResponse']))
        data['RelayState'] = parser.unescape(str(data['RelayState']))

        # Send post request
        self.send_post(url, data)
        response = self._response.content.decode('utf-8')

        # Get the cookie from response
        cookie_value = self._response.cookies
        self._request_header['cookies'] = cookie_value
Esempio n. 12
0
 def get_hpz_url(self):
     return "http://{0}:{1}".format(preferences(Default.hpz_host), preferences(Default.hpz_port))
Esempio n. 13
0
    def set_request_cookie(self, user_id):
        """
        POST request for non-json content body
        :param user_id: userid used to send the request
        :type user_id:string
        """
        # Assumes password is always user_id + 1234
        password = user_id + '1234'

        # Make a request to Access the smarter URL for the purpose of being re directed to the OPEN AM page.
        self.send_request("GET", "/data")
        json_response = self._response.json()
        redirect = json_response['redirect']
        self.send_request("GET", redirect, use_base=False)
        # This should redirect us to IDP page. Extract the response message.
        response = self._response.content.decode('utf-8')

        # Search for regular expressions from the response body
        goto = re.search('name=\\"goto\\" value=\\"(.*)\\"', response).group(1)
        sun_query = re.search(
            'name=\\"SunQueryParamsString\\" value=\\"(.*)\\"',
            response).group(1)
        self.set_request_header('content-type',
                                'application/x-www-form-urlencoded')
        # Get the LOGIN FORM. Compose a redirect PATH using the parameters extracted from the last GET request made to smarter
        # Submit the request to get the login form from IDP.
        request_data = {
            'goto': goto,
            'SunQueryParamsString': sun_query,
            'IDButton': 'Log In',
            'gx_charset': 'UTF-8',
            'encoded': 'true',
            'IDToken1': user_id,
            'IDToken2': password
        }

        # Send login request to IDP
        self.send_post(preferences(Default.idp), request_data)
        # Extract the response received from IDP
        response = self._response.content.decode('utf-8')
        # https: Submit the login information in the login form received from the from previous request a
        # and send a post request to smarter to get the cookie information
        parser = html.parser.HTMLParser()
        url = re.search('action=\\"(.*?)\\"', response).group(1)
        samlresponse = re.search('name=\\"SAMLResponse\\" value=\\"(.*?)\\"',
                                 response).group(1)
        relaystate = re.search('name=\\"RelayState\\" value=\\"(.*?)\\"',
                               response).group(1)
        data = {'SAMLResponse': samlresponse, 'RelayState': relaystate}

        self.set_request_header('content-type',
                                'application/x-www-form-urlencoded')
        # unescape the strings
        url = parser.unescape(str(url))
        data['SAMLResponse'] = parser.unescape(str(data['SAMLResponse']))
        data['RelayState'] = parser.unescape(str(data['RelayState']))

        # Send post request
        self.send_post(url, data)
        response = self._response.content.decode('utf-8')

        # Get the cookie from response
        cookie_value = self._response.cookies
        self._request_header['cookies'] = cookie_value
Esempio n. 14
0
"""
Created on Feb 4, 2013

@author: nparoha
"""
import unittest

import allure
from allure.constants import AttachmentType
from selenium.webdriver.support.wait import WebDriverWait

from edware_testing_automation.pytest_webdriver_adaptor.pytest_webdriver_adaptor import browser
from edware_testing_automation.utils.preferences import preferences, Default

DOWNLOADS = preferences(Default.downloads_path)
UNZIPPED = preferences(Default.unzipped_path)


def save_screen(name):
    allure.attach(name, browser().get_screenshot_as_png(), type=AttachmentType.PNG)


def save_message(message, name='Additional information'):
    allure.attach(name, message, type=AttachmentType.TEXT)


def wait_for(method, seconds=60, message=''):
    return WebDriverWait(browser(), seconds).until(method, message)

Esempio n. 15
0
 def get_tsb_url(self):
     return "http://{0}:{1}".format(preferences(Default.tbs_host), preferences(Default.tbs_port))
Esempio n. 16
0
import os
import time

import allure
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions

from edware_testing_automation.frontend_tests.common_session_share_steps import SessionShareHelper
from edware_testing_automation.frontend_tests.indiv_student_helper import IndividualStudentHelper
from edware_testing_automation.frontend_tests.los_helper import LosHelper
from edware_testing_automation.pytest_webdriver_adaptor.pytest_webdriver_adaptor import browser
from edware_testing_automation.utils.preferences import Edware
from edware_testing_automation.utils.preferences import preferences
from edware_testing_automation.utils.test_base import save_screen, wait_for

full_reports_path = preferences(Edware.report_dir) + "/NC/2015/228/242/03/isr/INTERIM COMPREHENSIVE"


class MultipleOpportunities(IndividualStudentHelper, LosHelper, SessionShareHelper):
    """
    Tests for Individual Student Report
    """

    def __init__(self, *args, **kwargs):
        IndividualStudentHelper.__init__(self, *args, **kwargs)
        LosHelper.__init__(self, *args, **kwargs)
        SessionShareHelper.__init__(self, *args, **kwargs)

    def setUp(self):
        """ setUp: Open webpage """
        self.open_requested_page_redirects_login_page("state_view_sds")
Esempio n. 17
0
import csv
import json
import os
import shutil
import subprocess
import tarfile
import time

import allure

from edware_testing_automation.edapi_tests.api_helper import ApiHelper
from edware_testing_automation.frontend_tests.common_session_share_steps import SessionShareHelper
from edware_testing_automation.frontend_tests.extracts_helper import ExtractsHelper
from edware_testing_automation.utils.preferences import preferences, TSB

TSB_RAW_DATA_PATH = preferences(TSB.xml) + '/'
TSB_ITEM_LEVEL_PATH = preferences(TSB.csv) + '/'
STAGING_PATH = preferences(TSB.staging)
XML_FILE_PATH = os.path.join(os.getcwd(), '..', 'resources')


@allure.feature('Smarter: Integration with TSB')
class TestTSBAPI(ApiHelper, SessionShareHelper, ExtractsHelper):
    def __init__(self, *args, **kwargs):
        SessionShareHelper.__init__(self, *args, **kwargs)
        ExtractsHelper.__init__(self, *args, **kwargs)
        ApiHelper.__init__(self, *args, **kwargs)
        self.dest = '/tmp/tsb_decrypt'

    def setUp(self):
        self.clean_up()
Esempio n. 18
0
# to third party vendors solely for the purpose of performing services on behalf
# of such consortium member educational agencies.

import os

import allure
from sqlalchemy.sql import select

from edware_testing_automation.frontend_tests.common_session_share_steps import SessionShareHelper
from edware_testing_automation.hpz.hpz_helper import HpzHelper
from edware_testing_automation.utils.db_connector import DBConnection
from edware_testing_automation.utils.db_utils import create_connection
from edware_testing_automation.utils.preferences import preferences, HPZ
from edware_testing_automation.utils.test_base import DOWNLOADS

HPZ_UPLOAD_DIRECTORY = preferences(HPZ.uploads_directory) + '/'
DOWNLOAD_DIRECTORY = DOWNLOADS + "/"


class HpzSadPathTests(HpzHelper, SessionShareHelper):
    def __init__(self, *args, **kwargs):
        HpzHelper.__init__(self, *args, **kwargs)

    def tearDown(self):
        for file_to_delete in self.files_to_delete:
            if os.path.exists(file_to_delete):
                os.remove(file_to_delete)

    def setUp(self):
        self.test_file_name = 'test_file.tar'
        self.test_file = os.path.join(os.path.dirname(__file__), 'resources', self.test_file_name)
Esempio n. 19
0
@author: nparoha
"""
import os
import time

import allure
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions

from edware_testing_automation.frontend_tests.common_session_share_steps import SessionShareHelper
from edware_testing_automation.pytest_webdriver_adaptor.pytest_webdriver_adaptor import browser
from edware_testing_automation.utils.preferences import preferences, Edware
from edware_testing_automation.utils.test_base import save_screen, wait_for

_pdfs = preferences(Edware.report_dir)


@allure.feature('Smarter: Student view')
@allure.story('Print report')
class PrintPdfTest(SessionShareHelper):
    def __init__(self, *args, **kwargs):
        SessionShareHelper.__init__(self, *args, **kwargs)

    def setUp(self):
        self.open_requested_page_redirects_login_page("state_view_sds")
        self.enter_login_credentials("shall", "shall1234")
        self.check_redirected_requested_page("state_view_sds")

    def test_color_pdf(self):
        print("TC_COLOR_PDF: Validate that the pdf is printed from the UI and a directory structure is available.")
import csv
import json
import os
import shutil
import subprocess
import tarfile
import time

import allure

from edware_testing_automation.edapi_tests.api_helper import ApiHelper
from edware_testing_automation.frontend_tests.common_session_share_steps import SessionShareHelper
from edware_testing_automation.frontend_tests.extracts_helper import ExtractsHelper
from edware_testing_automation.utils.preferences import preferences, TSB

TSB_RAW_DATA_PATH = preferences(TSB.xml) + '/'
TSB_ITEM_LEVEL_PATH = preferences(TSB.csv) + '/'
STAGING_PATH = preferences(TSB.staging)
XML_FILE_PATH = os.path.join(os.getcwd(), '..', 'resources')


@allure.feature('Smarter: Integration with TSB')
class TestTSBAPI(ApiHelper, SessionShareHelper, ExtractsHelper):
    def __init__(self, *args, **kwargs):
        SessionShareHelper.__init__(self, *args, **kwargs)
        ExtractsHelper.__init__(self, *args, **kwargs)
        ApiHelper.__init__(self, *args, **kwargs)
        self.dest = '/tmp/tsb_decrypt'

    def setUp(self):
        self.clean_up()
Esempio n. 21
0
# of such consortium member educational agencies.
"""
Created on Feb 4, 2013

@author: nparoha
"""
import unittest

import allure
from allure.constants import AttachmentType
from selenium.webdriver.support.wait import WebDriverWait

from edware_testing_automation.pytest_webdriver_adaptor.pytest_webdriver_adaptor import browser
from edware_testing_automation.utils.preferences import preferences, Default

DOWNLOADS = preferences(Default.downloads_path)
UNZIPPED = preferences(Default.unzipped_path)


def save_screen(name):
    allure.attach(name,
                  browser().get_screenshot_as_png(),
                  type=AttachmentType.PNG)


def save_message(message, name='Additional information'):
    allure.attach(name, message, type=AttachmentType.TEXT)


def wait_for(method, seconds=60, message=''):
    return WebDriverWait(browser(), seconds).until(method, message)
# to third party vendors solely for the purpose of performing services on behalf
# of such consortium member educational agencies.

import os

import allure
from sqlalchemy.sql import select

from edware_testing_automation.frontend_tests.common_session_share_steps import SessionShareHelper
from edware_testing_automation.hpz.hpz_helper import HpzHelper
from edware_testing_automation.utils.db_connector import DBConnection
from edware_testing_automation.utils.db_utils import create_connection
from edware_testing_automation.utils.preferences import preferences, HPZ
from edware_testing_automation.utils.test_base import DOWNLOADS

HPZ_UPLOAD_DIRECTORY = preferences(HPZ.uploads_directory) + '/'
DOWNLOAD_DIRECTORY = DOWNLOADS + "/"


class HpzSadPathTests(HpzHelper, SessionShareHelper):
    def __init__(self, *args, **kwargs):
        HpzHelper.__init__(self, *args, **kwargs)

    def tearDown(self):
        for file_to_delete in self.files_to_delete:
            if os.path.exists(file_to_delete):
                os.remove(file_to_delete)

    def setUp(self):
        self.test_file_name = 'test_file.tar'
        self.test_file = os.path.join(os.path.dirname(__file__), 'resources',
Esempio n. 23
0
 def get_tsb_url(self):
     return "http://{0}:{1}".format(preferences(Default.tbs_host),
                                    preferences(Default.tbs_port))
Esempio n. 24
0
 def __init__(self, *args, **kwargs):
     EdTestBase.__init__(self, *args, **kwargs)
     DatabaseTestHelper.db_url = preferences(Edware.db_main_url)
     DatabaseTestHelper.db_schema_name = preferences(Edware.db_schema_name)
     create_connection(DatabaseTestHelper.db_url, DatabaseTestHelper.db_schema_name,
                       datasource_name=DatabaseTestHelper.datasource_name)
Esempio n. 25
0
 def get_hpz_url(self):
     return "http://{0}:{1}".format(preferences(Default.hpz_host),
                                    preferences(Default.hpz_port))
Esempio n. 26
0
import os
import time

import allure
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions

from edware_testing_automation.frontend_tests.common_session_share_steps import SessionShareHelper
from edware_testing_automation.frontend_tests.indiv_student_helper import IndividualStudentHelper
from edware_testing_automation.frontend_tests.los_helper import LosHelper
from edware_testing_automation.pytest_webdriver_adaptor.pytest_webdriver_adaptor import browser
from edware_testing_automation.utils.preferences import Edware
from edware_testing_automation.utils.preferences import preferences
from edware_testing_automation.utils.test_base import save_screen, wait_for

full_reports_path = preferences(
    Edware.report_dir) + "/NC/2015/228/242/03/isr/INTERIM COMPREHENSIVE"


class MultipleOpportunities(IndividualStudentHelper, LosHelper,
                            SessionShareHelper):
    """
    Tests for Individual Student Report
    """
    def __init__(self, *args, **kwargs):
        IndividualStudentHelper.__init__(self, *args, **kwargs)
        LosHelper.__init__(self, *args, **kwargs)
        SessionShareHelper.__init__(self, *args, **kwargs)

    def setUp(self):
        """ setUp: Open webpage """
        self.open_requested_page_redirects_login_page("state_view_sds")